/** * {@inheritDoc} */ public void close() { objectStore.close(); indexStore.close(); } }
/** * {@inheritDoc} */ @Override public void complete() { objectStore.complete(); indexStore.complete(); }
/** * Adds the specified object to the store. * * @param data * The object to be added. */ public void add(T data) { objectStore.add(data); chunkObjectCount++; if (!chunkInProgress) { // Write the file index of the new chunk. indexStore.write(new LongLongIndexElement((chunkCount * 2), newChunkFilePosition)); chunkInProgress = true; } }
/** * Creates a new instance. * * @param serializationFactory * The factory defining the object serialisation implementation. * @param tmpFilePrefix * The prefix of the storage file. */ public IndexedObjectStore(ObjectSerializationFactory serializationFactory, String tmpFilePrefix) { objectStore = new RandomAccessObjectStore<T>(serializationFactory, tmpFilePrefix + "d"); indexStore = new IndexStore<Long, LongLongIndexElement>( LongLongIndexElement.class, new ComparableComparator<Long>(), tmpFilePrefix + "i" ); }
IndexedObjectStoreReader<T> reader; indexStoreReader = indexStore.createReader();
/** * Creates a new instance. * * @param serializationFactory * The factory defining the object serialisation implementation. * @param tmpFilePrefix * The prefix of the storage file. */ public IndexedObjectStore(ObjectSerializationFactory serializationFactory, String tmpFilePrefix) { objectStore = new RandomAccessObjectStore<T>(serializationFactory, tmpFilePrefix + "d"); indexStore = new IndexStore<Long, LongLongIndexElement>( LongLongIndexElement.class, new ComparableComparator<Long>(), tmpFilePrefix + "i" ); }
IndexedObjectStoreReader<T> reader; indexStoreReader = indexStore.createReader();
/** * Adds the specified object to the store. * * @param id * The identifier allowing the object to be retrieved. * @param data * The object to be added. */ public void add(long id, T data) { long objectOffset; // Write the object to the object store. objectOffset = objectStore.add(data); // Write the object offset keyed by the id to the index store. indexStore.write(new LongLongIndexElement(id, objectOffset)); }
/** * Creates a new instance. * * @param serializationFactory * The factory defining the object serialisation implementation. * @param objectStorageFile * The storage file to use for objects. * @param indexStorageFile * The storage file to use for the index. */ public IndexedObjectStore( ObjectSerializationFactory serializationFactory, File objectStorageFile, File indexStorageFile) { objectStore = new RandomAccessObjectStore<T>(serializationFactory, objectStorageFile); indexStore = new IndexStore<Long, LongLongIndexElement>( LongLongIndexElement.class, new ComparableComparator<Long>(), indexStorageFile ); }
/** * {@inheritDoc} */ public void close() { objectStore.close(); indexStore.close(); } }
/** * {@inheritDoc} */ @Override public void complete() { // Any outstanding chunks must be closed before we can complete. closeChunk(); indexStore.complete(); }
/** * Provides access to the contents of this store. * * @param chunk * The chunk to read objects from. * @return An iterator providing access to contents of the store. */ public ReleasableIterator<T> iterate(long chunk) { complete(); if (indexStoreReader == null) { indexStoreReader = indexStore.createReader(); } // Retrieve the file position and number of objects for the specified // chunk and iterate. return objectStore.iterate( indexStoreReader.get(chunk * 2).getValue(), indexStoreReader.get(chunk * 2 + 1).getValue() ); }
/** * Adds the specified object to the store. * * @param id * The identifier allowing the object to be retrieved. * @param data * The object to be added. */ public void add(long id, T data) { long objectOffset; // Write the object to the object store. objectOffset = objectStore.add(data); // Write the object offset keyed by the id to the index store. indexStore.write(new LongLongIndexElement(id, objectOffset)); }
/** * Creates a new instance. * * @param serializationFactory * The factory defining the object serialisation implementation. * @param objectStorageFile * The storage file to use for objects. * @param indexStorageFile * The storage file to use for the index. */ public IndexedObjectStore( ObjectSerializationFactory serializationFactory, File objectStorageFile, File indexStorageFile) { objectStore = new RandomAccessObjectStore<T>(serializationFactory, objectStorageFile); indexStore = new IndexStore<Long, LongLongIndexElement>( LongLongIndexElement.class, new ComparableComparator<Long>(), indexStorageFile ); }
/** * {@inheritDoc} */ public void close() { objectStore.close(); if (indexStoreReader != null) { indexStoreReader.close(); indexStoreReader = null; } indexStore.close(); } }
/** * {@inheritDoc} */ @Override public void complete() { objectStore.complete(); indexStore.complete(); }
/** * Provides access to the contents of this store. * * @param chunk * The chunk to read objects from. * @return An iterator providing access to contents of the store. */ public ReleasableIterator<T> iterate(long chunk) { complete(); if (indexStoreReader == null) { indexStoreReader = indexStore.createReader(); } // Retrieve the file position and number of objects for the specified // chunk and iterate. return objectStore.iterate( indexStoreReader.get(chunk * 2).getValue(), indexStoreReader.get(chunk * 2 + 1).getValue() ); }
/** * Adds the specified object to the store. * * @param data * The object to be added. */ public void add(T data) { objectStore.add(data); chunkObjectCount++; if (!chunkInProgress) { // Write the file index of the new chunk. indexStore.write(new LongLongIndexElement((chunkCount * 2), newChunkFilePosition)); chunkInProgress = true; } }
objectStore = new SegmentedObjectStore<T>(serializationFactory, storageFilePrefix, useCompression); indexStore = new IndexStore<Long, LongLongIndexElement>( LongLongIndexElement.class, new ComparableComparator<Long>(),
/** * {@inheritDoc} */ public void close() { objectStore.close(); if (indexStoreReader != null) { indexStoreReader.close(); indexStoreReader = null; } indexStore.close(); } }