Tinkerpop: Creating nested Properties - gremlin

I want to create a Vertex of label foo, which contains a property child. Child property will have two properties A, B. Child in itself can contain more nested children.
If vertex foo is deleted, its all properties including child property should be deleted. My query pattern would be to query all vertexes of label foo which has property A = 'bar'
This can be easily represented by representing the child as vertices instead of property, but then the child has to be deleted by doing dfs/bfs originating from vertex foo. This is proving a costly affair. If childs are saved as property, drop operation will be saved of dfs/bfs.
How do I create nested properties and how can I query them using apache tinkerpop. Is there any other data model I can adopt to reduce the query cost.

Neptune does not support meta properties. Even if it would, you should not have used them. If you have hierarchical structure, and you already use a graph DB, then you should benefit from its capabilities.
If just storing nested properties is your need, maybe you should look at document DB instead.
Deleting a child vertex should not be an expensive operation:
g.V(child_id).emit().repeat(out()).drop()

Related

kotlin firebase remove child

I'm trying to delete a specific value from a firebase realtime database, but I don't know how to do it because I don't know to save or find the key value of the child which is automatically generate.
If you see the picture I've only managed to remove all the children from the first key with
FirebaseDatabase.getInstance().reference.child("Comentarios").removeValue()
But I need to delete just by the child creadoPor
Is there any way of skkiping an unnamed child?
FirebaseDatabase.getInstance().reference.child("Comentarios").removeValue()
But I need to delete just by the child creadoPor.
Since you know the "grantparent" key of the data and the value of one of the nodes properties, you can use a query to find the nodes that match that value.
FirebaseDatabase.instance
.ref("Comentarios")
.child("-NGi7xP...")
.orderByChild("creadoPor")
.equalTo("R7lji3...")
When you get the DataSnapshot from the query, you'll need to loop over its children as shown in the documentation on listening for value events. Even when there's only one result, you'll get a list of one child node and thus will need to loop over them.

DynamoDB index only a specific set of values

My dynamoDB index is flooding with huge data. I would like to choose values that could be indexed and avoid indexing the rest. Is this possible?
Lets say, below are the sample items:
parent item:
{
"hashKey":"a1"
"indexHashKey":"parentType"
"indexRangeKey":"date1"
}
child item:
{
"hashKey":"a2"
"indexHashKey":"childType"
"indexRangeKey":"date11"
}
In my use case, I am always going to ask index to fetch only parentType records. The index is getting loaded with huge data because the childTypes are also getting indexed (and thats the nature). I would like to choose specific values (lets say 'parentType1', 'parentType2') to get indexed in dynamoDB. Is there any feature dynamoDB provides for this purpose?
Alternative:
If there is no such capability dynamoDB provides, then I should either
* avoid storing the child type of the item. But it would be good to have the child type stored.
or
* Maintain two different fields. One to store parent record type and another to store child record type. This looks ugly.
Any suggestions would be helpful.
To be clear, you are storing both parent and child items in a single table and want an index on the table to only contain child items? Is this a correct representation of your problem?
If you do not want all the data in a DynamoDB table to be in an index, you need to design a sparse index, which is a regular index where the attributes specified for the index hash & range keys are NOT on every item in the table. Your issue is that your 'indexHashKey' and 'indexRangeKey' attributes are on ALL your parent and child items, so they are all showing up in your index. Remember, items in a DynamoDB table can have different attributes; at a minimum, they need to contain the table's hash key and sort key (if the table has one), but they do not need to contain attributes that happen to be keys for any index attached to the table.
Consider modifying your items to only include the index hash & range key attributes on your parent items. For example:
parent item:
{
"hashKey":"a1"
"parentIndexHashKey":"parentType"
"parentIndexRangeKey":"date1"
}
Then you can do a query on that index by parent type (e.g. parentType == "parentType2") and return only the parent items in that table with that type.
If you also need to run a similar query for only child items, you can create a second sparse index that only has child items, by setting attributes for that index's hash and sort keys only on child items.
child item:
{
"hashKey":"a2"
"childIndexHashKey":"childType"
"childIndexRangeKey":"date11"
}
Alternatively, you can store parent and child items in separate DynamoDB tables so that there is no way for child items to get into the parent index and interfere with your queries.

Alfresco: Search all nodes without parents

I'd like to know how to get all nodes of a given type ts:folderSet which has no parent association of type ts:FolderSubSet informed.
Currently:
So, I mean, I need all nodes of type ts:folderSet where tsfss:folderSubSet-folder is null or not informed.
Currently, I'm using admin tool in order to build this query, but I'll need to use it into a java code.
So I mean, I can use FTS or lucene...
Any ideas?
If your parent type is different you can do:
+TYPE:"ts:folderSet"
The problem is that the PARENT keyword in search uses the primary parent. Your ts:folderSubSet object is a secondary parent to your ts:folderSet object. I don't think you will be able to write a single query that can find instances of ts:folderSet that do not have an instance of ts:folderSubSet as a secondary parent.
You can write a query that returns ts:folderSet objects and then you can iterate over each one of the results checking its list of parents for the secondary object. Not ideal, but it is probably the best you can do.
You can search for a type of nodes using the following Lucene query
TYPE:"cm:folder"

NSFetchRequest with sort descriptors for recursive CoreData Entity relationship

I have got a simple CoreData entity "MyEntity" with a recursive relationship:
(The relation is a one-to-one relation in this case)
Imagine I had created 5 objects of this entity:
ObjectA -> ObjectB -> ObjectC -> ObjectD -> ObjectE
(ObjectB is the child of ObjectA and so on)
I would like to create a NSFetchRequest with NSSortDescriptors which return the objects in the correct order (from root to last child):
ObjectA
ObjectB
ObjectC
ObjectD
ObjectE
Is this possible?
(My specific problem is somewhat more complex, but I think I can get it done if I got this simple one solved)
Why bother, just fetch the parent object and then get it's child and the child's child from the property (relationship) directly. If you need them in an array then use a while loop to traverse the hierarchy until child = nil.
I understand, that question is out of date, but came up with idea for those, who will stumble upon later
You can use one fetch request with predicate staiting that parent must be nil. After that you don't need no more fetch requests. You just get child from this one (or more, if that possible), object. Then, you get child from this new object (child of original object). And go on, while you have child to get

How to get the item parent in a flex tree when using nested objects as data provider?

I have a Flex tree with an ArrayCollection as data provider. The collection holds an array of CategoryVO objects. Each object can have another array of CategoryVO objects inside it's "child" attribute. This way the tree displays the data correctly.
Now I want to get the parent of a specific item, e.g. tree.selectedItem. Using XML as data provider the item parent is available through the parent() method. But I can't convert my data to XML. How can I get an item's parent? Perhaps using the tree's dataDescriptor?
I just found out how to solve my problem :) The tree offers a getParentItem(item:Object) method that returns the parent item of the item. Notice that this function returns null for top level items.
The DataDescriptor does not contain parent information.
The easiest solution I believe would be simply adding a reference to the parent in each CategoryVO object.

Resources