Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Mar 23, 2018
1 parent 8ced3d6 commit e3c5d4f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 28 deletions.
Expand Up @@ -40,6 +40,8 @@
*/
public interface IndexAccessor extends Closeable
{
IndexAccessor EMPTY = new Adapter();

/**
* Deletes this index as well as closes all used external resources.
* There will not be any interactions after this call.
Expand Down Expand Up @@ -118,8 +120,6 @@ public interface IndexAccessor extends Closeable
*/
boolean isDirty();

IndexAccessor EMPTY = new Adapter();

class Adapter implements IndexAccessor
{
@Override
Expand Down
Expand Up @@ -43,12 +43,11 @@
abstract class NativeSchemaIndexReader<KEY extends NativeSchemaKey, VALUE extends NativeSchemaValue>
implements IndexReader
{
private final GBPTree<KEY,VALUE> tree;
protected final SchemaIndexDescriptor descriptor;
final Layout<KEY,VALUE> layout;
private final IndexSamplingConfig samplingConfig;

final Set<RawCursor<Hit<KEY,VALUE>,IOException>> openSeekers;
protected final SchemaIndexDescriptor descriptor;
private final GBPTree<KEY,VALUE> tree;
private final IndexSamplingConfig samplingConfig;

NativeSchemaIndexReader( GBPTree<KEY,VALUE> tree, Layout<KEY,VALUE> layout,
IndexSamplingConfig samplingConfig,
Expand Down
Expand Up @@ -25,6 +25,7 @@
import org.neo4j.collection.primitive.PrimitiveIntCollections;
import org.neo4j.function.ThrowingConsumer;
import org.neo4j.function.ThrowingFunction;
import org.neo4j.helpers.Exceptions;
import org.neo4j.kernel.api.index.IndexProvider;

/**
Expand Down Expand Up @@ -125,17 +126,9 @@ public static <T, E extends Exception> void forAll( ThrowingConsumer<T,E> consum
{
consumer.accept( subject );
}
catch ( Exception caught )
catch ( Exception e )
{
E castedException = (E) caught;
if ( exception == null )
{
exception = castedException;
}
else
{
exception.addSuppressed( castedException );
}
exception = Exceptions.chain( exception, (E) e );
}
}
if ( exception != null )
Expand Down
Expand Up @@ -26,6 +26,7 @@
import org.neo4j.graphdb.Resource;
import org.neo4j.internal.kernel.api.IndexOrder;
import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.internal.kernel.api.IndexQuery.ExistsPredicate;
import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException;
import org.neo4j.kernel.api.schema.index.SchemaIndexDescriptor;
import org.neo4j.kernel.impl.api.schema.BridgingIndexProgressor;
Expand Down Expand Up @@ -113,8 +114,10 @@ public boolean hasFullValuePrecision( IndexQuery... predicates )
IndexReader instance = selector.select( instances, predicates );
if ( instance == null )
{
assert predicates.length == 1 && predicates[0] instanceof IndexQuery.ExistsPredicate :
"Unexpected selector result for predicates " + Arrays.toString( predicates );
if ( !(predicates.length == 1 && predicates[0] instanceof ExistsPredicate) )
{
throw new IllegalStateException( "Selected IndexReader null for predicates " + Arrays.toString( predicates ) );
}
// null means ExistsPredicate and we don't care about
// full value precision for that, therefor true.
return true;
Expand Down
Expand Up @@ -20,10 +20,12 @@
package org.neo4j.kernel.impl.index.schema.fusion;

import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.internal.kernel.api.IndexQuery.RangePredicate;
import org.neo4j.storageengine.api.schema.IndexReader;
import org.neo4j.values.storable.Value;
import org.neo4j.values.storable.Values;

import static org.neo4j.internal.kernel.api.IndexQuery.*;
import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.LUCENE;
import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.SPATIAL;
import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.TEMPORAL;
Expand Down Expand Up @@ -73,13 +75,13 @@ public IndexReader select( IndexReader[] instances, IndexQuery... predicates )
}
IndexQuery predicate = predicates[0];

if ( predicate instanceof IndexQuery.ExactPredicate )
if ( predicate instanceof ExactPredicate )
{
IndexQuery.ExactPredicate exactPredicate = (IndexQuery.ExactPredicate) predicate;
ExactPredicate exactPredicate = (ExactPredicate) predicate;
return select( instances, exactPredicate.value() );
}

if ( predicate instanceof IndexQuery.RangePredicate )
if ( predicate instanceof RangePredicate )
{
switch ( predicate.valueGroup() )
{
Expand All @@ -95,7 +97,7 @@ public IndexReader select( IndexReader[] instances, IndexQuery... predicates )
default: // fall through
}
}
if ( predicate instanceof IndexQuery.ExistsPredicate )
if ( predicate instanceof ExistsPredicate )
{
return null;
}
Expand Down
Expand Up @@ -26,6 +26,7 @@
import org.neo4j.values.storable.ValueGroup;
import org.neo4j.values.storable.Values;

import static org.neo4j.internal.kernel.api.IndexQuery.*;
import static org.neo4j.internal.kernel.api.IndexQuery.ExactPredicate;
import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.LUCENE;
import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.NUMBER;
Expand Down Expand Up @@ -89,7 +90,7 @@ public IndexReader select( IndexReader[] instances, IndexQuery... predicates )
return select( instances, exactPredicate.value() );
}

if ( predicate instanceof IndexQuery.RangePredicate )
if ( predicate instanceof RangePredicate )
{
switch ( predicate.valueGroup() )
{
Expand Down
Expand Up @@ -25,6 +25,7 @@
import org.neo4j.values.storable.ValueGroup;
import org.neo4j.values.storable.Values;

import static org.neo4j.internal.kernel.api.IndexQuery.*;
import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.LUCENE;
import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.NUMBER;
import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.SPATIAL;
Expand Down Expand Up @@ -85,18 +86,18 @@ public IndexReader select( IndexReader[] instances, IndexQuery... predicates )
}
IndexQuery predicate = predicates[0];

if ( predicate instanceof IndexQuery.ExactPredicate )
if ( predicate instanceof ExactPredicate )
{
IndexQuery.ExactPredicate exactPredicate = (IndexQuery.ExactPredicate) predicate;
ExactPredicate exactPredicate = (ExactPredicate) predicate;
return select( instances, exactPredicate.value() );
}

if ( predicate instanceof IndexQuery.StringPredicate )
if ( predicate instanceof StringPredicate )
{
return instances[STRING];
}

if ( predicate instanceof IndexQuery.RangePredicate )
if ( predicate instanceof RangePredicate )
{
switch ( predicate.valueGroup() )
{
Expand All @@ -116,7 +117,7 @@ public IndexReader select( IndexReader[] instances, IndexQuery... predicates )
default: // fall through
}
}
if ( predicate instanceof IndexQuery.ExistsPredicate )
if ( predicate instanceof ExistsPredicate )
{
return null;
}
Expand Down

0 comments on commit e3c5d4f

Please sign in to comment.