danielcraig23
danielcraig23
ATApache TinkerPop
Created by danielcraig23 on 5/9/2024 in #questions
Is the insertion order guaranteed with this example code?
Ok thank you!!
13 replies
ATApache TinkerPop
Created by danielcraig23 on 5/9/2024 in #questions
Is the insertion order guaranteed with this example code?
for 3.6.2 is this also the case?
13 replies
ATApache TinkerPop
Created by danielcraig23 on 5/9/2024 in #questions
Is the insertion order guaranteed with this example code?
@Valentyn Kahamlyk does gtx....iterate() have a strategy for maintaining the order of these writes?
13 replies
ATApache TinkerPop
Created by danielcraig23 on 5/9/2024 in #questions
Using mergeE to create an edge with an id that depends on a lookup
Thank you @spmallette !
8 replies
ATApache TinkerPop
Created by danielcraig23 on 5/9/2024 in #questions
Is the insertion order guaranteed with this example code?
Is this an acceptable way of making sequential writes? I am using async.retry to retry the promise returned by tx.commit(), similar to this example from Amazon: https://docs.aws.amazon.com/neptune/latest/userguide/lambda-functions-examples.html#lambda-functions-examples-javascript ``` const tx = g.tx(); try { // get the graph traversal source from the transaction const gtx = tx.begin();
gtx.addV("owner").property(id, "1111").iterate() gtx.addV("laptop").property(id, "macbookAir2024").property("yearReleased", 2024).iterate() gtx.V() .hasLabel('laptop') .has(t.id, textP.startingWith(partialMacbookId)) .order() .by('yearReleased', desc) .limit(1) .as("mostRecentMacbook") .mergeE( new Map([ [t.label, 'hasOwner'], [direction.out, merge.outV], [direction.in, merge.inV]] ) ) .option(merge.outV, .select('mostRecentMacbook')) .option(merge.inV, .V(ownerId)) .iterate(); return tx.commit(); } catch (error) { logger.error(error); // roll back the transaction return tx.rollback(); }
13 replies
ATApache TinkerPop
Created by danielcraig23 on 4/18/2024 in #questions
.mergeV() with Javascript not working
The solution was to allow neptune to use the default mimetype; removing the mimetype header solved the issue
28 replies
ATApache TinkerPop
Created by danielcraig23 on 5/9/2024 in #questions
Is the insertion order guaranteed with this example code?
Yes that's certainly true, for reasons of breaking up a series of several long .mergeV() and .mergeE()'s I want to use a transaction so that there's space in between.
13 replies
ATApache TinkerPop
Created by danielcraig23 on 5/9/2024 in #questions
Using mergeE to create an edge with an id that depends on a lookup
I'm using Tinkerpop 3.6.2, where .concat() and .format() weren't yet added, and I'm using Neptune where lambdas aren't supported
8 replies
ATApache TinkerPop
Created by danielcraig23 on 5/9/2024 in #questions
Using mergeE to create an edge with an id that depends on a lookup
gremlin> g.addV("owner").property(id, "1111")
gremlin> g.addV("laptop").property(id, "macbookAir2024").property("yearReleased", 2024)
gremlin> g.V().hasLabel('laptop').has(T.id, TextP.startingWith("macbookAir")).order().by('yearReleased', desc).limit(1).as("mostRecentMacbook").mergeE([(T.label): 'hasOwner', (from): Merge.outV, (to): Merge.inV]).option(Merge.outV, __.select('mostRecentMacbook')).option(Merge.inV, __.V('1111')).iterate();
gremlin> g.addV("owner").property(id, "1111")
gremlin> g.addV("laptop").property(id, "macbookAir2024").property("yearReleased", 2024)
gremlin> g.V().hasLabel('laptop').has(T.id, TextP.startingWith("macbookAir")).order().by('yearReleased', desc).limit(1).as("mostRecentMacbook").mergeE([(T.label): 'hasOwner', (from): Merge.outV, (to): Merge.inV]).option(Merge.outV, __.select('mostRecentMacbook')).option(Merge.inV, __.V('1111')).iterate();
8 replies
ATApache TinkerPop
Created by danielcraig23 on 5/9/2024 in #questions
Using mergeE to create an edge with an id that depends on a lookup
Here is the script that I'm testing in gremlin console:
8 replies
ATApache TinkerPop
Created by danielcraig23 on 5/8/2024 in #questions
Is tx.close() necessary in Javascript?
Thanks Valentyn
6 replies
ATApache TinkerPop
Created by danielcraig23 on 5/8/2024 in #questions
Is tx.close() necessary in Javascript?
try {
const gtx = tx.begin();

gtx.mergeV(
new Map([
[t.id, 'exampleId'],
[t.label, 'exampleLabel']
]))
.option(merge.onCreate, new Map([['lastUpdatedTime', eventTimeStamp]]))
.iterate();

tx.commit();
} catch (error) {
logger.error(error);
// roll back the transaction
tx.rollback();
}
try {
const gtx = tx.begin();

gtx.mergeV(
new Map([
[t.id, 'exampleId'],
[t.label, 'exampleLabel']
]))
.option(merge.onCreate, new Map([['lastUpdatedTime', eventTimeStamp]]))
.iterate();

tx.commit();
} catch (error) {
logger.error(error);
// roll back the transaction
tx.rollback();
}
6 replies
ATApache TinkerPop
Created by danielcraig23 on 4/18/2024 in #questions
.mergeV() with Javascript not working
Thank you!
28 replies
ATApache TinkerPop
Created by danielcraig23 on 4/18/2024 in #questions
.mergeV() with Javascript not working
I provided some more details in an amazon case which I just created, can I send you that case #?
28 replies
ATApache TinkerPop
Created by danielcraig23 on 4/18/2024 in #questions
.mergeV() with Javascript not working
ooh nice that's what I want to see
28 replies
ATApache TinkerPop
Created by danielcraig23 on 4/18/2024 in #questions
.mergeV() with Javascript not working
so the problem remains
28 replies
ATApache TinkerPop
Created by danielcraig23 on 4/18/2024 in #questions
.mergeV() with Javascript not working
So it seems that the map was populated after all, and my logging was just representing it as {}.
28 replies
ATApache TinkerPop
Created by danielcraig23 on 4/18/2024 in #questions
.mergeV() with Javascript not working
Now I've updated my function to
async function query() {
const vertexMatcher = new Map([
['label', 'person'],
['name', 'marko'],
['age', 31],
]);
logger.info('vertexMatcher', { vertexMatcher });
console.log(vertexMatcher);
console.log(vertexMatcher.get('label'));
return g.mergeV(vertexMatcher).next();
}
async function query() {
const vertexMatcher = new Map([
['label', 'person'],
['name', 'marko'],
['age', 31],
]);
logger.info('vertexMatcher', { vertexMatcher });
console.log(vertexMatcher);
console.log(vertexMatcher.get('label'));
return g.mergeV(vertexMatcher).next();
}
and the logs show
{"level":"info","message":"Initializing connection to neptunedbcluster-XXXXX.cluster-csd4wx9xfzaj.us-east-1.neptune.amazonaws.com, port ZZZZ"}
2024-04-19T15:44:33.052Z 60819b7d-5dfc-40db-a3aa-4f1ebdc7cc9b INFO Map(3) { 'label' => 'person', 'name' => 'marko', 'age' => 31 }
{"level":"info","message":"vertexMatcher","vertexMatcher":{}}
2024-04-19T15:44:33.054Z 60819b7d-5dfc-40db-a3aa-4f1ebdc7cc9b INFO person
{"level":"info","message":"Result","result":{"done":false,"value":{"id":"9ac77b77-8872-5bc3-9388-659dbe6791d5","label":"vertex"}}}
{"level":"info","message":"Initializing connection to neptunedbcluster-XXXXX.cluster-csd4wx9xfzaj.us-east-1.neptune.amazonaws.com, port ZZZZ"}
2024-04-19T15:44:33.052Z 60819b7d-5dfc-40db-a3aa-4f1ebdc7cc9b INFO Map(3) { 'label' => 'person', 'name' => 'marko', 'age' => 31 }
{"level":"info","message":"vertexMatcher","vertexMatcher":{}}
2024-04-19T15:44:33.054Z 60819b7d-5dfc-40db-a3aa-4f1ebdc7cc9b INFO person
{"level":"info","message":"Result","result":{"done":false,"value":{"id":"9ac77b77-8872-5bc3-9388-659dbe6791d5","label":"vertex"}}}
28 replies
ATApache TinkerPop
Created by danielcraig23 on 4/18/2024 in #questions
.mergeV() with Javascript not working
I'm not sure what /* @__PURE__ */ means
28 replies
ATApache TinkerPop
Created by danielcraig23 on 4/18/2024 in #questions
.mergeV() with Javascript not working
As deployed in Lambda the code appears like this:
async function query() {
const vertexMatcher = /* @__PURE__ */ new Map([[label, "person"], ["name", "marko"], ["age", 31]]);
import_logging3.logger.info("vertexMatcher", { vertexMatcher });
return g.mergeV(vertexMatcher).next();
}
async function query() {
const vertexMatcher = /* @__PURE__ */ new Map([[label, "person"], ["name", "marko"], ["age", 31]]);
import_logging3.logger.info("vertexMatcher", { vertexMatcher });
return g.mergeV(vertexMatcher).next();
}
28 replies