|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjhplot.io.BaseRecordsFile
public abstract class BaseRecordsFile
| Field Summary | |
|---|---|
protected static long |
DATA_START_HEADER_LOCATION
|
protected long |
dataStartPtr
|
protected static int |
FILE_HEADERS_REGION_LENGTH
|
protected static int |
INDEX_ENTRY_LENGTH
|
protected static int |
MAX_KEY_LENGTH
|
protected static long |
NUM_RECORDS_HEADER_LOCATION
|
protected static int |
RECORD_HEADER_LENGTH
|
| Constructor Summary | |
|---|---|
protected |
BaseRecordsFile(String dbPath,
int initialSize)
Creates a new database file, initializing the appropriate headers. |
protected |
BaseRecordsFile(String dbPath,
String accessFlags)
Opens an existing database file and initializes the dataStartPtr. |
| Method Summary | |
|---|---|
protected void |
addEntryToIndex(String key,
RecordHeader newRecord,
int currentNumRecords)
Appends an entry to end of index. |
protected abstract RecordHeader |
allocateRecord(String key,
int dataLength)
Locates space for a new record of dataLength size and initializes a RecordHeader. |
void |
close()
Closes the file. |
protected void |
deleteEntryFromIndex(String key,
RecordHeader header,
int currentNumRecords)
Removes the record from the index. |
void |
deleteRecord(String key)
Deletes a record. |
abstract Enumeration |
enumerateKeys()
Returns an Enumeration of the keys of all records in the database. |
protected long |
getFileLength()
|
abstract int |
getNumRecords()
Returns the number or records in the database. |
protected abstract RecordHeader |
getRecordAt(long targetFp)
Returns the record to which the target file pointer belongs - meaning the specified location in the file is part of the record data of the RecordHeader which is returned. |
protected long |
indexPositionToKeyFp(int pos)
Returns a file pointer in the index pointing to the first byte in the key located at the given index position. |
void |
insertRecord(RecordWriter rw)
Adds the given record to the database. |
protected void |
insureIndexSpace(int requiredNumRecords)
|
protected abstract RecordHeader |
keyToRecordHeader(String key)
Maps a key to a record header. |
protected long |
readDataStartHeader()
Reads the data start pointer header from the file. |
protected int |
readNumRecordsHeader()
Reads the number of records header from the file. |
RecordReader |
readRecord(String key)
Reads a record. |
protected byte[] |
readRecordData(RecordHeader header)
Reads the record data for the given record header. |
protected byte[] |
readRecordData(String key)
Reads the data for the record with the given key. |
abstract boolean |
recordExists(String key)
Checks there is a record with the given key. |
protected void |
setFileLength(long l)
|
void |
updateRecord(RecordWriter rw)
Updates an existing record. |
protected void |
writeDataStartPtrHeader(long dataStartPtr)
Writes the data start pointer header to the file. |
protected void |
writeNumRecordsHeader(int numRecords)
Writes the number of records header to the file. |
protected void |
writeRecordData(RecordHeader header,
byte[] data)
Updates the contents of the given record. |
protected void |
writeRecordData(RecordHeader header,
RecordWriter rw)
Updates the contents of the given record. |
protected void |
writeRecordHeaderToIndex(RecordHeader header)
Writes the ith record header to the index. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected long dataStartPtr
protected static final int FILE_HEADERS_REGION_LENGTH
protected static final int RECORD_HEADER_LENGTH
protected static final int MAX_KEY_LENGTH
protected static final int INDEX_ENTRY_LENGTH
protected static final long NUM_RECORDS_HEADER_LOCATION
protected static final long DATA_START_HEADER_LOCATION
| Constructor Detail |
|---|
protected BaseRecordsFile(String dbPath,
int initialSize)
throws IOException,
RecordsFileException
IOException
RecordsFileException
protected BaseRecordsFile(String dbPath,
String accessFlags)
throws IOException,
RecordsFileException
IOException
RecordsFileException| Method Detail |
|---|
public abstract Enumeration enumerateKeys()
public abstract int getNumRecords()
public abstract boolean recordExists(String key)
protected abstract RecordHeader keyToRecordHeader(String key)
throws RecordsFileException
RecordsFileException
protected abstract RecordHeader allocateRecord(String key,
int dataLength)
throws RecordsFileException,
IOException
RecordsFileException
IOException
protected abstract RecordHeader getRecordAt(long targetFp)
throws RecordsFileException
RecordsFileException
protected long getFileLength()
throws IOException
IOException
protected void setFileLength(long l)
throws IOException
IOException
protected int readNumRecordsHeader()
throws IOException
IOException
protected void writeNumRecordsHeader(int numRecords)
throws IOException
IOException
protected long readDataStartHeader()
throws IOException
IOException
protected void writeDataStartPtrHeader(long dataStartPtr)
throws IOException
IOExceptionprotected long indexPositionToKeyFp(int pos)
protected void writeRecordHeaderToIndex(RecordHeader header)
throws IOException
IOException
protected void addEntryToIndex(String key,
RecordHeader newRecord,
int currentNumRecords)
throws IOException,
RecordsFileException
IOException
RecordsFileException
protected void deleteEntryFromIndex(String key,
RecordHeader header,
int currentNumRecords)
throws IOException,
RecordsFileException
IOException
RecordsFileException
public void insertRecord(RecordWriter rw)
throws RecordsFileException,
IOException
RecordsFileException
IOException
public void updateRecord(RecordWriter rw)
throws RecordsFileException,
IOException
RecordsFileException
IOException
public RecordReader readRecord(String key)
throws RecordsFileException,
IOException
RecordsFileException
IOException
protected byte[] readRecordData(String key)
throws IOException,
RecordsFileException
IOException
RecordsFileException
protected byte[] readRecordData(RecordHeader header)
throws IOException
IOException
protected void writeRecordData(RecordHeader header,
RecordWriter rw)
throws IOException,
RecordsFileException
IOException
RecordsFileException
protected void writeRecordData(RecordHeader header,
byte[] data)
throws IOException,
RecordsFileException
IOException
RecordsFileException
public void deleteRecord(String key)
throws RecordsFileException,
IOException
RecordsFileException
IOException
protected void insureIndexSpace(int requiredNumRecords)
throws RecordsFileException,
IOException
RecordsFileException
IOException
public void close()
throws IOException,
RecordsFileException
IOException
RecordsFileException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||