@Override public E get(long index, RandomAccessFile indexFile, RandomAccessFile dataFile, Codec<E> codec, IndexStrategy indexStrategy) throws IOException, ClassNotFoundException { long elementsCount = indexStrategy.getSize(indexFile); if(index >= 0 && index < elementsCount) { long offset = indexStrategy.getOffset(indexFile, index); if(offset < 0) { return null; } return internalReadElement(dataFile, offset, codec); } return null; }
@Override public E get(long index, RandomAccessFile indexFile, RandomAccessFile dataFile, Codec<E> codec, IndexStrategy indexStrategy) throws IOException, ClassNotFoundException { long elementsCount = indexStrategy.getSize(indexFile); if(index >= 0 && index < elementsCount) { long offset = indexStrategy.getOffset(indexFile, index); if(offset < 0) { return null; } return internalReadElement(dataFile, offset, codec); } return null; }
@Override public E get(long index, RandomAccessFile indexFile, RandomAccessFile dataFile, Codec<E> codec, IndexStrategy indexStrategy) throws IOException, ClassNotFoundException { long elementsCount = indexStrategy.getSize(indexFile); if(index >= 0 && index < elementsCount) { long offset = indexStrategy.getOffset(indexFile, index); if(offset < 0) { return null; } return internalReadElement(dataFile, offset, codec); } return null; }
@Override public E get(long index, RandomAccessFile indexFile, RandomAccessFile dataFile, Codec<E> codec, IndexStrategy indexStrategy) throws IOException, ClassNotFoundException { long elementsCount = indexStrategy.getSize(indexFile); if(index >= 0 && index < elementsCount) { long offset = indexStrategy.getOffset(indexFile, index); if(offset < 0) { return null; } return internalReadElement(dataFile, offset, codec); } return null; }
@Override public boolean set(long index, E element, RandomAccessFile indexFile, RandomAccessFile dataFile, Codec<E> codec, IndexStrategy indexStrategy) throws IOException, UnsupportedOperationException { long offset = indexStrategy.getOffset(indexFile, index); if(!supportingOverwrite && offset >= 0) { return false; } if(element != null) { offset = dataFile.length(); internalWriteElement(dataFile, offset, index, element, codec); indexStrategy.setOffset(indexFile, index, offset); return true; } else { // set offset to -1 to signal a null value. indexStrategy.setOffset(indexFile, index, -1); return true; } }
@Override public boolean set(long index, E element, RandomAccessFile indexFile, RandomAccessFile dataFile, Codec<E> codec, IndexStrategy indexStrategy) throws IOException, UnsupportedOperationException { long offset = indexStrategy.getOffset(indexFile, index); if(!supportingOverwrite && offset >= 0) { return false; } if(element != null) { offset = dataFile.length(); internalWriteElement(dataFile, offset, index, element, codec); indexStrategy.setOffset(indexFile, index, offset); return true; } else { // set offset to -1 to signal a null value. indexStrategy.setOffset(indexFile, index, -1); return true; } }