public static Function<Node,Node> addLabel( Label label ) { return node -> { node.addLabel( label ); return node; }; }
@Override public void accept( Transaction transaction ) { node.addLabel( label ); } };
public NodeRepresentation createNode( Map<String,Object> properties, Label... labels ) throws PropertyValueException { Node node = graphDb.createNode(); propertySetter.setProperties( node, properties ); if ( labels != null ) { for ( Label label : labels ) { node.addLabel( label ); } } return new NodeRepresentation( node ); }
private void addLabels( Node node, Label... labels ) { try ( Transaction tx = dbRule.beginTx() ) { for ( Label label : labels ) { node.addLabel( label ); } tx.success(); } }
private void addLabelToUnLabeledNode( Node unLabeledNode ) { try ( Transaction tx = db.beginTx() ) { unLabeledNode.addLabel( LABEL ); tx.success(); } }
private void addLabel( Node node, Label label ) { try ( Transaction tx = db.beginTx() ) { node.addLabel( label ); tx.success(); } }
private void addLabelToExistingNode( List<Pair<Long,Label[]>> nodesInStore ) { int targetIndex = random.nextInt( nodesInStore.size() ); Pair<Long,Label[]> existingNode = nodesInStore.get( targetIndex ); Node node = db.getNodeById( existingNode.first() ); node.addLabel( EXTRA_LABEL ); }
public void add( Node node, String label ) { node.addLabel( label( label ) ); put( added, node, label ); }
private void modifyLabelsOnExistingNode( List<Pair<Long,Label[]>> existingNodes ) { int targetIndex = random.nextInt( existingNodes.size() ); Pair<Long,Label[]> existingPair = existingNodes.get( targetIndex ); long nodeId = existingPair.first(); Node node = db.getNodeById( nodeId ); node.getLabels().forEach( node::removeLabel ); Label[] newLabels = randomLabels(); for ( Label label : newLabels ) { node.addLabel( label ); } existingNodes.remove( targetIndex ); existingNodes.add( Pair.of( nodeId, newLabels ) ); }
private void modifyLabelsOnExistingNode( List<Pair<Long,Label[]>> existingNodes ) { int targetIndex = random.nextInt( existingNodes.size() ); Pair<Long,Label[]> existingPair = existingNodes.get( targetIndex ); long nodeId = existingPair.first(); Node node = db.getNodeById( nodeId ); node.getLabels().forEach( node::removeLabel ); Label[] newLabels = randomLabels(); for ( Label label : newLabels ) { node.addLabel( label ); } existingNodes.remove( targetIndex ); existingNodes.add( Pair.of( nodeId, newLabels ) ); }
@Test public void testSingleNodeLabels() { Node n = gdb.createNode(); n.addLabel( Label.label( "Foo" ) ); n.addLabel( Label.label( "Bar" ) ); final ExecutionResult result = result( "node", n ); final SubGraph graph = CypherResultSubGraph.from( result, gdb, false ); assertEquals( "create (_" + n.getId() + ":`Foo`:`Bar`)" + lineSeparator() + ";" + lineSeparator(), doExportGraph( graph ) ); }
private void addLabels( long nodeId, int startLabelIndex, int count ) { try ( Transaction tx = dbRule.beginTx() ) { Node node = dbRule.getNodeById( nodeId ); int endLabelIndex = startLabelIndex + count; for ( int i = startLabelIndex; i < endLabelIndex; i++ ) { node.addLabel( labelWithIndex( i ) ); } tx.success(); } }
@Test public void addConcurrentlySameLabelToANode() throws Throwable { final long nodeId = initWithNode( db ); Thread t1 = newThreadForNodeAction( nodeId, node -> node.addLabel( Label.label( "A" ) ) ); Thread t2 = newThreadForNodeAction( nodeId, node -> node.addLabel( Label.label( "A" ) ) ); startAndWait( t1, t2 ); db.shutdown(); assertDatabaseConsistent(); }
@Test public void shouldNotWarnOnSmallLabelScansWithLoadCVS() { try ( Transaction tx = db().beginTx() ) { db().createNode().addLabel( label( "A" ) ); tx.success(); } Stream.of( "CYPHER 3.1", "CYPHER 3.5" ).forEach( version -> { shouldNotNotifyInStream( version, "EXPLAIN LOAD CSV FROM 'file:///ignore/ignore.csv' AS line MATCH (a:A) RETURN *" ); shouldNotNotifyInStream( version, "EXPLAIN LOAD CSV FROM 'file:///ignore/ignore.csv' AS line MERGE (a:A) RETURN *" ); } ); }
@Test public void shouldWarnOnLargeLabelScansWithLoadCVSMatch() { for ( int i = 0; i < 11; i++ ) { try ( Transaction tx = db().beginTx() ) { db().createNode().addLabel( label( "A" ) ); tx.success(); } } Stream.of( "CYPHER 3.1", "CYPHER 3.5" ).forEach( version -> assertNotifications( version + "EXPLAIN LOAD CSV FROM 'file:///ignore/ignore.csv' AS line MATCH (a:A) RETURN *", containsNoItem( largeLabelCSVWarning ) ) ); }
@Test public void shouldWarnOnLargeLabelScansWithLoadCVSMerge() { for ( int i = 0; i < 11; i++ ) { try ( Transaction tx = db().beginTx() ) { db().createNode().addLabel( label( "A" ) ); tx.success(); } } Stream.of( "CYPHER 3.1", "CYPHER 3.5" ).forEach( version -> assertNotifications( version + "EXPLAIN LOAD CSV FROM 'file:///ignore/ignore.csv' AS line MERGE (a:A) RETURN *", containsNoItem( largeLabelCSVWarning ) ) ); }
@Test public void shouldWarnOnMisspelledLabel() { try ( Transaction tx = db().beginTx() ) { db().createNode().addLabel( label( "Person" ) ); tx.success(); } Stream.of( "CYPHER 2.3", "CYPHER 3.1", "CYPHER 3.5" ).forEach( version -> { assertNotifications(version + "EXPLAIN MATCH (n:Preson) RETURN *", containsItem( unknownLabelWarning ) ); shouldNotNotifyInStream( version, "EXPLAIN MATCH (n:Person) RETURN *" ); }); }
public void addLabelToNode( long node, String labelName ) { try ( Transaction tx = database.getGraph().beginTransaction( implicit, AnonymousContext.writeToken() ) ) { database.getGraph().getNodeById( node ).addLabel( label( labelName ) ); tx.success(); } }
@Test public void shouldNotNotifyOnDynamicPropertyLookupWithLabelHavingNoIndex() { Stream.of( "CYPHER 2.3", "CYPHER 3.1", "CYPHER 3.5" ).forEach( version -> { db().execute( "CREATE INDEX ON :Person(name)" ); db().execute( "Call db.awaitIndexes()" ); try ( Transaction tx = db().beginTx() ) { db().createNode().addLabel( label( "Foo" ) ); tx.success(); } shouldNotNotifyInStream( version, "EXPLAIN MATCH (n:Foo) WHERE n['key-' + n.name] = 'value' RETURN n" ); } ); }
@Test public void shouldWarnOnMisspelledRelationship() { try ( Transaction tx = db().beginTx() ) { db().createNode().addLabel( label( "Person" ) ); tx.success(); } Stream.of( "CYPHER 2.3", "CYPHER 3.1", "CYPHER 3.5" ).forEach( version -> { db().execute( "CREATE (n)-[r:R]->(m)"); assertNotifications(version + "EXPLAIN MATCH ()-[r:r]->() RETURN *", containsItem( unknownRelationshipWarning ) ); shouldNotNotifyInStream( version, "EXPLAIN MATCH ()-[r:R]->() RETURN *" ); }); }