Skip to content

Commit

Permalink
Pulls out record format into RecordFormat
Browse files Browse the repository at this point in the history
also adds randomized tests to all current records, with ability to easily add
other formats to that test suite.

During testing a RelationshipGroup format issue was found and fixed.

Simpler and finally pluggable record format
  • Loading branch information
tinwelint committed Feb 1, 2016
1 parent cab9968 commit 4d7803a
Show file tree
Hide file tree
Showing 89 changed files with 2,661 additions and 1,100 deletions.
Expand Up @@ -36,7 +36,7 @@ class DynamicRecordCheck

DynamicRecordCheck( RecordStore<DynamicRecord> store, DynamicStore dereference )
{
this.blockSize = store.getRecordSize() - store.getRecordHeaderSize();
this.blockSize = store.getRecordDataSize();
this.dereference = dereference;
this.store = store;
}
Expand Down
Expand Up @@ -24,9 +24,9 @@
import org.junit.runners.JUnit4;
import org.junit.runners.Suite;

import org.neo4j.kernel.impl.store.AbstractDynamicStore;
import org.neo4j.kernel.impl.store.RecordStore;
import org.neo4j.kernel.impl.store.SchemaStore;
import org.neo4j.kernel.impl.store.format.current.DynamicRecordFormat;
import org.neo4j.kernel.impl.store.record.DynamicRecord;
import org.neo4j.legacy.consistency.report.ConsistencyReport;

Expand Down Expand Up @@ -330,8 +330,8 @@ public static RecordStore<DynamicRecord> configureDynamicStore( int blockSize )
{
@SuppressWarnings( "unchecked" )
RecordStore<DynamicRecord> mock = mock( RecordStore.class );
when( mock.getRecordSize() ).thenReturn( blockSize + AbstractDynamicStore.RECORD_HEADER_SIZE );
when( mock.getRecordHeaderSize() ).thenReturn( AbstractDynamicStore.RECORD_HEADER_SIZE );
when( mock.getRecordSize() ).thenReturn( blockSize + DynamicRecordFormat.RECORD_HEADER_SIZE );
when( mock.getRecordDataSize() ).thenReturn( blockSize );
return mock;
}
}
Expand Up @@ -34,7 +34,7 @@ public class DynamicRecordCheck

public DynamicRecordCheck( RecordStore<DynamicRecord> store, DynamicStore dereference )
{
this.blockSize = store.getRecordSize() - store.getRecordHeaderSize();
this.blockSize = store.getRecordDataSize();
this.dereference = dereference;
}

Expand Down
Expand Up @@ -25,9 +25,9 @@
import org.junit.runners.Suite;

import org.neo4j.consistency.report.ConsistencyReport;
import org.neo4j.kernel.impl.store.AbstractDynamicStore;
import org.neo4j.kernel.impl.store.RecordStore;
import org.neo4j.kernel.impl.store.SchemaStore;
import org.neo4j.kernel.impl.store.format.current.DynamicRecordFormat;
import org.neo4j.kernel.impl.store.record.DynamicRecord;

import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -271,8 +271,8 @@ public static RecordStore<DynamicRecord> configureDynamicStore( int blockSize )
{
@SuppressWarnings( "unchecked" )
RecordStore<DynamicRecord> mock = mock( RecordStore.class );
when( mock.getRecordSize() ).thenReturn( blockSize + AbstractDynamicStore.RECORD_HEADER_SIZE );
when( mock.getRecordHeaderSize() ).thenReturn( AbstractDynamicStore.RECORD_HEADER_SIZE );
when( mock.getRecordSize() ).thenReturn( blockSize + DynamicRecordFormat.RECORD_HEADER_SIZE );
when( mock.getRecordDataSize() ).thenReturn( blockSize );
return mock;
}
}
Expand Up @@ -90,6 +90,7 @@
import org.neo4j.kernel.impl.store.MetaDataStore;
import org.neo4j.kernel.impl.store.StoreId;
import org.neo4j.kernel.impl.store.UnderlyingStorageException;
import org.neo4j.kernel.impl.store.format.current.Current;
import org.neo4j.kernel.impl.store.id.IdGeneratorFactory;
import org.neo4j.kernel.impl.storemigration.DatabaseMigrator;
import org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor;
Expand Down Expand Up @@ -561,7 +562,8 @@ private StorageEngine buildStorageEngine(
new RecordStorageEngine( storeDir, config, idGeneratorFactory, pageCache, fs, logProvider, propertyKeyTokenHolder,
labelTokens, relationshipTypeTokens, schemaStateChangeCallback, constraintSemantics, scheduler,
tokenNameLookup, lockService, schemaIndexProvider, indexingServiceMonitor, databaseHealth,
labelScanStore, legacyIndexProviderLookup, indexConfigStore, legacyIndexTransactionOrdering ) );
labelScanStore, legacyIndexProviderLookup, indexConfigStore, legacyIndexTransactionOrdering,
Current.RECORD_FORMATS ) );
}

private TransactionLogModule buildTransactionLogs(
Expand Down
Expand Up @@ -30,10 +30,10 @@
import org.neo4j.kernel.impl.store.DynamicArrayStore;
import org.neo4j.kernel.impl.store.DynamicStringStore;
import org.neo4j.kernel.impl.store.LongerShortString;
import org.neo4j.kernel.impl.store.PropertyStore;
import org.neo4j.kernel.impl.store.PropertyType;
import org.neo4j.kernel.impl.store.RecordCursor;
import org.neo4j.kernel.impl.store.ShortArray;
import org.neo4j.kernel.impl.store.format.current.PropertyRecordFormat;
import org.neo4j.kernel.impl.store.record.DynamicRecord;
import org.neo4j.kernel.impl.store.record.PropertyBlock;
import org.neo4j.kernel.impl.util.Bits;
Expand Down Expand Up @@ -66,7 +66,7 @@
*/
class StorePropertyPayloadCursor
{
static final int MAX_NUMBER_OF_PAYLOAD_LONG_ARRAY = PropertyStore.DEFAULT_PAYLOAD_SIZE / 8;
static final int MAX_NUMBER_OF_PAYLOAD_LONG_ARRAY = PropertyRecordFormat.DEFAULT_PAYLOAD_SIZE / 8;

private static final long PROPERTY_KEY_ID_BITMASK = 0xFFFFFFL;
private static final int MAX_BYTES_IN_SHORT_STRING_OR_SHORT_ARRAY = 32;
Expand Down
Expand Up @@ -31,7 +31,6 @@
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.pagecache.PageCache;
import org.neo4j.kernel.impl.store.id.IdGeneratorFactory;
import org.neo4j.kernel.api.TokenNameLookup;
import org.neo4j.kernel.api.exceptions.TransactionFailureException;
import org.neo4j.kernel.api.exceptions.schema.ConstraintValidationKernelException;
Expand Down Expand Up @@ -71,6 +70,8 @@
import org.neo4j.kernel.impl.store.NeoStores;
import org.neo4j.kernel.impl.store.SchemaStorage;
import org.neo4j.kernel.impl.store.StoreFactory;
import org.neo4j.kernel.impl.store.format.RecordFormats;
import org.neo4j.kernel.impl.store.id.IdGeneratorFactory;
import org.neo4j.kernel.impl.transaction.command.CacheInvalidationBatchTransactionApplier;
import org.neo4j.kernel.impl.transaction.command.HighIdBatchTransactionApplier;
import org.neo4j.kernel.impl.transaction.command.IndexBatchTransactionApplier;
Expand Down Expand Up @@ -178,7 +179,8 @@ public RecordStorageEngine(
LabelScanStoreProvider labelScanStoreProvider,
LegacyIndexProviderLookup legacyIndexProviderLookup,
IndexConfigStore indexConfigStore,
IdOrderingQueue legacyIndexTransactionOrdering )
IdOrderingQueue legacyIndexTransactionOrdering,
RecordFormats recordFormats )
{
this.propertyKeyTokenHolder = propertyKeyTokenHolder;
this.relationshipTypeTokenHolder = relationshipTypeTokens;
Expand All @@ -191,7 +193,8 @@ public RecordStorageEngine(
this.constraintSemantics = constraintSemantics;
this.legacyIndexTransactionOrdering = legacyIndexTransactionOrdering;

final StoreFactory storeFactory = new StoreFactory( storeDir, config, idGeneratorFactory, pageCache, fs, logProvider );
final StoreFactory storeFactory = new StoreFactory( storeDir, config, idGeneratorFactory,
pageCache, fs, logProvider, recordFormats );
neoStores = storeFactory.openAllNeoStores( true );

try
Expand Down

0 comments on commit 4d7803a

Please sign in to comment.