I want to put a restriction in titan graph while adding a new vertex with out unique property key.
Eg: In my titan graph "aid" is unique property key and if I try to add any vertex thru gremlin or rexster without using "aid" it should stop.
Steps I followed:
mgmt = g.getManagementSystem()
aid = mgmt.makePropertyKey('aid').dataType(String.class).make()
mgmt.buildIndex('byAid',Vertex.class).addKey(aid).unique().buildCompositeIndex()
mgmt.commit()
gremlin>g.addVertex([aid:'aid91']);
==>v[229640]
*gremlin>g.addVertex([name:'srinivas']);
==>v[246024]*
I want to restrict the second step if "aid" is not provided.
Can you guys help me to know the solution for this?
Thanking you in advance..
You would have to do that kind of data validation at the application-level. Neither Titan, nor the TinkerPop stack, provide a way to ensure that a field is present when a new vertex is added.
The syntax you are using seems to indicate that you are using Titan 0.5.x (or perhaps earlier). If so, one solution might be to create a "wrapper graph" to centralize the validation. The wrapper pattern can be seen in TinkerPop in features like: ReadOnlyGraph, IdGraph, etc. Basically, you create a ValidationGraph class and pass your TitanGraph instance in on the constructor, then override addVertex to intercept the calls. You can then implement whatever validation you'd like.
In Titan 0.9.x/TinkerPop3, the pattern is a bit different. The current model calls for building a TraversalStrategy to implement the validation. Unfortunately, this pattern is still a bit unproven. I'm sure it will develop further after TP3 GA is released.
Related
Regarding Firebase document Ids, I am trying to set a prefix before the default Firebase docId generation. For example, if the default document Id generated is 23492drf94fl, then I would write it as, somePrefix:23492drf94fl.
Currently, I understand that there are two ways to do this: one with generating your own custom UUID on the client side with custom prefix, and another is to rewrite the document Id after initially writing it in Firestore.
Is there any shorthand method or function I could use in React (Node.js) to just use the default Firestore docId generation w/ a specified prefix?
Thanks in advance.
There isn't a shorter/easier method or function that would allow you to set a prefix to the auto-generated id. You will need to do it manually as you mentioned it and even doing this manually, it's not a very good option, as you will be impacting more of your application and, of course, spending part of your quotas on each read and write every time a new doc is created.
However, if you really would like or need, to have the document id with a prefix, I would recommend you to use a second field, where you would copy the value of the document id and then, add the prefix. This way, you won't affect the default field created - which can impact the uniform distribution of it, since it's automatically created - and you would still be able to have a MATH:235E23 or SCI:2309F4 your database, that you can use as a default field for you.
Besides that, in case you feel this could be a good improvement to the system, please, consider raising a Feature Request in Google's Issue Tracker, so they can check about the possibility of implementing it in the future.
Let me know if the information helped you!
Why RexsterGraph in the blueprint stack is not meant for high-performing graph traversals:
https://github.com/tinkerpop/blueprints/wiki/Rexster-Implementation
What are the limitations?
And should I then fallback on executing gremlin throw a simple string evaluated?
RexsterGraph uses the Rexster REST API which is a RESTful representation of the Blueprints API. As such, each Blueprints method called in RexsterGraph translates to an HTTP call.
Here's an example of why that's bad for "high performance traversals". Using the toy graph, for an example. Let's say I want to do something simple with RexsterGraph like: g.v(1).out.filter{it.name=='josh'}.name. That will translate to the following HTTP calls:
vertices/1 - gets data for v(1)
vertices/1/outE - gets the out edges for v(1)
vertices/2 - knowing the out edges tells us the other vertex to retrieve
vertices/3 - knowing the out edges tells us the other vertex to retrieve
vertices/4 - knowing the out edges tells us the other vertex to retrieve
vertices/2 - now we are filtering so we need the name property
vertices/3 - now we are filtering so we need the name property
vertices/4 - now we are filtering so we need the name property
vertices/4 - now we are down to "josh" so get the name property
As you can see, it's not efficient. It is a one-to-one mapping of the Blueprints API to the Rexster REST API. That's it. Could it be made to be more efficient? Probably...we might consider caching property values or something, but it will still be really chatty for a "high performance traversal". Other problems with trying to make it more efficient are dealing with mechanisms for serializing closures so that can be executed on the server.
In the end, it was simply decided a long time ago that this was not a good approach and we started to recommend against using RexsterGraph in favor of server-side DSLs and RexPro/REST Gremlin Extension.
Right now SynonymFilterFactory only allows to use one dictionary. I am wondering in indexing time if there is a way to use different dictionary depending on some metadata of a document (for example a category of a document). I feel like this should be doable if I override something in the indexer side? One way is to create a separate index/core based on the metadata but I hope to avoid it.
There doesn't seem to be a way to do what I want at this point other than creating a separate core.
I'm having a lot of troubles with RIA Services. I'm really wondering if it's worth the hassle at all. The problem I have now is similar to other problems: related entities. Let's say I have a class, Foo. Foo has two related entities, Bar and Fighter.
If I'm working on a new Foo, foo, and I want to add something to the Bars collection, it works just fine. Like:
foo.Bars.Add(new Bar{A=a, B=b});
But when I try to add a Fighter, it doesn't work:
foo.Fighters.Add(new Fighter{C=c,D=d});
I've been all around the interwebz looking for the solution. I've found the suggestions to use the [Include] attribute and the [Associated] attribute as well. Both have worked in some cases. But they're not working in this case and I have zero clue why. I've deleted and re-created my EDMX and my DomainService because someone suggested it, but it isn't working.
So what is wrong and what other information do you need to help me out? When I say try to add a Fighter to my foo.Fighters collection, it's not persisting the add. I will note that I'm trying to add an existing Fighter in my specific example, not a new Fighter, if that helps/gives clues.
If you need information or real code samples, I'll be happy to oblige. Thanks in advance to all that try to help.
A number of things to check and confirm
The Fighter table has a foreign key defined in the database.
Use [Association], [Include], and [Composition] attributes. Association defines the relationship. Include instructs the server to send the instance or contents of the collection to the client, if populated. Composition instructs WCF RIA to track changes to the collection and send them back to the server.
Ensure you are calling context.SubmitChanges() after all the adds in Silverlight.
Ensure you have an insert method on your DomainService.
Maybe one or more of these will help.
I have a code library that makes heavy use of XPathNavigator to parse some specific xml document. The xml document is cross-referenced, meaning that an element can reference another which has not yet been encountered during parsing:
<ElementA ...>
<DependentElementX id="1234">
</ElementA>
<ElementX id="1234" .../>
The document doesn't really look like this, but the point is that 1) there is an xml schema that enforces the overall document structure, 2) elements inside the document can reference each other using some IDs, and 3) there is quite a few such cross references between different elements in the document.
The document is parsed in two phases. In the first pass I walk through the document
XPathDocument doc = ...;
XPathNavigator nav = doc.CreateNavigator();
nav.MoveToRoot();
nav.MoveToFirstChild()...
and occasionally 'bookmark' the current position (element) in the document using XPathNavigator.Clone() method. This gives me a lightweight instance of an XPathNavigator which I can store somewhere and use later to jump back to a particular place (element) in my document.
Once I have enough information collected in the first pass (for example, I have made sure there is indeed an ElementX with an id='1234'), I jump back to saved bookmarks (using those saved XPathNavigators) and complete the parsing.
Well, now I'm about to use this library in Silverlight 3.0 and to my horror the XPathNavigator is not in the System.Xml assembly.
Questions:
1) Am I missing something obvious (i.e. XPathNavigator does exist in some shape or form, for example in a toolkit or a freeware library)?
2) If I do have to make modifications in the code, what would be the best way to go? Ideally, I would like to make minimal changes, not to rewrite 80% of the code just to be able to use something like XLinq.
To resume, in case I have to give up XPathNavigator, all I need is a way to bookmark places in my document and to get back to them so that I can continue to iterate from where I left off.
Thanks in advance for any help/ideas.
You are not missing something obvious, there is no implementation of XPathNavigator or XPathDocument in the Silverlight versions of the libraries.
The "best way to go" is highly subjective and would really depend on how many lines of code are really depending on XPathNavigator. However I see a couple of choices.
Go ahead and re-write the code using XDocument, XElement etc from the System.Xml.Linq namepsace. This may not be as bad a choice as you might think.
Wrap Xml-to-Linq objects in your own implementation of those properties and methods of the XPathNavigator that you are actually using. It shouldn't be too hard re-create most the features of the XPathNavigator against the Xml-to-Linq objects. You can then run your existing code against your own XPathNavigator.
XPath (xdoc.XPathSelectElements) is available in Silverlight 4: here's an online test tool.
There are tons of ways:
How to deal with XML in C#
You can still use Linq to XML just minus the linq syntax and use the Linq Extension methods.