use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class GitHub1304Test method givenBatchInserterWhenArrayPropertyUpdated4TimesThenShouldNotFail.
@Test
public void givenBatchInserterWhenArrayPropertyUpdated4TimesThenShouldNotFail() throws Exception {
BatchInserter batchInserter = BatchInserters.inserter(folder.getRoot().getAbsoluteFile(), fileSystemRule.get());
long nodeId = batchInserter.createNode(Collections.<String, Object>emptyMap());
for (int i = 0; i < 4; i++) {
batchInserter.setNodeProperty(nodeId, "array", new byte[] { 2, 3, 98, 1, 43, 50, 3, 33, 51, 55, 116, 16, 23, 56, 9, -10, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
}
//fails here
batchInserter.getNodeProperties(nodeId);
batchInserter.shutdown();
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method createBatchNodeAndRelationshipsDeleteAllInEmbedded.
@Test
public void createBatchNodeAndRelationshipsDeleteAllInEmbedded() throws Exception {
/*
* ()--[REL_TYPE1]-->(node)--[BATCH_TEST]->()
*/
BatchInserter inserter = newBatchInserter();
long nodeId = inserter.createNode(null);
inserter.createRelationship(nodeId, inserter.createNode(null), RelTypes.BATCH_TEST, null);
inserter.createRelationship(inserter.createNode(null), nodeId, RelTypes.REL_TYPE1, null);
// Delete node and all its relationships
GraphDatabaseService db = switchToEmbeddedGraphDatabaseService(inserter);
try (Transaction tx = db.beginTx()) {
Node node = db.getNodeById(nodeId);
for (Relationship relationship : node.getRelationships()) {
relationship.delete();
}
node.delete();
tx.success();
}
db.shutdown();
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method shouldBeAbleToOverwriteDynamicProperty.
@Test
public void shouldBeAbleToOverwriteDynamicProperty() throws Exception {
// Only triggered if assertions are enabled
// GIVEN
BatchInserter batchInserter = globalInserter;
String key = "tags";
long nodeId = batchInserter.createNode(MapUtil.map(key, new String[] { "one", "two", "three" }));
// WHEN
String[] secondValue = new String[] { "four", "five", "six" };
batchInserter.setNodeProperty(nodeId, key, secondValue);
// THEN
assertTrue(Arrays.equals(secondValue, (String[]) batchInserter.getNodeProperties(nodeId).get(key)));
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method testSetAndKeepRelationshipProperty.
@Test
public void testSetAndKeepRelationshipProperty() throws Exception {
BatchInserter inserter = newBatchInserter();
long from = inserter.createNode(Collections.<String, Object>emptyMap());
long to = inserter.createNode(Collections.<String, Object>emptyMap());
long theRel = inserter.createRelationship(from, to, RelationshipType.withName("TestingPropsHere"), MapUtil.map("foo", "bar"));
inserter.setRelationshipProperty(theRel, "foo2", "bar2");
Map<String, Object> props = inserter.getRelationshipProperties(theRel);
assertEquals(2, props.size());
assertEquals("bar", props.get("foo"));
assertEquals("bar2", props.get("foo2"));
inserter.shutdown();
inserter = newBatchInserter();
props = inserter.getRelationshipProperties(theRel);
assertEquals(2, props.size());
assertEquals("bar", props.get("foo"));
assertEquals("bar2", props.get("foo2"));
inserter.setRelationshipProperty(theRel, "foo", "bar3");
props = inserter.getRelationshipProperties(theRel);
assertEquals("bar3", props.get("foo"));
assertEquals(2, props.size());
assertEquals("bar3", props.get("foo"));
assertEquals("bar2", props.get("foo2"));
inserter.shutdown();
inserter = newBatchInserter();
props = inserter.getRelationshipProperties(theRel);
assertEquals("bar3", props.get("foo"));
assertEquals(2, props.size());
assertEquals("bar3", props.get("foo"));
assertEquals("bar2", props.get("foo2"));
inserter.shutdown();
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method testNodeHasProperty.
@Test
public void testNodeHasProperty() throws Exception {
BatchInserter inserter = globalInserter;
long theNode = inserter.createNode(properties);
long anotherNode = inserter.createNode(Collections.<String, Object>emptyMap());
long relationship = inserter.createRelationship(theNode, anotherNode, RelationshipType.withName("foo"), properties);
for (String key : properties.keySet()) {
assertTrue(inserter.nodeHasProperty(theNode, key));
assertFalse(inserter.nodeHasProperty(theNode, key + "-"));
assertTrue(inserter.relationshipHasProperty(relationship, key));
assertFalse(inserter.relationshipHasProperty(relationship, key + "-"));
}
}
Aggregations