Skip to content

Commit

Permalink
Removed duplicated interface PropertyLookup
Browse files Browse the repository at this point in the history
All usages replaced with PropertyAccessor.
  • Loading branch information
lutovich committed Jan 25, 2016
1 parent b121045 commit 084d77e
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 55 deletions.
Expand Up @@ -24,17 +24,17 @@
import java.util.List;

import org.neo4j.function.Suppliers;
import org.neo4j.kernel.api.index.PropertyAccessor;
import org.neo4j.kernel.api.properties.DefinedProperty;
import org.neo4j.kernel.api.properties.Property;
import org.neo4j.kernel.impl.api.PropertyLookup;
import org.neo4j.kernel.impl.store.InvalidRecordException;
import org.neo4j.kernel.impl.store.NodeStore;
import org.neo4j.kernel.impl.store.PropertyStore;
import org.neo4j.kernel.impl.store.record.NodeRecord;
import org.neo4j.kernel.impl.store.record.PropertyBlock;
import org.neo4j.kernel.impl.store.record.PropertyRecord;

public class PropertyReader implements PropertyLookup
public class PropertyReader implements PropertyAccessor
{
private final PropertyStore propertyStore;
private final NodeStore nodeStore;
Expand Down Expand Up @@ -65,7 +65,7 @@ public DefinedProperty propertyValue( PropertyBlock block )
}

@Override
public Property nodeProperty( long nodeId, int propertyKeyId )
public Property getProperty( long nodeId, int propertyKeyId )
{
try
{
Expand Down
Expand Up @@ -25,28 +25,25 @@
import java.util.List;

import org.neo4j.function.Suppliers;
import org.neo4j.kernel.api.index.PropertyAccessor;
import org.neo4j.kernel.api.properties.DefinedProperty;
import org.neo4j.kernel.api.properties.Property;
import org.neo4j.kernel.impl.api.PropertyLookup;
import org.neo4j.kernel.impl.store.NodeStore;
import org.neo4j.kernel.impl.store.PropertyStore;
import org.neo4j.kernel.impl.store.StoreAccess;
import org.neo4j.kernel.impl.store.record.NodeRecord;
import org.neo4j.kernel.impl.store.record.PropertyBlock;
import org.neo4j.kernel.impl.store.record.PropertyRecord;
import org.neo4j.kernel.impl.store.record.Record;

public class PropertyReader implements PropertyLookup
public class PropertyReader implements PropertyAccessor
{
private final PropertyStore propertyStore;
private final NodeStore nodeStore;
private final StoreAccess storeAccess;

public PropertyReader( StoreAccess storeAccess )
{
this.storeAccess = storeAccess;
propertyStore = storeAccess.getRawNeoStores().getPropertyStore();
nodeStore = storeAccess.getRawNeoStores().getNodeStore();
}

public Collection<PropertyRecord> getPropertyRecordChain( NodeRecord nodeRecord )
Expand Down Expand Up @@ -100,7 +97,7 @@ public DefinedProperty propertyValue( PropertyBlock block )
}

@Override
public Property nodeProperty( long nodeId, int propertyKeyId )
public Property getProperty( long nodeId, int propertyKeyId )
{
NodeRecord nodeRecord = storeAccess.getNodeStore().forceGetRecord( nodeId );
if ( nodeRecord != null )
Expand Down
Expand Up @@ -20,13 +20,12 @@
package org.neo4j.kernel.api.index;

import org.neo4j.kernel.api.exceptions.EntityNotFoundException;
import org.neo4j.kernel.api.exceptions.PropertyNotFoundException;
import org.neo4j.kernel.api.properties.Property;

/**
* Used by the {@link IndexPopulator} for verifying constraints, if need be.
*/
public interface PropertyAccessor
{
Property getProperty( long nodeId, int propertyKeyId ) throws EntityNotFoundException, PropertyNotFoundException;
Property getProperty( long nodeId, int propertyKeyId ) throws EntityNotFoundException;
}
Expand Up @@ -25,6 +25,7 @@
import org.neo4j.collection.primitive.PrimitiveLongIterator;
import org.neo4j.cursor.Cursor;
import org.neo4j.kernel.api.exceptions.EntityNotFoundException;
import org.neo4j.kernel.api.index.PropertyAccessor;
import org.neo4j.kernel.api.properties.Property;
import org.neo4j.kernel.impl.api.operations.EntityOperations;
import org.neo4j.kernel.impl.api.operations.EntityReadOperations;
Expand All @@ -44,13 +45,13 @@ public class LookupFilter
/**
* used by the consistency checker
*/
public static PrimitiveLongIterator exactIndexMatches( PropertyLookup lookup, PrimitiveLongIterator indexedNodeIds,
int propertyKeyId, Object value )
public static PrimitiveLongIterator exactIndexMatches( PropertyAccessor accessor,
PrimitiveLongIterator indexedNodeIds, int propertyKeyId, Object value )
{
if ( isNumberOrArray( value ) )
{
return PrimitiveLongCollections.filter( indexedNodeIds,
new LookupBasedExactMatchPredicate( lookup, propertyKeyId,
new LookupBasedExactMatchPredicate( accessor, propertyKeyId,
value ) );
}
return indexedNodeIds;
Expand Down Expand Up @@ -150,18 +151,18 @@ Property nodeProperty( long nodeId, int propertyKeyId ) throws EntityNotFoundExc
*/
private static class LookupBasedExactMatchPredicate extends BaseExactMatchPredicate
{
final PropertyLookup lookup;
final PropertyAccessor accessor;

LookupBasedExactMatchPredicate( PropertyLookup lookup, int propertyKeyId, Object value )
LookupBasedExactMatchPredicate( PropertyAccessor accessor, int propertyKeyId, Object value )
{
super( propertyKeyId, value );
this.lookup = lookup;
this.accessor = accessor;
}

@Override
Property nodeProperty( long nodeId, int propertyKeyId ) throws EntityNotFoundException
{
return lookup.nodeProperty( nodeId, propertyKeyId );
return accessor.getProperty( nodeId, propertyKeyId );
}
}

Expand Down

This file was deleted.

Expand Up @@ -24,7 +24,6 @@

import org.neo4j.helpers.collection.Visitor;
import org.neo4j.kernel.api.exceptions.EntityNotFoundException;
import org.neo4j.kernel.api.exceptions.PropertyNotFoundException;
import org.neo4j.kernel.api.index.IndexDescriptor;
import org.neo4j.kernel.api.index.NodePropertyUpdate;
import org.neo4j.kernel.api.index.PropertyAccessor;
Expand Down Expand Up @@ -87,8 +86,7 @@ public PopulationProgress getProgress()
IndexStoreView EMPTY = new IndexStoreView()
{
@Override
public Property getProperty( long nodeId, int propertyKeyId )
throws EntityNotFoundException, PropertyNotFoundException
public Property getProperty( long nodeId, int propertyKeyId ) throws EntityNotFoundException
{
return Property.noNodeProperty( nodeId, propertyKeyId );
}
Expand Down
Expand Up @@ -28,7 +28,6 @@
import org.neo4j.helpers.collection.PrefetchingIterator;
import org.neo4j.helpers.collection.Visitor;
import org.neo4j.kernel.api.exceptions.EntityNotFoundException;
import org.neo4j.kernel.api.exceptions.PropertyNotFoundException;
import org.neo4j.kernel.api.index.IndexDescriptor;
import org.neo4j.kernel.api.index.NodePropertyUpdate;
import org.neo4j.kernel.api.labelscan.NodeLabelUpdate;
Expand All @@ -50,6 +49,7 @@
import org.neo4j.register.Register.DoubleLongRegister;
import org.neo4j.storageengine.api.EntityType;
import org.neo4j.storageengine.api.schema.PopulationProgress;

import static org.neo4j.collection.primitive.PrimitiveLongCollections.EMPTY_LONG_ARRAY;
import static org.neo4j.kernel.api.index.NodePropertyUpdate.add;
import static org.neo4j.kernel.api.labelscan.NodeLabelUpdate.labelChanges;
Expand Down Expand Up @@ -178,7 +178,7 @@ public void nodeAsUpdates( long nodeId, Collection<NodePropertyUpdate> target )
}

@Override
public Property getProperty( long nodeId, int propertyKeyId ) throws EntityNotFoundException, PropertyNotFoundException
public Property getProperty( long nodeId, int propertyKeyId ) throws EntityNotFoundException
{
NodeRecord node = nodeStore.forceGetRecord( nodeId );
if ( !node.inUse() )
Expand All @@ -188,7 +188,7 @@ public Property getProperty( long nodeId, int propertyKeyId ) throws EntityNotFo
long firstPropertyId = node.getNextProp();
if ( firstPropertyId == Record.NO_NEXT_PROPERTY.intValue() )
{
throw new PropertyNotFoundException( propertyKeyId, EntityType.NODE, nodeId );
return Property.noNodeProperty( nodeId, propertyKeyId );
}
for ( PropertyRecord propertyRecord : propertyStore.getPropertyRecordChain( firstPropertyId ) )
{
Expand All @@ -198,7 +198,7 @@ public Property getProperty( long nodeId, int propertyKeyId ) throws EntityNotFo
return propertyBlock.newPropertyData( propertyStore );
}
}
throw new PropertyNotFoundException( propertyKeyId, EntityType.NODE, nodeId );
return Property.noNodeProperty( nodeId, propertyKeyId );
}

private Object valueOf( PropertyBlock property )
Expand Down
Expand Up @@ -25,7 +25,6 @@
import org.neo4j.collection.primitive.PrimitiveLongCollections;
import org.neo4j.collection.primitive.PrimitiveLongIterator;
import org.neo4j.kernel.api.exceptions.EntityNotFoundException;
import org.neo4j.kernel.api.exceptions.PropertyNotFoundException;
import org.neo4j.kernel.api.properties.Property;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
Expand Down Expand Up @@ -133,7 +132,7 @@ public void shouldApplyUpdatesIdempotently() throws Exception
PropertyAccessor propertyAccessor = new PropertyAccessor()
{
@Override
public Property getProperty( long nodeId, int propertyKeyId ) throws EntityNotFoundException, PropertyNotFoundException
public Property getProperty( long nodeId, int propertyKeyId ) throws EntityNotFoundException
{
return Property.stringProperty( propertyKeyId, propertyValue );
}
Expand Down

0 comments on commit 084d77e

Please sign in to comment.