|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.neo4j.kernel.impl.nioneo.store.CommonAbstractStore
org.neo4j.kernel.impl.nioneo.store.AbstractDynamicStore
public abstract class AbstractDynamicStore
An abstract representation of a dynamic store. The difference between a
normal AbstractStore and a AbstractDynamicStore is
that the size of a record/entry can be dynamic.
Instead of a fixed record this class uses blocks to store a record. If a record size is greater than the block size the record will use one or more blocks to store its data.
A dynamic store don't have a IdGenerator because the position of a
record can't be calculated just by knowing the id. Instead one should use a
AbstractStore and store the start block of the record located in the
dynamic store. Note: This class makes use of an id generator internally for
managing free and non free blocks.
Note, the first block of a dynamic store is reserved and contains information about the store.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.neo4j.kernel.impl.nioneo.store.RecordStore |
|---|
RecordStore.Processor |
| Field Summary | |
|---|---|
protected static int |
BLOCK_HEADER_SIZE
|
| Fields inherited from class org.neo4j.kernel.impl.nioneo.store.CommonAbstractStore |
|---|
ALL_STORES_VERSION, logger, storageFileName, UNKNOWN_VERSION |
| Fields inherited from interface org.neo4j.kernel.impl.nioneo.store.RecordStore |
|---|
IN_USE |
| Constructor Summary | |
|---|---|
AbstractDynamicStore(String fileName,
Map<?,?> config,
IdType idType)
|
|
| Method Summary | |
|---|---|
protected Collection<DynamicRecord> |
allocateRecords(long startBlock,
byte[] src)
|
protected static void |
createEmptyStore(String fileName,
int baseBlockSize,
String typeAndVersionDescriptor,
IdGeneratorFactory idGeneratorFactory,
IdType idType)
Creates a new empty store. |
protected long |
figureOutHighestIdInUse()
|
DynamicRecord |
forceGetRaw(long id)
|
DynamicRecord |
forceGetRecord(long id)
|
void |
forceUpdateRecord(DynamicRecord record)
|
void |
freeBlockId(long blockId)
Makes a previously used block available again. |
int |
getBlockSize()
Returns the byte size of each block for this dynamic store |
protected int |
getEffectiveRecordSize()
|
Collection<DynamicRecord> |
getLightRecords(long startBlockId)
|
DynamicRecord |
getRecord(long id)
|
int |
getRecordHeaderSize()
|
Collection<DynamicRecord> |
getRecords(long startBlockId)
|
int |
getRecordSize()
|
static int |
getRecordSize(int dataSize)
Calculate the size of a dynamic record given the size of the data block. |
protected boolean |
isRecordInUse(ByteBuffer buffer)
|
void |
logIdUsage(StringLogger logger)
|
void |
makeHeavy(DynamicRecord record)
|
long |
nextBlockId()
Returns next free block. |
protected void |
readAndVerifyBlockSize()
|
protected void |
rebuildIdGenerator()
Rebuilds the internal id generator keeping track of what blocks are free or taken. |
String |
toString()
|
void |
updateRecord(DynamicRecord record)
|
protected void |
verifyFileSizeAndTruncate()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.neo4j.kernel.impl.nioneo.store.Store |
|---|
getHighestPossibleIdInUse, getNumberOfIdsInUse, getTypeDescriptor, getWindowPoolStats, nextId |
| Methods inherited from interface org.neo4j.kernel.impl.nioneo.store.RecordStore |
|---|
accept, close, getHighId |
| Field Detail |
|---|
protected static final int BLOCK_HEADER_SIZE
| Constructor Detail |
|---|
public AbstractDynamicStore(String fileName,
Map<?,?> config,
IdType idType)
| Method Detail |
|---|
protected static void createEmptyStore(String fileName,
int baseBlockSize,
String typeAndVersionDescriptor,
IdGeneratorFactory idGeneratorFactory,
IdType idType)
AbstractDynamicStore.BLOCK_HEADER_SIZE
bytes.
This method will create a empty store with descriptor returned by the
CommonAbstractStore.getTypeDescriptor(). The internal id generator used by
this store will also be created.
fileName - The file name of the store that will be createdblockSize - The number of bytes for each blocktypeAndVersionDescriptor - The type and version descriptor that identifies this store
IOException - If fileName is null or if file exists or illegal block sizeprotected int getEffectiveRecordSize()
getEffectiveRecordSize in class CommonAbstractStorepublic int getRecordSize()
getRecordSize in interface RecordStore<DynamicRecord>public int getRecordHeaderSize()
getRecordHeaderSize in interface RecordStore<DynamicRecord>
protected void verifyFileSizeAndTruncate()
throws IOException
verifyFileSizeAndTruncate in class CommonAbstractStoreIOException
protected void readAndVerifyBlockSize()
throws IOException
readAndVerifyBlockSize in class CommonAbstractStoreIOExceptionpublic int getBlockSize()
public long nextBlockId()
IOException - If capacity exceeded or closed id generatorpublic void freeBlockId(long blockId)
blockId - The id of the block to free
IOException - If id generator closed or illegal block idpublic static int getRecordSize(int dataSize)
dataSize - the size of the data block in bytes.
public void updateRecord(DynamicRecord record)
updateRecord in interface RecordStore<DynamicRecord>public void forceUpdateRecord(DynamicRecord record)
forceUpdateRecord in interface RecordStore<DynamicRecord>
protected Collection<DynamicRecord> allocateRecords(long startBlock,
byte[] src)
public Collection<DynamicRecord> getLightRecords(long startBlockId)
public void makeHeavy(DynamicRecord record)
protected boolean isRecordInUse(ByteBuffer buffer)
public DynamicRecord getRecord(long id)
getRecord in interface RecordStore<DynamicRecord>public DynamicRecord forceGetRecord(long id)
forceGetRecord in interface RecordStore<DynamicRecord>public DynamicRecord forceGetRaw(long id)
forceGetRaw in interface RecordStore<DynamicRecord>public Collection<DynamicRecord> getRecords(long startBlockId)
protected void rebuildIdGenerator()
rebuildIdGenerator in class CommonAbstractStoreIOException - If unable to rebuild the id generatorprotected long figureOutHighestIdInUse()
figureOutHighestIdInUse in class CommonAbstractStorepublic void logIdUsage(StringLogger logger)
logIdUsage in interface Storepublic String toString()
toString in class CommonAbstractStore
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||