我可以在 OrientDB 上的查询期间访问对象的集群名称吗? [英] Can I access Cluster/s name for objects during a query on OrientDB?

查看:53
本文介绍了我可以在 OrientDB 上的查询期间访问对象的集群名称吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这可能是由于设计不佳,所以任何建议将不胜感激.

Maybe this could be due a poor design, so any advice will be appreciated.

我有一个图形数据库,可以帮助我基于继承对对象的关联进行建模,例如

I got a graph database that helps me model associations of objects based on Inheritance, for example

class:Element <----- class:Car

所以如果我买了一辆新车,我就把它插入汽车类

So if I get a new car, I just insert it into car class

后来我添加了需求,为了保持一个元模型",或者是所有明星进入模型的数据的愿景,同时为用户维护数据分离,为了实现这一点,我决定每个用户的数据,应该去单独的一组集群.

Later I added the requirement, to keep a "metamodel", or a vision of all the data that stars getting into the model, while mantaining data separation for users, to achieve this, I decided that the data for each user, should go to separate set of clusters.

因此,如果 personA 尝试在 car 中插入一些东西,系统将自动创建新集群,并将元素放在正确的集群上.

So if personA tries to insert something inside car, the system is going to create automatically the new cluster, and put the element on the right cluster.

class:Element <----- class:Car ------ cluster:personA_Car

这个模型同样适用于关系和其他类型的元素.

This model applies the same for relationships and other kind of elements.

在 class:Car 的同一级别,驻留着稍后将与汽车相关的其他类,例如割草机、自行车,所有这些类都是动态创建的,数据和关系的集群也是如此.

At the same level of class:Car, resides other classes that are going to be later related with car, for example, lawnmower, bike, all this classes are created dynamically, as are the clusters for the data and the relationships.

底线,模型看起来像一棵树,其中使用关系,我关联不同类型的对象,为了区分用户 A 到用户 B,我使用集群,但查询时我只有集群名称的前缀,但我不知道我的根元素所在的实际集群.

Bottom line, the model looks like a tree, where using relationships, I associate different kind of objects, and to differentiate from user A to user B, I use cluster, but when querying I only have the prefix of the cluster names, but the actual cluster where my root element resides is unknown for me.

概括地说,我需要找到一种方法来为personA做这样的事情:

To generalize, I need to find a way to be able to do something like this for personA:

 select * from Element e where in.in.size() is null (and 'e' resides on cluster starting with personA)

除了在 orientEngine 上做第一部分,然后编码第二部分以获得 clusterName 并得到正确的,还有其他更好的方法吗?

Besides doing the first part on the orientEngine, and coding the second part to get the clusterName, and get the correct one, is there another better approach?

推荐答案

从 orientDb 团队收到的答复:

Answer recieved from the orientDb team:

嗨卡米洛,

在此阶段,无法在查询中访问集群名称.您可以定义一个自定义 javascript 函数,该函数根据记录(使用本机 API)检索集群名称,然后在您的查询中使用此函数.无论如何,每个用户使用集群的想法可能会导致一些问题:在当前版本中,每个数据库最多只能有 32.000 个集群,因此您可能会用完可用集群.我建议您采用不同的策略,例如.添加用户实体并将其从您的元素记录中链接.这样你的查询就会很直接

at this stage there is no way to access cluster name inside a query. You can define a custom javascript function that retrieves a cluster name based on a record (using native APIs) and then use this function in your queries. Anyway, the idea of using a cluster per user will probably lead to some problems: in current release you have a limitation to max 32.000 clusters per database, so you will probably run out of available clusters in short. I suggest you to adopt a different strategy, eg. adding a User entity and linking it from your Element records. This way your queries will be straight forward

原帖https://groups.google.com/forum/#!searchin/orient-database/Can$20I$20access$20Cluster$2Fs$20name$20for$20objects$20during$20a$20query/orient-database/YvKaRLeHWqI/A78ZIkBABQAJ

original post https://groups.google.com/forum/#!searchin/orient-database/Can$20I$20access$20Cluster$2Fs$20name$20for$20objects$20during$20a$20query/orient-database/YvKaRLeHWqI/A78ZIkBABQAJ

这篇关于我可以在 OrientDB 上的查询期间访问对象的集群名称吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆