Skip to content

Commit

Permalink
Revert "Merge pull request #16 from davidegrohmann/3.3-cleanup"
Browse files Browse the repository at this point in the history
This reverts commit 9ac9db2, reversing
changes made to 7b0b7a6.
  • Loading branch information
MishaDemianenko committed May 25, 2017
1 parent f9e420f commit 3da8523
Show file tree
Hide file tree
Showing 26 changed files with 389 additions and 310 deletions.
Expand Up @@ -37,11 +37,11 @@
public class GlobalCursorPools implements CursorPools
{
private final CursorPool<NodeCursor> nodeCursor;
private final CursorPool<SingleRelationshipCursor> singleRelationshipCursor;
private final CursorPool<IteratorRelationshipCursor> iteratorRelationshipCursor;
private final CursorPool<NodeRelationshipCursor> nodeRelationshipsCursor;
private final CursorPool<PropertyCursor> propertyCursor;
private final CursorPool<SinglePropertyCursor> singlePropertyCursor;
private final CursorPool<StoreSingleRelationshipCursor> singleRelationshipCursor;
private final CursorPool<StoreIteratorRelationshipCursor> iteratorRelationshipCursor;
private final CursorPool<StoreNodeRelationshipCursor> nodeRelationshipsCursor;
private final CursorPool<StorePropertyCursor> propertyCursor;
private final CursorPool<StoreSinglePropertyCursor> singlePropertyCursor;
private final CursorPool<RelationshipGroupCursor> relationshipGroupCursorCache;
private final CursorPool<DenseNodeDegreeCounter> degreeCounter;
private final NeoStores neoStores;
Expand All @@ -52,16 +52,16 @@ public GlobalCursorPools( NeoStores neoStores, LockService lockService )
this.nodeCursor =
new CursorPool<>( 10, cache -> new NodeCursor( neoStores.getNodeStore(), cache, lockService ) );
this.singleRelationshipCursor = new CursorPool<>( 10,
cache -> new SingleRelationshipCursor( neoStores.getRelationshipStore(), cache, lockService ) );
cache -> new StoreSingleRelationshipCursor( neoStores.getRelationshipStore(), cache, lockService ) );
this.iteratorRelationshipCursor = new CursorPool<>( 10,
cache -> new IteratorRelationshipCursor( neoStores.getRelationshipStore(), cache, lockService ) );
cache -> new StoreIteratorRelationshipCursor( neoStores.getRelationshipStore(), cache, lockService ) );
this.nodeRelationshipsCursor = new CursorPool<>( 10,
cache -> new NodeRelationshipCursor( neoStores.getRelationshipStore(),
cache -> new StoreNodeRelationshipCursor( neoStores.getRelationshipStore(),
neoStores.getRelationshipGroupStore(), cache, lockService ) );
this.propertyCursor =
new CursorPool<>( 10, cache -> new PropertyCursor( neoStores.getPropertyStore(), cache ) );
new CursorPool<>( 10, cache -> new StorePropertyCursor( neoStores.getPropertyStore(), cache ) );
this.singlePropertyCursor =
new CursorPool<>( 10, cache -> new SinglePropertyCursor( neoStores.getPropertyStore(), cache ) );
new CursorPool<>( 10, cache -> new StoreSinglePropertyCursor( neoStores.getPropertyStore(), cache ) );
this.degreeCounter = new CursorPool<>( 10,
cache -> new DenseNodeDegreeCounter( neoStores.getRelationshipStore(),
neoStores.getRelationshipGroupStore(), cache ) );
Expand Down
Expand Up @@ -123,7 +123,6 @@ public void close()
labels = null;
added = null;
progression = null;
stateView = null;
batch.nothing();
instanceCache.accept( this );
}
Expand Down
Expand Up @@ -28,13 +28,13 @@
import static org.neo4j.kernel.api.StatementConstants.NO_SUCH_RELATIONSHIP;
import static org.neo4j.kernel.api.StatementConstants.NO_SUCH_RELATIONSHIP_TYPE;

public abstract class AbstractIteratorRelationshipCursor extends AbstractRelationshipCursor
public abstract class StoreAbstractIteratorRelationshipCursor extends StoreAbstractRelationshipCursor
{
private ReadableTransactionState state;
private PrimitiveLongIterator addedRelationshipIterator;
private boolean fromStore;

AbstractIteratorRelationshipCursor( RelationshipStore relationshipStore, LockService lockService )
StoreAbstractIteratorRelationshipCursor( RelationshipStore relationshipStore, LockService lockService )
{
super( relationshipStore, lockService );
}
Expand Down
Expand Up @@ -35,9 +35,9 @@
import static org.neo4j.kernel.api.StatementConstants.NO_SUCH_PROPERTY;
import static org.neo4j.kernel.impl.store.record.RecordLoad.FORCE;

public abstract class AbstractPropertyCursor implements PropertyItem, Cursor<PropertyItem>, Disposable
public abstract class StoreAbstractPropertyCursor implements PropertyItem, Cursor<PropertyItem>, Disposable
{
private final PropertyPayloadCursor payload;
protected final StorePropertyPayloadCursor payload;
private final PageCursor cursor;
private final PropertyRecord record;
private final PropertyStore propertyStore;
Expand All @@ -50,12 +50,12 @@ public abstract class AbstractPropertyCursor implements PropertyItem, Cursor<Pro
private Lock lock;
protected PropertyContainerState state;

AbstractPropertyCursor( PropertyStore propertyStore )
StoreAbstractPropertyCursor( PropertyStore propertyStore )
{
this.cursor = propertyStore.newPageCursor();
this.propertyStore = propertyStore;
this.record = propertyStore.newRecord();
this.payload = new PropertyPayloadCursor( propertyStore.getStringStore(), propertyStore.getArrayStore() );
this.payload = new StorePropertyPayloadCursor( propertyStore.getStringStore(), propertyStore.getArrayStore() );
}

protected final void initialize( IntPredicate propertyKeyIds, long firstPropertyId, Lock lock,
Expand Down Expand Up @@ -115,7 +115,7 @@ private boolean fetchNext()
private boolean payloadHasNext()
{
boolean next = payload.next();
while ( next )
while ( next && state != null )
{
int propertyKeyId = payload.propertyKeyId();
if ( !state.isPropertyRemoved( propertyKeyId ) )
Expand All @@ -126,7 +126,7 @@ private boolean payloadHasNext()
}
next = payload.next();
}
return false;
return next;
}

protected abstract boolean loadNextFromDisk();
Expand Down Expand Up @@ -166,7 +166,6 @@ public final void close()
payload.close();
propertyKeyIds = null;
property = null;
state = null;
nextPropertyId = NO_SUCH_PROPERTY;
doClose();
}
Expand Down
Expand Up @@ -37,7 +37,7 @@
/**
* Base cursor for relationships.
*/
public abstract class AbstractRelationshipCursor
public abstract class StoreAbstractRelationshipCursor
implements RelationshipVisitor<RuntimeException>, RelationshipItem, Cursor<RelationshipItem>, Disposable
{
protected final RelationshipRecord relationshipRecord;
Expand All @@ -46,7 +46,7 @@ public abstract class AbstractRelationshipCursor
private final LockService lockService;
protected boolean fetched;

AbstractRelationshipCursor( RelationshipStore relationshipStore, LockService lockService )
StoreAbstractRelationshipCursor( RelationshipStore relationshipStore, LockService lockService )
{
this.relationshipStore = relationshipStore;
this.relationshipRecord = relationshipStore.newRecord();
Expand Down
Expand Up @@ -32,20 +32,20 @@
/**
* Cursor for iterating a set of relationships.
*/
public class IteratorRelationshipCursor extends AbstractIteratorRelationshipCursor
public class StoreIteratorRelationshipCursor extends StoreAbstractIteratorRelationshipCursor
{
private final Consumer<IteratorRelationshipCursor> instanceCache;
private final Consumer<StoreIteratorRelationshipCursor> instanceCache;
private PrimitiveLongIterator iterator;

IteratorRelationshipCursor( RelationshipStore relationshipStore,
Consumer<IteratorRelationshipCursor> instanceCache,
StoreIteratorRelationshipCursor( RelationshipStore relationshipStore,
Consumer<StoreIteratorRelationshipCursor> instanceCache,
LockService lockService )
{
super( relationshipStore, lockService );
this.instanceCache = instanceCache;
}

public IteratorRelationshipCursor init( PrimitiveLongIterator iterator, ReadableTransactionState state )
public StoreIteratorRelationshipCursor init( PrimitiveLongIterator iterator, ReadableTransactionState state )
{
internalInitTxState( state, addedRelationships( state ) );
this.iterator = iterator;
Expand Down
Expand Up @@ -45,11 +45,11 @@
* <p/>
* This cursor handles both dense and non-dense nodes as source.
*/
public class NodeRelationshipCursor extends AbstractIteratorRelationshipCursor
public class StoreNodeRelationshipCursor extends StoreAbstractIteratorRelationshipCursor
{
private final RelationshipGroupRecord groupRecord;
private final RelationshipGroupStore relationshipGroupStore;
private final Consumer<NodeRelationshipCursor> instanceCache;
private final Consumer<StoreNodeRelationshipCursor> instanceCache;
private final PageCursor groupStorePageCursor;

private boolean isDense;
Expand All @@ -60,9 +60,9 @@ public class NodeRelationshipCursor extends AbstractIteratorRelationshipCursor
private int groupChainIndex;
private boolean end;

public NodeRelationshipCursor( RelationshipStore relationshipStore,
public StoreNodeRelationshipCursor( RelationshipStore relationshipStore,
RelationshipGroupStore relationshipGroupStore,
Consumer<NodeRelationshipCursor> instanceCache,
Consumer<StoreNodeRelationshipCursor> instanceCache,
LockService lockService )
{
super( relationshipStore, lockService );
Expand All @@ -72,22 +72,22 @@ public NodeRelationshipCursor( RelationshipStore relationshipStore,
this.instanceCache = instanceCache;
}

public NodeRelationshipCursor init( boolean isDense, long firstRelId, long fromNodeId, Direction direction,
public StoreNodeRelationshipCursor init( boolean isDense, long firstRelId, long fromNodeId, Direction direction,
ReadableTransactionState state )
{
PrimitiveLongIterator addedNodeRelationships = addedNodeRelationships( fromNodeId, direction, null, state );
return init( isDense, firstRelId, fromNodeId, direction, ALWAYS_TRUE_INT, state, addedNodeRelationships );
}

public NodeRelationshipCursor init( boolean isDense, long firstRelId, long fromNodeId, Direction direction,
public StoreNodeRelationshipCursor init( boolean isDense, long firstRelId, long fromNodeId, Direction direction,
int[] allowedTypes, ReadableTransactionState state )
{
PrimitiveLongIterator addedNodeRelationships =
addedNodeRelationships( fromNodeId, direction, allowedTypes, state );
return init( isDense, firstRelId, fromNodeId, direction, any( allowedTypes ), state, addedNodeRelationships );
}

private NodeRelationshipCursor init( boolean isDense, long firstRelId, long fromNodeId, Direction direction,
private StoreNodeRelationshipCursor init( boolean isDense, long firstRelId, long fromNodeId, Direction direction,
IntPredicate allowedTypes, ReadableTransactionState state, PrimitiveLongIterator addedNodeRelationships )
{
internalInitTxState( state, addedNodeRelationships );
Expand Down
Expand Up @@ -33,21 +33,21 @@
/**
* Cursor for all properties on a node or relationship.
*/
public class PropertyCursor extends AbstractPropertyCursor
public class StorePropertyCursor extends StoreAbstractPropertyCursor
{
private final Consumer<PropertyCursor> consumer;
private final Consumer<StorePropertyCursor> instanceCache;

private Iterator<StorageProperty> storagePropertyIterator;

public PropertyCursor( PropertyStore propertyStore, Consumer<PropertyCursor> consumer )
public StorePropertyCursor( PropertyStore propertyStore, Consumer<StorePropertyCursor> instanceCache )
{
super( propertyStore );
this.consumer = consumer;
this.instanceCache = instanceCache;
}

public PropertyCursor init( long firstPropertyId, Lock lock, PropertyContainerState state )
public StorePropertyCursor init( long firstPropertyId, Lock lock, PropertyContainerState state )
{
storagePropertyIterator = state.addedProperties();
storagePropertyIterator = state == null ? null : state.addedProperties();
initialize( ALWAYS_TRUE_INT, firstPropertyId, lock, state );
return this;
}
Expand All @@ -61,16 +61,20 @@ protected boolean loadNextFromDisk()
@Override
protected DefinedProperty nextAdded()
{
if ( storagePropertyIterator.hasNext() )
if ( storagePropertyIterator != null )
{
return (DefinedProperty) storagePropertyIterator.next();
if ( storagePropertyIterator.hasNext() )
{
return (DefinedProperty) storagePropertyIterator.next();
}
storagePropertyIterator = null;
}
return null;
}

@Override
protected void doClose()
{
consumer.accept( this );
instanceCache.accept( this );
}
}
Expand Up @@ -48,7 +48,7 @@
* During initialization the raw property block {@code long}s are read from
* the given property record.
*/
class PropertyPayloadCursor implements Disposable
class StorePropertyPayloadCursor implements Disposable
{
private static final int MAX_BYTES_IN_SHORT_STRING_OR_SHORT_ARRAY = 32;
private static final int INTERNAL_BYTE_ARRAY_SIZE = 4096;
Expand All @@ -72,7 +72,7 @@ class PropertyPayloadCursor implements Disposable
private IntPredicate propertyKeyIds;
private boolean exhausted;

PropertyPayloadCursor( DynamicStringStore stringStore, DynamicArrayStore arrayStore )
StorePropertyPayloadCursor( DynamicStringStore stringStore, DynamicArrayStore arrayStore )
{
this.record = stringStore.newRecord();
this.stringStore = stringStore;
Expand Down
Expand Up @@ -26,18 +26,18 @@
import org.neo4j.kernel.impl.store.PropertyStore;
import org.neo4j.storageengine.api.txstate.PropertyContainerState;

public class SinglePropertyCursor extends AbstractPropertyCursor
public class StoreSinglePropertyCursor extends StoreAbstractPropertyCursor
{
private final Consumer<SinglePropertyCursor> consumer;
private final Consumer<StoreSinglePropertyCursor> instanceCache;
private int propertyKeyId;

SinglePropertyCursor( PropertyStore propertyStore, Consumer<SinglePropertyCursor> consumer )
StoreSinglePropertyCursor( PropertyStore propertyStore, Consumer<StoreSinglePropertyCursor> instanceCache )
{
super( propertyStore );
this.consumer = consumer;
this.instanceCache = instanceCache;
}

public SinglePropertyCursor init( int propertyKeyId, long firstPropertyId, Lock lock,
public StoreSinglePropertyCursor init( int propertyKeyId, long firstPropertyId, Lock lock,
PropertyContainerState state )
{
this.propertyKeyId = propertyKeyId;
Expand Down Expand Up @@ -67,6 +67,6 @@ protected DefinedProperty nextAdded()
@Override
protected void doClose()
{
consumer.accept( this );
instanceCache.accept( this );
}
}
Expand Up @@ -33,20 +33,20 @@
/**
* Cursor for a single relationship.
*/
public class SingleRelationshipCursor extends AbstractRelationshipCursor
public class StoreSingleRelationshipCursor extends StoreAbstractRelationshipCursor
{
private final Consumer<SingleRelationshipCursor> consumer;
private final Consumer<StoreSingleRelationshipCursor> consumer;
private long relationshipId = NO_SUCH_RELATIONSHIP;
private ReadableTransactionState state;

SingleRelationshipCursor( RelationshipStore relationshipStore,
Consumer<SingleRelationshipCursor> consumer, LockService lockService )
StoreSingleRelationshipCursor( RelationshipStore relationshipStore,
Consumer<StoreSingleRelationshipCursor> consumer, LockService lockService )
{
super( relationshipStore, lockService );
this.consumer = consumer;
}

public SingleRelationshipCursor init( long relId, ReadableTransactionState state )
public StoreSingleRelationshipCursor init( long relId, ReadableTransactionState state )
{
this.relationshipId = relId;
this.state = state;
Expand Down Expand Up @@ -91,7 +91,6 @@ private boolean fetchFromTxState()
public void close()
{
super.close();
state = null;
relationshipId = NO_SUCH_RELATIONSHIP;
consumer.accept( this );
}
Expand Down
Expand Up @@ -46,7 +46,7 @@ public class PropertyRecord extends AbstractBaseRecord implements Iterable<Prope
private long nextProp;
private long prevProp;
// Holds the purely physical representation of the loaded properties in this record. This is so that
// PropertyCursor is able to use this raw data without the rather heavy and bloated data structures
// StorePropertyCursor is able to use this raw data without the rather heavy and bloated data structures
// of PropertyBlock and thereabouts. So when a property record is loaded only these blocks are read,
// the construction of all PropertyBlock instances are loaded lazile when they are first needed, loaded
// by ensureBlocksLoaded().
Expand Down
Expand Up @@ -49,7 +49,7 @@
import org.neo4j.io.pagecache.PageCursor;
import org.neo4j.io.pagecache.PagedFile;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.api.store.PropertyCursor;
import org.neo4j.kernel.impl.api.store.StorePropertyCursor;
import org.neo4j.kernel.impl.locking.LockService;
import org.neo4j.kernel.impl.logging.LogService;
import org.neo4j.kernel.impl.store.CountsComputer;
Expand Down Expand Up @@ -90,7 +90,6 @@
import org.neo4j.kernel.impl.util.CustomIOConfigValidator;
import org.neo4j.kernel.lifecycle.Lifespan;
import org.neo4j.logging.NullLogProvider;
import org.neo4j.storageengine.api.txstate.PropertyContainerState;
import org.neo4j.unsafe.impl.batchimport.AdditionalInitialIds;
import org.neo4j.unsafe.impl.batchimport.BatchImporter;
import org.neo4j.unsafe.impl.batchimport.Configuration;
Expand Down Expand Up @@ -615,11 +614,11 @@ private <ENTITY extends InputEntity, RECORD extends PrimitiveRecord> BiConsumer<
};
}

final PropertyCursor cursor = new PropertyCursor( propertyStore, ignored -> {} );
final StorePropertyCursor cursor = new StorePropertyCursor( propertyStore, ignored -> {} );
final List<Object> scratch = new ArrayList<>();
return ( ENTITY entity, RECORD record ) ->
{
cursor.init( record.getNextProp(), LockService.NO_LOCK, PropertyContainerState.EMPTY );
cursor.init( record.getNextProp(), LockService.NO_LOCK, null );
scratch.clear();
while ( cursor.next() )
{
Expand Down

0 comments on commit 3da8523

Please sign in to comment.