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.
*/
Stream<ActiveLock> activeLocks();
Stream<? extends ActiveLock> activeLocks();

/**
* 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<>();
AllStoreHolder allStoreHolder =
new AllStoreHolder( storageEngine, storageStatement, this, cursors, explicitIndexStore );
org.neo4j.kernel.impl.newapi.NodeSchemaMatcher matcher =
new org.neo4j.kernel.impl.newapi.NodeSchemaMatcher( allStoreHolder );
this.operations =
new Operations(
allStoreHolder,
new IndexTxStateUpdater( storageEngine.storeReadLayer(), allStoreHolder, matcher ),
new IndexTxStateUpdater( storageEngine.storeReadLayer(), allStoreHolder ),
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.
*/
public Stream<ActiveLock> activeLocks()
public Stream<? extends ActiveLock> activeLocks()
{
StatementLocks locks = this.statementLocks;
return locks == null ? Stream.empty() : locks.activeLocks();
Expand Down
Expand Up @@ -149,7 +149,7 @@ public Stream<ExecutingQuery> executingQueries()
}

@Override
public Stream<ActiveLock> activeLocks()
public Stream<? extends ActiveLock> 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 */
int getLockSessionId();

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

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

@Override
public Stream<ActiveLock> activeLocks()
public Stream<? extends ActiveLock> 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.
*/
Stream<ActiveLock> activeLocks();
Stream<? extends ActiveLock> activeLocks();

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

// 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.
public IndexTxStateUpdater( StoreReadLayer storeReadLayer, Read read, NodeSchemaMatcher nodeIndexMatcher )
public IndexTxStateUpdater( StoreReadLayer storeReadLayer, Read read )
{
this.storeReadLayer = storeReadLayer;
this.read = read;
this.nodeIndexMatcher = nodeIndexMatcher;
}

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

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

/**
Expand All @@ -58,7 +58,7 @@ public NodeSchemaMatcher( Read read )
* @param callback The action to take on match
* @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,
NodeCursor node,
PropertyCursor property,
Expand Down
Expand Up @@ -87,7 +87,6 @@ public class Operations implements Write, ExplicitIndexWrite
private DefaultPropertyCursor propertyCursor;
private DefaultRelationshipScanCursor relationshipCursor;
private final DefaultCursors cursors;
private final NodeSchemaMatcher schemaMatcher;

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

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

schemaMatcher.onMatchingSchema( uniquenessConstraints, nodeCursor, propertyCursor, propertyKey,
NodeSchemaMatcher.onMatchingSchema( uniquenessConstraints, nodeCursor, propertyCursor, propertyKey,
( constraint, propertyIds ) ->
{
if ( propertyIds.contains( propertyKey ) )
Expand Down
Expand Up @@ -26,7 +26,8 @@
*/
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()
{
Expand Down
Expand Up @@ -29,7 +29,6 @@
import org.neo4j.internal.kernel.api.helpers.StubNodeCursor;
import org.neo4j.internal.kernel.api.helpers.StubPropertyCursor;
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.IndexDescriptorFactory;
import org.neo4j.kernel.api.txstate.TransactionState;
Expand Down Expand Up @@ -111,7 +110,7 @@ public void setup()
Read readOps = mock( Read.class );
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.schema.LabelSchemaDescriptor;
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.AutoIndexing;
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(
ExplicitIndexStore.class ) );
operations = new Operations( allStoreHolder, mock( IndexTxStateUpdater.class ),
store, transaction, new KernelToken( storeReadLayer ), cursors, autoindexing,
mock( NodeSchemaMatcher.class ) );
store, transaction, new KernelToken( storeReadLayer ), cursors, autoindexing );
operations.initialize();

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

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

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

@Override
Expand Down
Expand Up @@ -369,7 +369,7 @@ public void run()
}
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 );

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

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

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

0 comments on commit 5a48bb8

Please sign in to comment.