Skip to content

Commit

Permalink
Remove deprecated GlobalGraphOperations
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegrohmann committed Mar 16, 2016
1 parent 12e4f63 commit 737a1fb
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 543 deletions.
Expand Up @@ -176,21 +176,17 @@ public interface GraphDatabaseService
/** /**
* Returns all relationship types currently in the underlying store. * Returns all relationship types currently in the underlying store.
* Relationship types are added to the underlying store the first time they * Relationship types are added to the underlying store the first time they
* are used in a successfully commited {@link Node#createRelationshipTo * are used in a successfully committed {@link Node#createRelationshipTo
* node.createRelationshipTo(...)}. Note that this method is guaranteed to * node.createRelationshipTo(...)}. This method guarantees that it will
* return all known relationship types, but it does not guarantee that it * return all relationship types currently in use.
* won't return <i>more</i> than that (e.g. it can return "historic"
* relationship types that no longer have any relationships in the node
* space).
* *
* @return all relationship types in the underlying store * @return all relationship types in the underlying store
*/ */
ResourceIterable<RelationshipType> getAllRelationshipTypes(); ResourceIterable<RelationshipType> getAllRelationshipTypes();


/** /**
* Returns all labels currently in the underlying store. Labels are added to the store the first time * Returns all labels currently in the underlying store. Labels are added to the store the first time
* they are used. This method guarantees that it will return all labels currently in use. However, * they are used. This method guarantees that it will return all labels currently in use.
* it may also return <i>more</i> than that (e.g. it can return "historic" labels that are no longer used).
* *
* Please take care that the returned {@link ResourceIterable} is closed correctly and as soon as possible * Please take care that the returned {@link ResourceIterable} is closed correctly and as soon as possible
* inside your transaction to avoid potential blocking of write operations. * inside your transaction to avoid potential blocking of write operations.
Expand Down
Expand Up @@ -86,7 +86,6 @@
import static org.neo4j.helpers.collection.Iterators.count; import static org.neo4j.helpers.collection.Iterators.count;
import static org.neo4j.helpers.collection.MapUtil.store; import static org.neo4j.helpers.collection.MapUtil.store;
import static org.neo4j.helpers.collection.MapUtil.stringMap; import static org.neo4j.helpers.collection.MapUtil.stringMap;
import static org.neo4j.tooling.GlobalGraphOperations.at;
import static org.neo4j.tooling.ImportTool.MULTI_FILE_DELIMITER; import static org.neo4j.tooling.ImportTool.MULTI_FILE_DELIMITER;


public class ImportToolTest public class ImportToolTest
Expand Down Expand Up @@ -193,7 +192,7 @@ public void import4097Labels() throws Exception
// THEN // THEN
try ( Transaction tx = dbRule.beginTx() ) try ( Transaction tx = dbRule.beginTx() )
{ {
long nodeCount = Iterables.count( at( dbRule ).getAllNodes() ); long nodeCount = Iterables.count( dbRule.getAllNodes() );
assertEquals( 4097, nodeCount ); assertEquals( 4097, nodeCount );


tx.success(); tx.success();
Expand Down Expand Up @@ -371,7 +370,7 @@ public void shouldIgnoreWhitespaceAroundBooleans() throws Exception
} }
} }


long nodeCount = Iterables.count( at( dbRule ).getAllNodes() ); long nodeCount = Iterables.count( dbRule.getAllNodes() );
assertEquals( 10, nodeCount ); assertEquals( 10, nodeCount );
tx.success(); tx.success();
} }
Expand Down Expand Up @@ -1271,7 +1270,7 @@ public void shouldAcceptRawAsciiCharacterCodeAsQuoteConfiguration() throws Excep
GraphDatabaseService db = dbRule.getGraphDatabaseAPI(); GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
try ( Transaction tx = db.beginTx() ) try ( Transaction tx = db.beginTx() )
{ {
for ( Node node : at( db ).getAllNodes() ) for ( Node node : db.getAllNodes() )
{ {
String name = (String) node.getProperty( "name" ); String name = (String) node.getProperty( "name" );
assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) ); assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) );
Expand Down Expand Up @@ -1370,7 +1369,7 @@ public void shouldAcceptRawEscapedAsciiCodeAsQuoteConfiguration() throws Excepti
GraphDatabaseService db = dbRule.getGraphDatabaseAPI(); GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
try ( Transaction tx = db.beginTx() ) try ( Transaction tx = db.beginTx() )
{ {
for ( Node node : at( db ).getAllNodes() ) for ( Node node : db.getAllNodes() )
{ {
String name = (String) node.getProperty( "name" ); String name = (String) node.getProperty( "name" );
assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) ); assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) );
Expand Down Expand Up @@ -1428,7 +1427,7 @@ public void shouldBeEquivalentToUseRawAsciiOrCharacterAsQuoteConfiguration1() th
GraphDatabaseService db = dbRule.getGraphDatabaseAPI(); GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
try ( Transaction tx = db.beginTx() ) try ( Transaction tx = db.beginTx() )
{ {
for ( Node node : at( db ).getAllNodes() ) for ( Node node : db.getAllNodes() )
{ {
String name = (String) node.getProperty( "name" ); String name = (String) node.getProperty( "name" );
assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) ); assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) );
Expand Down Expand Up @@ -1514,7 +1513,7 @@ public void shouldBeEquivalentToUseRawAsciiOrCharacterAsQuoteConfiguration2() th
GraphDatabaseService db = dbRule.getGraphDatabaseAPI(); GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
try ( Transaction tx = db.beginTx() ) try ( Transaction tx = db.beginTx() )
{ {
for ( Node node : at( db ).getAllNodes() ) for ( Node node : db.getAllNodes() )
{ {
String name = (String) node.getProperty( "name" ); String name = (String) node.getProperty( "name" );
assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) ); assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) );
Expand Down
Expand Up @@ -394,25 +394,49 @@ protected Relationship fetchNextOrNull()
@Override @Override
public ResourceIterable<RelationshipType> getAllRelationshipTypes() public ResourceIterable<RelationshipType> getAllRelationshipTypes()
{ {
return all( TokenAccess.RELATIONSHIP_TYPES ); return allInUse( TokenAccess.RELATIONSHIP_TYPES );
} }


@Override @Override
public ResourceIterable<Label> getAllLabels() public ResourceIterable<Label> getAllLabels()
{ {
return all( TokenAccess.LABELS ); return allInUse( TokenAccess.LABELS );
} }


@Override @Override
public ResourceIterable<String> getAllPropertyKeys() public ResourceIterable<String> getAllPropertyKeys()
{
return allInUse( TokenAccess.PROPERTY_KEYS );
}

private <T> ResourceIterable<T> allInUse( final TokenAccess<T> tokens )
{
assertTransactionOpen();
return () -> tokens.inUse( spi.currentStatement() );
}

@Override
public ResourceIterable<RelationshipType> getAllExistingRelationshipTypes()
{
return all( TokenAccess.RELATIONSHIP_TYPES );
}

@Override
public ResourceIterable<Label> getAllExistingLabelsInUseAndNot()
{
return all( TokenAccess.LABELS );
}

@Override
public ResourceIterable<String> getAllExistingPropertyKeysInUseAndNot()
{ {
return all( TokenAccess.PROPERTY_KEYS ); return all( TokenAccess.PROPERTY_KEYS );
} }


private <T> ResourceIterable<T> all( final TokenAccess<T> tokens ) private <T> ResourceIterable<T> all( final TokenAccess<T> tokens )
{ {
assertTransactionOpen(); assertTransactionOpen();
return () -> tokens.inUse( spi.currentStatement() ); return () -> tokens.all( spi.currentStatement() );
} }


@Override @Override
Expand Down
Expand Up @@ -23,6 +23,10 @@


import org.neo4j.graphdb.DependencyResolver; import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.ResourceIterable;
import org.neo4j.graphdb.security.URLAccessValidationError; import org.neo4j.graphdb.security.URLAccessValidationError;
import org.neo4j.kernel.impl.store.StoreId; import org.neo4j.kernel.impl.store.StoreId;


Expand All @@ -49,4 +53,42 @@ public interface GraphDatabaseAPI extends GraphDatabaseService
URL validateURLAccess( URL url ) throws URLAccessValidationError; URL validateURLAccess( URL url ) throws URLAccessValidationError;


String getStoreDir(); String getStoreDir();

/**
* Returns all relationship types currently in the underlying store.
* Relationship types are added to the underlying store the first time they
* are used in a successfully committed {@link Node#createRelationshipTo
* node.createRelationshipTo(...)}. Note that this method is guaranteed to
* return all known relationship types, but it does not guarantee that it
* won't return <i>more</i> than that (e.g. it can return "historic"
* relationship types that no longer have any relationships in the node
* space).
*
* @return all relationship types in the underlying store
*/
ResourceIterable<RelationshipType> getAllExistingRelationshipTypes();

/**
* Returns all labels currently in the underlying store. Labels are added to the store the first time
* they are used. This method guarantees that it will return all labels currently in use. However,
* it may also return <i>more</i> than that (e.g. it can return "historic" labels that are no longer used).
*
* Please take care that the returned {@link ResourceIterable} is closed correctly and as soon as possible
* inside your transaction to avoid potential blocking of write operations.
*
* @return all labels in the underlying store.
*/
ResourceIterable<Label> getAllExistingLabelsInUseAndNot();

/**
* Returns all property keys currently in the underlying store. This method guarantees that it will return all
* property keys currently in use. However, it may also return <i>more</i> than that (e.g. it can return "historic"
* labels that are no longer used).
*
* Please take care that the returned {@link ResourceIterable} is closed correctly and as soon as possible
* inside your transaction to avoid potential blocking of write operations.
*
* @return all property keys in the underlying store.
*/
ResourceIterable<String> getAllExistingPropertyKeysInUseAndNot();
} }

This file was deleted.

0 comments on commit 737a1fb

Please sign in to comment.