ITeye博客

公开分布式高性能查询的源代码和部署方案(一)

markhe · 2012-04-26 16:09 · 数据库 · Markdown

1) Versant数据库可以直接支持复杂的业务模型:

public class Person {

String firstName;

String lastName;

String gender;

String ethnicity;

String language;

// 新增的节点

int index = 5;

Contact info;

Location location;

public String primaryCountry;

public String primaryAreaCode;

HashSet friends = new HashSet();

HashSet colleagues = new HashSet();

HashSet family = new HashSet();

HashSet relations = new HashSet();

}

Versant数据库可以直接支持包括HashSet、LinkedList在内的复杂数据结构。

2)Versant数据库可以直接支持复杂的对象间的关系

如下的代码中展示了一个两层的关系结构。

public void addFriend( Person p ){

friends.add(p);

addRelation(p);

p.getFriends().add(this);

}

3)Versant数据库可以很容易的建立和数据库之间的连接:

Iterator ite = this.dblist.iterator();

DatabaseLoginHelper helper = (DatabaseLoginHelper)ite.next();

session = new TransSession(helper.getDatabaseNodeProperty());

session.setSchemaOption(TransSession.SCHEMA_ADD_DROP_ATTRIBUTES);

// System.out.println("Define Logical database:");

session.newLogicalDatabase(HPC_DEMO_NETWORK_NAME);

// System.out.println("Add to logical database:"+dbList);

session.addToLogicalDatabase(HPC_DEMO_NETWORK_NAME, helper.databaseName);

System.out.println("Add to logical database:" + helper.databaseName);

4)Versant数据库可以很容易地创建对象,并保存到数据库中。

TransSession session = DistributedDatabaseManager.getInstance()

.createNewSession();

session.setDefaultDatabase("dbnodeb");

// TransSession session = new TransSession("dbnodea");

/**

  • generate 500 random objects

*/

for (int i = 0; i < 1500; i++) {

Person person = new Person();

person.setFirstName("TFistName" + i);

person.setLastName("TListName" + i);

// set storage schema

DistributedDatabaseManager.getInstance()

.setRoundRobinPersistentSchema();

session.makePersistent(person);

session.commit();

}

System.out.println("Demo data generated.");

session.commit();

上面的例子中,可以实现自动将数据对象配载到分布式数据库的不同节点中。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。