Baffled by all this Node stuff & # 8594; Titanium

I'm new to Java, Gremlin, Nodejs, Tickerpop, Maven and pretty much everything else. What does this code do? Specifically, what does "java.import" do? Is this a Java class? What does this have to do with Titan?

var Titan = require('titan-node');
var gremlin = new Titan.Gremlin({ loglevel: 'OFF' });

var TinkerGraphFactory = gremlin.java.import('com.tinkerpop.blueprints.impls.tg.TinkerGraphFactory');
var graph = TinkerGraphFactory.createTinkerGraphSync();
var g = gremlin.wrap(graph);

g.V('name', 'marko').next(function (err, v) {
    v.getProperty('name', function (err, value) {
        console.log(value);
    });
});

      

Why, when I use Rexster, I can't see the requested database here?

+3


source to share


2 answers


To add a valid @ mscdex answer.

This is Gremlin's JavaScript chained code in Node.js using direct Java bindings via node-java.

Gremlin is not a language, but a DSL. It is most of the time written in Groovy (due to its shorthand syntax over Java), but it also exists in any JVM-compatible languages ​​(e.g. Java, Groovy, Scala, JavaScript via rhino and now nashorn with Java 8 to name several). The complete Groovy / Java API is available with the Gremlin query / script suite, making it a "complete" language.



I recommend reading http://gremlindocs.com/ and http://sql2gremlin.com for interesting beginner resources on Gremlin. http://www.tinkerpop.com/docs/3.0.0.M1/ will give you details on TinkerPop and Gremlin (note: link will be torn as v3.0 is officially released).

Because of the way node-java works and provides Java methods (sync / async), you need to use callbacks here to avoid blocking the event loop. This is a JavaScript problem and has nothing to do with Gremlin, strictly speaking.

There are a few other clients that are not directly tied to the JVM, but use HTTP for TinkerPop 2.x ( https://github.com/gulthor/grex for Node.js) or WebSocket for TinkerPop 3.0+ ( https: // github. com / gulthor / gremlin-client , for Node.JS / browsers that will become the official TP3 JavaScript language Driver). Note: here is the author of the article TinkerPop / lib.

+6


source


gremlin

(dependency titan-node

) uses node-java

which is the bridge between node and Java. node-java

allows you to import Java classes, instantiate Java data, etc.



So you see an node-java

import of a specific Java class because Gremlin is Java / JVM.

+1


source







All Articles