Skip to content

Commit

Permalink
* Added wildcard back to streams
Browse files Browse the repository at this point in the history
* NodeSchemaMatcher is now a static helper class
* EPSILON cannot be final
  • Loading branch information
klaren committed Feb 22, 2018
1 parent bcaf64b commit 5a48bb8
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 36 deletions.
Expand Up @@ -132,7 +132,7 @@ public interface KernelTransactionHandle
/** /**
* @return the lock requests granted for this transaction. * @return the lock requests granted for this transaction.
*/ */
Stream<ActiveLock> activeLocks(); Stream<? extends ActiveLock> activeLocks();


/** /**
* Provide underlying transaction execution statistics. For example: elapsed time, allocated bytes etc * Provide underlying transaction execution statistics. For example: elapsed time, allocated bytes etc
Expand Down
Expand Up @@ -208,14 +208,12 @@ procedures, accessCapability, lockTracer, statementOperations, new ClockContext(
this.userMetaData = new HashMap<>(); this.userMetaData = new HashMap<>();
AllStoreHolder allStoreHolder = AllStoreHolder allStoreHolder =
new AllStoreHolder( storageEngine, storageStatement, this, cursors, explicitIndexStore ); new AllStoreHolder( storageEngine, storageStatement, this, cursors, explicitIndexStore );
org.neo4j.kernel.impl.newapi.NodeSchemaMatcher matcher =
new org.neo4j.kernel.impl.newapi.NodeSchemaMatcher( allStoreHolder );
this.operations = this.operations =
new Operations( new Operations(
allStoreHolder, allStoreHolder,
new IndexTxStateUpdater( storageEngine.storeReadLayer(), allStoreHolder, matcher ), new IndexTxStateUpdater( storageEngine.storeReadLayer(), allStoreHolder ),
storageStatement, storageStatement,
this, token, cursors, autoIndexing, matcher ); this, token, cursors, autoIndexing );
} }


/** /**
Expand Down Expand Up @@ -945,7 +943,7 @@ public void dispose()
* *
* @return the locks held by this transaction. * @return the locks held by this transaction.
*/ */
public Stream<ActiveLock> activeLocks() public Stream<? extends ActiveLock> activeLocks()
{ {
StatementLocks locks = this.statementLocks; StatementLocks locks = this.statementLocks;
return locks == null ? Stream.empty() : locks.activeLocks(); return locks == null ? Stream.empty() : locks.activeLocks();
Expand Down
Expand Up @@ -149,7 +149,7 @@ public Stream<ExecutingQuery> executingQueries()
} }


@Override @Override
public Stream<ActiveLock> activeLocks() public Stream<? extends ActiveLock> activeLocks()
{ {
return tx.activeLocks(); return tx.activeLocks();
} }
Expand Down
Expand Up @@ -130,7 +130,7 @@ interface Client extends ResourceLocker, AutoCloseable
/** For slave transactions, this tracks an identifier for the lock session running on the master */ /** For slave transactions, this tracks an identifier for the lock session running on the master */
int getLockSessionId(); int getLockSessionId();


Stream<ActiveLock> activeLocks(); Stream<? extends ActiveLock> activeLocks();


long activeLockCount(); long activeLockCount();
} }
Expand Down
Expand Up @@ -66,7 +66,7 @@ public void close()
} }


@Override @Override
public Stream<ActiveLock> activeLocks() public Stream<? extends ActiveLock> activeLocks()
{ {
return client.activeLocks(); return client.activeLocks();
} }
Expand Down
Expand Up @@ -70,7 +70,7 @@ public interface StatementLocks extends AutoCloseable, org.neo4j.internal.kernel
* *
* @return the locks held by this transaction. * @return the locks held by this transaction.
*/ */
Stream<ActiveLock> activeLocks(); Stream<? extends ActiveLock> activeLocks();


/** /**
* Get the current number of active locks. * Get the current number of active locks.
Expand Down
Expand Up @@ -43,15 +43,13 @@ public class IndexTxStateUpdater
{ {
private final StoreReadLayer storeReadLayer; private final StoreReadLayer storeReadLayer;
private final Read read; private final Read read;
private final NodeSchemaMatcher nodeIndexMatcher;


// We can use the StoreReadLayer directly instead of the SchemaReadOps, because we know that in transactions // We can use the StoreReadLayer directly instead of the SchemaReadOps, because we know that in transactions
// where this class is needed we will never have index changes. // where this class is needed we will never have index changes.
public IndexTxStateUpdater( StoreReadLayer storeReadLayer, Read read, NodeSchemaMatcher nodeIndexMatcher ) public IndexTxStateUpdater( StoreReadLayer storeReadLayer, Read read )
{ {
this.storeReadLayer = storeReadLayer; this.storeReadLayer = storeReadLayer;
this.read = read; this.read = read;
this.nodeIndexMatcher = nodeIndexMatcher;
} }


// LABEL CHANGES // LABEL CHANGES
Expand Down Expand Up @@ -122,7 +120,7 @@ void onPropertyAdd( NodeCursor node, PropertyCursor propertyCursor, int property
assert noSchemaChangedInTx(); assert noSchemaChangedInTx();
Iterator<IndexDescriptor> indexes = Iterator<IndexDescriptor> indexes =
storeReadLayer.indexesGetRelatedToProperty( propertyKeyId ); storeReadLayer.indexesGetRelatedToProperty( propertyKeyId );
nodeIndexMatcher.onMatchingSchema( indexes, node, propertyCursor, propertyKeyId, NodeSchemaMatcher.onMatchingSchema( indexes, node, propertyCursor, propertyKeyId,
( index, propertyKeyIds ) -> ( index, propertyKeyIds ) ->
{ {
Validators.INDEX_VALUE_VALIDATOR.validate( value ); Validators.INDEX_VALUE_VALIDATOR.validate( value );
Expand All @@ -138,7 +136,7 @@ void onPropertyRemove( NodeCursor node, PropertyCursor propertyCursor, int prope
assert noSchemaChangedInTx(); assert noSchemaChangedInTx();
Iterator<IndexDescriptor> indexes = Iterator<IndexDescriptor> indexes =
storeReadLayer.indexesGetRelatedToProperty( propertyKeyId ); storeReadLayer.indexesGetRelatedToProperty( propertyKeyId );
nodeIndexMatcher.onMatchingSchema( indexes, node, propertyCursor, propertyKeyId, NodeSchemaMatcher.onMatchingSchema( indexes, node, propertyCursor, propertyKeyId,
( index, propertyKeyIds ) -> ( index, propertyKeyIds ) ->
{ {
ValueTuple values = ValueTuple values =
Expand All @@ -153,7 +151,7 @@ void onPropertyChange( NodeCursor node, PropertyCursor propertyCursor, int prope
{ {
assert noSchemaChangedInTx(); assert noSchemaChangedInTx();
Iterator<IndexDescriptor> indexes = storeReadLayer.indexesGetRelatedToProperty( propertyKeyId ); Iterator<IndexDescriptor> indexes = storeReadLayer.indexesGetRelatedToProperty( propertyKeyId );
nodeIndexMatcher.onMatchingSchema( indexes, node, propertyCursor, propertyKeyId, NodeSchemaMatcher.onMatchingSchema( indexes, node, propertyCursor, propertyKeyId,
( index, propertyKeyIds ) -> ( index, propertyKeyIds ) ->
{ {
Validators.INDEX_VALUE_VALIDATOR.validate( afterValue ); Validators.INDEX_VALUE_VALIDATOR.validate( afterValue );
Expand Down
Expand Up @@ -35,9 +35,9 @@
*/ */
public class NodeSchemaMatcher public class NodeSchemaMatcher
{ {

private NodeSchemaMatcher()
public NodeSchemaMatcher( Read read )
{ {
throw new AssertionError( "no instance" );
} }


/** /**
Expand All @@ -58,7 +58,7 @@ public NodeSchemaMatcher( Read read )
* @param callback The action to take on match * @param callback The action to take on match
* @throws EXCEPTION This exception is propagated from the action * @throws EXCEPTION This exception is propagated from the action
*/ */
<SUPPLIER extends LabelSchemaSupplier, EXCEPTION extends Exception> void onMatchingSchema( static <SUPPLIER extends LabelSchemaSupplier, EXCEPTION extends Exception> void onMatchingSchema(
Iterator<SUPPLIER> schemaSuppliers, Iterator<SUPPLIER> schemaSuppliers,
NodeCursor node, NodeCursor node,
PropertyCursor property, PropertyCursor property,
Expand Down
Expand Up @@ -87,7 +87,6 @@ public class Operations implements Write, ExplicitIndexWrite
private DefaultPropertyCursor propertyCursor; private DefaultPropertyCursor propertyCursor;
private DefaultRelationshipScanCursor relationshipCursor; private DefaultRelationshipScanCursor relationshipCursor;
private final DefaultCursors cursors; private final DefaultCursors cursors;
private final NodeSchemaMatcher schemaMatcher;


public Operations( public Operations(
AllStoreHolder allStoreHolder, AllStoreHolder allStoreHolder,
Expand All @@ -96,8 +95,7 @@ public Operations(
KernelTransactionImplementation ktx, KernelTransactionImplementation ktx,
KernelToken token, KernelToken token,
DefaultCursors cursors, DefaultCursors cursors,
AutoIndexing autoIndexing, AutoIndexing autoIndexing )
NodeSchemaMatcher schemaMatcher )
{ {
this.token = token; this.token = token;
this.autoIndexing = autoIndexing; this.autoIndexing = autoIndexing;
Expand All @@ -106,7 +104,6 @@ public Operations(
this.statement = statement; this.statement = statement;
this.updater = updater; this.updater = updater;
this.cursors = cursors; this.cursors = cursors;
this.schemaMatcher = schemaMatcher;
} }


public void initialize() public void initialize()
Expand Down Expand Up @@ -367,7 +364,7 @@ public Value nodeSetProperty( long node, int propertyKey, Value value )
Iterator<IndexBackedConstraintDescriptor> uniquenessConstraints = Iterator<IndexBackedConstraintDescriptor> uniquenessConstraints =
new CastingIterator<>( constraints, IndexBackedConstraintDescriptor.class ); new CastingIterator<>( constraints, IndexBackedConstraintDescriptor.class );


schemaMatcher.onMatchingSchema( uniquenessConstraints, nodeCursor, propertyCursor, propertyKey, NodeSchemaMatcher.onMatchingSchema( uniquenessConstraints, nodeCursor, propertyCursor, propertyKey,
( constraint, propertyIds ) -> ( constraint, propertyIds ) ->
{ {
if ( propertyIds.contains( propertyKey ) ) if ( propertyIds.contains( propertyKey ) )
Expand Down
Expand Up @@ -26,7 +26,8 @@
*/ */
public class NoneStrictMath public class NoneStrictMath
{ {
public static final double EPSILON = 1.0E-8; // NOTE: This cannot be final since it's used to change the tolerance in the graph algorithms module
public static double EPSILON = 1.0E-8;


private NoneStrictMath() private NoneStrictMath()
{ {
Expand Down
Expand Up @@ -29,7 +29,6 @@
import org.neo4j.internal.kernel.api.helpers.StubNodeCursor; import org.neo4j.internal.kernel.api.helpers.StubNodeCursor;
import org.neo4j.internal.kernel.api.helpers.StubPropertyCursor; import org.neo4j.internal.kernel.api.helpers.StubPropertyCursor;
import org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor;
import org.neo4j.kernel.api.exceptions.EntityNotFoundException;
import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory;
import org.neo4j.kernel.api.txstate.TransactionState; import org.neo4j.kernel.api.txstate.TransactionState;
Expand Down Expand Up @@ -111,7 +110,7 @@ public void setup()
Read readOps = mock( Read.class ); Read readOps = mock( Read.class );
when( readOps.txState() ).thenReturn( txState ); when( readOps.txState() ).thenReturn( txState );


indexTxUpdater = new IndexTxStateUpdater( storeReadLayer, readOps, new NodeSchemaMatcher( readOps ) ); indexTxUpdater = new IndexTxStateUpdater( storeReadLayer, readOps );


} }


Expand Down
Expand Up @@ -36,7 +36,6 @@
import org.neo4j.internal.kernel.api.exceptions.explicitindex.AutoIndexingKernelException; import org.neo4j.internal.kernel.api.exceptions.explicitindex.AutoIndexingKernelException;
import org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor;
import org.neo4j.internal.kernel.api.schema.constraints.ConstraintDescriptor; import org.neo4j.internal.kernel.api.schema.constraints.ConstraintDescriptor;
import org.neo4j.kernel.api.exceptions.EntityNotFoundException;
import org.neo4j.kernel.api.explicitindex.AutoIndexOperations; import org.neo4j.kernel.api.explicitindex.AutoIndexOperations;
import org.neo4j.kernel.api.explicitindex.AutoIndexing; import org.neo4j.kernel.api.explicitindex.AutoIndexing;
import org.neo4j.kernel.api.schema.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema.SchemaDescriptorFactory;
Expand Down Expand Up @@ -116,8 +115,7 @@ public void setUp() throws InvalidTransactionTypeKernelException
allStoreHolder = new AllStoreHolder( engine, store, transaction, cursors, mock( allStoreHolder = new AllStoreHolder( engine, store, transaction, cursors, mock(
ExplicitIndexStore.class ) ); ExplicitIndexStore.class ) );
operations = new Operations( allStoreHolder, mock( IndexTxStateUpdater.class ), operations = new Operations( allStoreHolder, mock( IndexTxStateUpdater.class ),
store, transaction, new KernelToken( storeReadLayer ), cursors, autoindexing, store, transaction, new KernelToken( storeReadLayer ), cursors, autoindexing );
mock( NodeSchemaMatcher.class ) );
operations.initialize(); operations.initialize();


this.order = inOrder( locks, txState, storeReadLayer ); this.order = inOrder( locks, txState, storeReadLayer );
Expand Down
Expand Up @@ -280,7 +280,7 @@ public int getLockSessionId()
} }


@Override @Override
public Stream<ActiveLock> activeLocks() public Stream<? extends ActiveLock> activeLocks()
{ {
return localClient.activeLocks(); return localClient.activeLocks();
} }
Expand Down
Expand Up @@ -184,9 +184,9 @@ public int getLockSessionId()
} }


@Override @Override
public Stream<ActiveLock> activeLocks() public Stream<? extends ActiveLock> activeLocks()
{ {
return locks.keySet().stream().map( ActiveLock.class::cast ); return locks.keySet().stream();
} }


@Override @Override
Expand Down
Expand Up @@ -369,7 +369,7 @@ public void run()
} }
catch ( HighAvailabilityStoreFailureException e ) catch ( HighAvailabilityStoreFailureException e )
{ {
userLog.error( "UNABLE HEADER_TO START UP AS SLAVE: %s", e.getMessage() ); userLog.error( "UNABLE TO START UP AS SLAVE: %s", e.getMessage() );
msgLog.error( "Unable to start up as slave", e ); msgLog.error( "Unable to start up as slave", e );


clusterMemberAvailability.memberIsUnavailable( SLAVE ); clusterMemberAvailability.memberIsUnavailable( SLAVE );
Expand Down
Expand Up @@ -225,7 +225,7 @@ public int getLockSessionId()
} }


@Override @Override
public Stream<ActiveLock> activeLocks() public Stream<? extends ActiveLock> activeLocks()
{ {
return client.activeLocks(); return client.activeLocks();
} }
Expand Down
Expand Up @@ -80,7 +80,7 @@ public void close()
} }


@Override @Override
public Stream<ActiveLock> activeLocks() public Stream<? extends ActiveLock> activeLocks()
{ {
return delegate.activeLocks(); return delegate.activeLocks();
} }
Expand Down

0 comments on commit 5a48bb8

Please sign in to comment.