公开分布式高性能查询的源代码和部署方案(一)
2012-04-23 00:00
148 查看
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(); 上面的例子中,可以实现自动将数据对象配载到分布式数据库的不同节点中。 |
相关文章推荐
- 公开分布式高性能查询的源代码和部署方案.(二)
- 公开分布式高性能查询的源代码和部署方案(三)
- 公开分布式高性能查询的源代码和部署方案(三)
- 公开分布式高性能查询的源代码和部署方案.(二)
- 公开分布式高性能查询的源代码和部署方案(一)
- 公开SNS社区即时找朋友链的源代码和部署方案(续四)
- 公开SNS社区即时找朋友链的源代码和部署方案(续三)
- 公开SNS社区即时找朋友链的源代码和部署方案(续五)
- 公开SNS社区即时找朋友链的源代码和部署方案(续六)
- 公开SNS社区即时找朋友链的源代码和部署方案(续六)
- 公开SNS社区即时找朋友链的源代码和部署方案(续五)
- 【云星数据---mesos实战系列002】:mesos全分布式部署实战006--mesos全分布式部署方案
- 项目分布式部署那些事(2):基于OCS(Memcached)的Session共享方案
- zookeeper分布式部署方案
- Memcached常规应用与分布式部署方案
- 矢量切片应用中geoserver与geowebcache分布式部署方案
- Zabbix监控和分布式部署实施方案
- Memcache分布式部署方案
- 【云星数据---mesos实战系列002】:mesos全分布式部署实战007--mesos集成docker方案
- 基于云的分布式部署开发环境方案