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

1) Versant数据库能够直接支持复杂的业务模型:node

public class Person {数据库

String firstName;session

String lastName;数据结构

String gender;dom

String ethnicity;分布式

String language;this

// 新增的节点spa

int index = 5;.net

Contact info;对象

Location location;

public String primaryCountry;

public String primaryAreaCode;

HashSet<Person> friends = new HashSet<Person>();

HashSet<Person> colleagues = new HashSet<Person>();

HashSet<Person> family = new HashSet<Person>();

HashSet<Person> relations = new HashSet<Person>();

}

Versant数据库能够直接支持包括HashSetLinkedList在内的复杂数据结构。

2Versant数据库能够直接支持复杂的对象间的关系

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

public void addFriend( Person p ){

friends.add(p);

addRelation(p);

p.getFriends().add(this);

}

3Versant数据库能够很容易的创建和数据库之间的链接:

Iterator<DatabaseLoginHelper> 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[0]);

session.addToLogicalDatabase(HPC_DEMO_NETWORK_NAME, helper.databaseName);

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

4Versant数据库能够很容易地建立对象,并保存到数据库中。

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();

上面的例子中,能够实现自动将数据对象配载到分布式数据库的不一样节点中。

相关文章
相关标签/搜索