Skip to content

Commit

Permalink
Cleanup unnecessary line breaks and class member ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen authored and ragadeeshu committed May 21, 2018
1 parent baae074 commit a5ef509
Show file tree
Hide file tree
Showing 41 changed files with 126 additions and 230 deletions.
Expand Up @@ -34,6 +34,42 @@
*/
public interface IndexReference extends IndexCapability
{
/**
* Sorts indexes by type, returning first GENERAL indexes, followed by UNIQUE. Implementation is not suitable in
* hot path.
*
* @param indexes Indexes to sort
* @return sorted indexes
*/
static Iterator<IndexReference> sortByType( Iterator<IndexReference> indexes )
{
List<IndexReference> materialized = Iterators.asList( indexes );
return Iterators.concat(
Iterators.filter( i -> !i.isUnique(), materialized.iterator() ),
Iterators.filter( IndexReference::isUnique, materialized.iterator() ) );

}

boolean isUnique();

int label();

int[] properties();

String providerKey();

String providerVersion();

/**
* @param tokenNameLookup used for looking up names for token ids.
* @return a user friendly description of what this index indexes.
*/
default String userDescription( TokenNameLookup tokenNameLookup )
{
String type = isUnique() ? "UNIQUE" : "GENERAL";
return format( "Index( %s, %s )", type, SchemaUtil.niceProperties( tokenNameLookup, properties() ) );
}

IndexReference NO_INDEX = new IndexReference()
{
@Override
Expand Down Expand Up @@ -78,40 +114,4 @@ public String providerVersion()
return null;
}
};

/**
* Sorts indexes by type, returning first GENERAL indexes, followed by UNIQUE. Implementation is not suitable in
* hot path.
*
* @param indexes Indexes to sort
* @return sorted indexes
*/
static Iterator<IndexReference> sortByType( Iterator<IndexReference> indexes )
{
List<IndexReference> materialized = Iterators.asList( indexes );
return Iterators.concat(
Iterators.filter( i -> !i.isUnique(), materialized.iterator() ),
Iterators.filter( IndexReference::isUnique, materialized.iterator() ) );

}

boolean isUnique();

int label();

int[] properties();

String providerKey();

String providerVersion();

/**
* @param tokenNameLookup used for looking up names for token ids.
* @return a user friendly description of what this index indexes.
*/
default String userDescription( TokenNameLookup tokenNameLookup )
{
String type = isUnique() ? "UNIQUE" : "GENERAL";
return format( "Index( %s, %s )", type, SchemaUtil.niceProperties( tokenNameLookup, properties() ) );
}
}
Expand Up @@ -173,8 +173,7 @@ public long createUniquenessConstraintIndex( KernelTransactionImplementation tra
}
}

private boolean indexStillExists( SchemaRead schemaRead, SchemaDescriptor descriptor,
IndexReference index )
private boolean indexStillExists( SchemaRead schemaRead, SchemaDescriptor descriptor, IndexReference index )
{
IndexReference existingIndex = schemaRead.index( descriptor.keyId(), descriptor.getPropertyIds() );
return existingIndex != IndexReference.NO_INDEX && existingIndex.equals( index );
Expand Down
Expand Up @@ -190,8 +190,7 @@ private static class SchemaCacheState
private final Map<Class<?>,Object> dependantState;
private final MutableIntObjectMap<List<CapableIndexDescriptor>> indexByProperty;

SchemaCacheState( ConstraintSemantics constraintSemantics, Iterable<SchemaRule> rules,
IndexProviderMap indexProviderMap )
SchemaCacheState( ConstraintSemantics constraintSemantics, Iterable<SchemaRule> rules, IndexProviderMap indexProviderMap )
{
this.constraintSemantics = constraintSemantics;
this.indexProviderMap = indexProviderMap;
Expand Down
Expand Up @@ -31,8 +31,8 @@
import org.neo4j.io.pagecache.PageCache;
import org.neo4j.io.pagecache.PageCursor;
import org.neo4j.kernel.api.index.IndexProvider;
import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor;
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor;

import static org.neo4j.helpers.Format.duration;
import static org.neo4j.helpers.collection.MapUtil.map;
Expand Down
Expand Up @@ -888,10 +888,7 @@ public IndexReference indexCreate( SchemaDescriptor descriptor,
assertIndexDoesNotExist( SchemaKernelException.OperationContext.INDEX_CREATION, descriptor );

IndexProvider.Descriptor providerDescriptor = ktx.indexProviderForOrDefault( provider );
IndexDescriptor index =
IndexDescriptorFactory.forSchema( descriptor,
name,
providerDescriptor );
IndexDescriptor index = IndexDescriptorFactory.forSchema( descriptor, name, providerDescriptor );
ktx.txState().indexDoAdd( index );
return index;
}
Expand Down
Expand Up @@ -307,8 +307,7 @@ public Long indexGetOwningUniquenessConstraintId( IndexDescriptor index )
}

@Override
public long indexGetCommittedId( IndexDescriptor index )
throws SchemaRuleNotFoundException
public long indexGetCommittedId( IndexDescriptor index ) throws SchemaRuleNotFoundException
{
StoreIndexDescriptor storeIndexDescriptor = getStoreIndexDescriptor( index );
if ( storeIndexDescriptor == null )
Expand Down
Expand Up @@ -469,10 +469,8 @@ private void validateRelationshipConstraintCanBeCreated( int relTypeId, int prop
private void createIndex( int labelId, int[] propertyKeyIds )
{
LabelSchemaDescriptor schema = SchemaDescriptorFactory.forLabel( labelId, propertyKeyIds );
StoreIndexDescriptor schemaRule =
IndexDescriptorFactory
.forSchema( schema, Optional.empty(), indexProviderMap.getDefaultProvider().getProviderDescriptor() )
.withId( schemaStore.nextId() );
IndexProvider.Descriptor providerDescriptor = indexProviderMap.getDefaultProvider().getProviderDescriptor();
StoreIndexDescriptor schemaRule = IndexDescriptorFactory.forSchema( schema, Optional.empty(), providerDescriptor ).withId( schemaStore.nextId() );

for ( DynamicRecord record : schemaStore.allocateFrom( schemaRule ) )
{
Expand Down Expand Up @@ -609,18 +607,10 @@ private void createUniqueIndexAndOwningConstraint( LabelSchemaDescriptor schema,
long indexId = schemaStore.nextId();
long constraintRuleId = schemaStore.nextId();

StoreIndexDescriptor storeIndexDescriptor =
IndexDescriptorFactory.uniqueForSchema(
schema,
this.indexProviderMap.getDefaultProvider().getProviderDescriptor()
).withIds( indexId, constraintRuleId );

ConstraintRule constraintRule =
ConstraintRule.constraintRule(
constraintRuleId,
constraintDescriptor,
indexId
);
IndexProvider.Descriptor providerDescriptor = this.indexProviderMap.getDefaultProvider().getProviderDescriptor();
StoreIndexDescriptor storeIndexDescriptor = IndexDescriptorFactory.uniqueForSchema( schema, providerDescriptor ).withIds( indexId, constraintRuleId );

ConstraintRule constraintRule = ConstraintRule.constraintRule( constraintRuleId, constraintDescriptor, indexId );

for ( DynamicRecord record : schemaStore.allocateFrom( constraintRule ) )
{
Expand Down
Expand Up @@ -43,8 +43,7 @@
" errors or warnings in some IDEs about test classes needing a public zero-arg constructor." )
public abstract class CompositeIndexAccessorCompatibility extends IndexAccessorCompatibility
{
public CompositeIndexAccessorCompatibility(
IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor )
public CompositeIndexAccessorCompatibility( IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor )
{
super( testSuite, descriptor );
}
Expand Down
Expand Up @@ -49,8 +49,7 @@
" errors or warnings in some IDEs about test classes needing a public zero-arg constructor." )
public class CompositeIndexPopulatorCompatibility extends IndexProviderCompatibilityTestSuite.Compatibility
{
public CompositeIndexPopulatorCompatibility(
IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor )
public CompositeIndexPopulatorCompatibility( IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor )
{
super( testSuite, descriptor );
}
Expand Down
Expand Up @@ -66,8 +66,7 @@
" errors or warnings in some IDEs about test classes needing a public zero-arg constructor." )
public abstract class SimpleIndexAccessorCompatibility extends IndexAccessorCompatibility
{
public SimpleIndexAccessorCompatibility( IndexProviderCompatibilityTestSuite testSuite,
IndexDescriptor descriptor )
public SimpleIndexAccessorCompatibility( IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor )
{
super( testSuite, descriptor );
}
Expand Down
Expand Up @@ -63,8 +63,7 @@
" errors or warnings in some IDEs about test classes needing a public zero-arg constructor." )
public class SimpleIndexPopulatorCompatibility extends IndexProviderCompatibilityTestSuite.Compatibility
{
public SimpleIndexPopulatorCompatibility(
IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor )
public SimpleIndexPopulatorCompatibility( IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor )
{
super( testSuite, descriptor );
}
Expand Down
Expand Up @@ -414,8 +414,7 @@ private void givenIndex( String label, String propKey )
int labelId = token( label, labels );
int propId = token( propKey, propKeys );

IndexReference index =
IndexDescriptorFactory.forSchema( forLabel( labelId, propId ), InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR );
IndexReference index = IndexDescriptorFactory.forSchema( forLabel( labelId, propId ), InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR );
indexes.add( index );
}

Expand All @@ -424,8 +423,7 @@ private void givenUniqueConstraint( String label, String propKey )
int labelId = token( label, labels );
int propId = token( propKey, propKeys );

IndexReference index =
IndexDescriptorFactory.uniqueForSchema( forLabel( labelId, propId ), InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR );
IndexReference index = IndexDescriptorFactory.uniqueForSchema( forLabel( labelId, propId ), InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR );
uniqueIndexes.add( index );
constraints.add( ConstraintDescriptorFactory.uniqueForLabel( labelId, propId ) );
}
Expand Down
Expand Up @@ -33,10 +33,8 @@
import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.kernel.api.index.IndexPopulator;
import org.neo4j.kernel.api.index.IndexProvider;
import org.neo4j.kernel.api.index.IndexUpdater;
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor;
import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory;
import org.neo4j.kernel.impl.locking.LockService;
import org.neo4j.kernel.impl.store.NeoStores;
Expand Down
Expand Up @@ -40,7 +40,6 @@ NativeSchemaIndexAccessor<LocalDateTimeSchemaKey,NativeSchemaValue> makeAccessor
@Override
protected LayoutTestUtil<LocalDateTimeSchemaKey,NativeSchemaValue> createLayoutTestUtil()
{
return new UniqueLayoutTestUtil<>( new LocalDateTimeLayoutTestUtil( TestIndexDescriptorFactory
.uniqueForLabel( 42, 666 ) ) );
return new UniqueLayoutTestUtil<>( new LocalDateTimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) );
}
}
Expand Up @@ -36,7 +36,6 @@ NativeSchemaIndexPopulator<LocalTimeSchemaKey,NativeSchemaValue> createPopulator
@Override
protected LayoutTestUtil<LocalTimeSchemaKey,NativeSchemaValue> createLayoutTestUtil()
{
return new UniqueLayoutTestUtil<>(
new LocalTimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) );
return new UniqueLayoutTestUtil<>( new LocalTimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) );
}
}
Expand Up @@ -206,8 +206,8 @@ public void shouldHandleRandomUpdates() throws Exception
for ( int round = 0; round < rounds; round++ )
{
// generate a batch of updates (add, change, remove)
IndexEntryUpdate<IndexDescriptor>[] batch = generateRandomUpdates( expectedData, newDataGenerator,
random.nextInt( 5, 20 ), (float) round / rounds * 2 );
IndexEntryUpdate<IndexDescriptor>[] batch =
generateRandomUpdates( expectedData, newDataGenerator, random.nextInt( 5, 20 ), (float) round / rounds * 2 );
// apply to tree
processAll( batch );
// apply to expectedData
Expand Down
Expand Up @@ -26,14 +26,11 @@

import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor;
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.values.storable.NumberValue;
import org.neo4j.values.storable.RandomValues;
import org.neo4j.values.storable.Value;

import static org.neo4j.kernel.impl.api.index.TestIndexProviderDescriptor.PROVIDER_DESCRIPTOR;

abstract class NumberLayoutTestUtil extends LayoutTestUtil<NumberSchemaKey,NativeSchemaValue>
{
private static final Number[] ALL_EXTREME_VALUES = new Number[]
Expand Down
Expand Up @@ -28,7 +28,6 @@
import org.neo4j.index.internal.gbptree.Layout;
import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor;
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettings;
import org.neo4j.values.storable.CoordinateReferenceSystem;
Expand All @@ -37,7 +36,6 @@
import org.neo4j.values.storable.Value;
import org.neo4j.values.storable.Values;

import static org.neo4j.kernel.impl.api.index.TestIndexProviderDescriptor.PROVIDER_DESCRIPTOR;
import static org.neo4j.values.storable.CoordinateReferenceSystem.WGS84;

public class SpatialLayoutTestUtil extends LayoutTestUtil<SpatialSchemaKey,NativeSchemaValue>
Expand Down
Expand Up @@ -40,8 +40,7 @@ public class SpatialNonUniqueSchemaIndexPopulatorTest extends NativeNonUniqueSch
NativeSchemaIndexPopulator<SpatialSchemaKey,NativeSchemaValue> createPopulator( IndexSamplingConfig samplingConfig )
{
fileLayout = new SpatialIndexFiles.SpatialFileLayout( crs, settings, super.getIndexFile() );
return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig,
new StandardConfiguration() );
return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig, new StandardConfiguration() );
}

@Override
Expand Down
Expand Up @@ -40,8 +40,7 @@ public class SpatialUniqueSchemaIndexPopulatorTest extends NativeUniqueSchemaInd
NativeSchemaIndexPopulator<SpatialSchemaKey,NativeSchemaValue> createPopulator( IndexSamplingConfig samplingConfig )
{
fileLayout = new SpatialIndexFiles.SpatialFileLayout( crs, settings, super.getIndexFile() );
return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig,
new StandardConfiguration() );
return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig, new StandardConfiguration() );
}

@Override
Expand Down
Expand Up @@ -29,15 +29,12 @@
import org.neo4j.index.internal.gbptree.Layout;
import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor;
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.values.storable.RandomValues;
import org.neo4j.values.storable.TimeValue;
import org.neo4j.values.storable.Value;
import org.neo4j.values.storable.Values;

import static org.neo4j.kernel.impl.api.index.TestIndexProviderDescriptor.PROVIDER_DESCRIPTOR;

public class TimeLayoutTestUtil extends LayoutTestUtil<ZonedTimeSchemaKey, NativeSchemaValue>
{
static long MAX_NANOS_PER_DAY = 86399999999999L;
Expand Down
Expand Up @@ -28,8 +28,7 @@ public class TimeNonUniqueSchemaIndexPopulatorTest extends NativeNonUniqueSchema
@Override
NativeSchemaIndexPopulator<ZonedTimeSchemaKey,NativeSchemaValue> createPopulator( IndexSamplingConfig samplingConfig )
{
TemporalIndexFiles.FileLayout<ZonedTimeSchemaKey> fileLayout =
new TemporalIndexFiles.FileLayout<>( getIndexFile(), layout, ValueGroup.ZONED_TIME );
TemporalIndexFiles.FileLayout<ZonedTimeSchemaKey> fileLayout = new TemporalIndexFiles.FileLayout<>( getIndexFile(), layout, ValueGroup.ZONED_TIME );
return new TemporalIndexPopulator.PartPopulator<>( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig );
}

Expand Down
Expand Up @@ -39,8 +39,7 @@ NativeSchemaIndexAccessor<ZonedTimeSchemaKey,NativeSchemaValue> makeAccessorWith
@Override
protected LayoutTestUtil<ZonedTimeSchemaKey,NativeSchemaValue> createLayoutTestUtil()
{
return new UniqueLayoutTestUtil<>(
new TimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) );
return new UniqueLayoutTestUtil<>( new TimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) );
}

}
Expand Up @@ -28,15 +28,13 @@ public class TimeUniqueSchemaIndexPopulatorTest extends NativeUniqueSchemaIndexP
@Override
NativeSchemaIndexPopulator<ZonedTimeSchemaKey,NativeSchemaValue> createPopulator( IndexSamplingConfig samplingConfig )
{
TemporalIndexFiles.FileLayout<ZonedTimeSchemaKey> fileLayout =
new TemporalIndexFiles.FileLayout<>( getIndexFile(), layout, ValueGroup.ZONED_TIME );
TemporalIndexFiles.FileLayout<ZonedTimeSchemaKey> fileLayout = new TemporalIndexFiles.FileLayout<>( getIndexFile(), layout, ValueGroup.ZONED_TIME );
return new TemporalIndexPopulator.PartPopulator<>( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig );
}

@Override
protected LayoutTestUtil<ZonedTimeSchemaKey,NativeSchemaValue> createLayoutTestUtil()
{
return new UniqueLayoutTestUtil<>(
new TimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) );
return new UniqueLayoutTestUtil<>( new TimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) );
}
}
Expand Up @@ -205,8 +205,7 @@ public void getPopulationFailureMustReportFailureWhenAnyFailed()
}

// then
assertThat( fusionIndexProvider.getPopulationFailure( AN_INDEX ),
containsString( failure ) );
assertThat( fusionIndexProvider.getPopulationFailure( AN_INDEX ), containsString( failure ) );
}
}

Expand Down
Expand Up @@ -122,9 +122,9 @@ private void initiateMocks()
throw new RuntimeException();
}
}
fusionIndexReader = new FusionIndexReader( fusionVersion.slotSelector(), new LazyInstanceSelector<>( readers, throwingFactory() ),
TestIndexDescriptorFactory.forLabel( LABEL_KEY, PROP_KEY ) );
}
fusionIndexReader = new FusionIndexReader( fusionVersion.slotSelector(), new LazyInstanceSelector<>( readers, throwingFactory() ),
TestIndexDescriptorFactory
.forLabel( LABEL_KEY, PROP_KEY ) );}

private IntFunction<IndexReader> throwingFactory()
{
Expand Down

0 comments on commit a5ef509

Please sign in to comment.