2
votes

Present i am using janusgraph-0.2.0-hadoop2 server and using [email protected] library for querying

const Gremlin = require("gremlin");
const client = Gremlin.createClient(8182, "192.168.0.103");

function test(p){
   client.execute(q, {}, (err, results) => {
    if (err) {
      console.error(err);
      client.closeConnection();
    }
    else {
    console.log(results);
    client.closeConnection();
   }
});
}

for query g.V().count() result is [ 12 ]

for query g.V().has('name', 'saturn').valueMap() result is [ { name: [ 'saturn' ], age: [ 10000 ] } ]

I am ok with that

But after update my janusgraph to janusgraph-0.5.0-hadoop2 server and using same library [email protected]

Getting data in different

for query g.V().count() result is [ { '@type': 'g:Int64', '@value': 12 } ]

for query g.V().has('name', 'saturn').valueMap() result is

[ { '@type': 'g:Map', '@value': [ 'name', [Object], 'age', [Object] ] } ] Updating library to [email protected]

const gremlin = require('gremlin');
const client = new gremlin.driver.Client('ws://192.168.0.106:8182/gremlin', { traversalSource: 'g' });

async function test(q){
  const res = await client.submit(q, {});
  console.log('res',res)
  client.close();
}

test()

for query g.V().count() result is [ 12 ]

for query g.V().has('name', 'saturn').valueMap() result is [ Map { 'name' => [ 'saturn' ], 'age' => [ 10000 ] } ]

Getting data in Hashmap I want to know

 1. Is it necessary to update gremlin library 3.4.6 getting correct result.
 2. After updating to 3.4.6 get data in hashmap format, Means i want to know i am getting correct data or not.
 3. I want data in object format but got in hashmap. I know i can convert to object but incase data is in nested hashmap, I dont want to repeat and convert it.

Please give me suggestions

1

1 Answers

4
votes

I would say it is a very good idea to be on the current version of Janus Graph. Note that you should use the Gremlin libraries that come with Janus graph and not update those independently. The most recent Javascript/Node Gremlin clients do return Map types as you are seeing.