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

本文介绍了Versant数据库的几个核心特点:直接支持复杂的业务模型和数据结构,如HashSet和LinkedList;支持复杂对象间的关系;轻松建立数据库连接;并能够简便地创建对象并保存到分布式数据库中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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<Person> friends = new HashSet<Person>();

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

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

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

}

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


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

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

public void addFriend( Person p ){

friends.add(p);

addRelation(p);

p.getFriends().add(this);

}


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

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


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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值