use byte offsets instead of block numbers

We want to allow arbitrary allocations in DiskStorage. The
first step was to change the hard coded block size into a
dynamic one.
This commit is contained in:
2018-10-12 08:10:43 +02:00
parent eaa234bfa5
commit 0539080200
6 changed files with 96 additions and 107 deletions

View File

@@ -22,6 +22,7 @@ import java.util.stream.StreamSupport;
import org.lucares.collections.IntList;
import org.lucares.pdb.api.StringCompressor;
import org.lucares.pdb.api.Tags;
import org.lucares.pdb.blockstorage.BSFile;
import org.lucares.pdb.datastore.Doc;
import org.lucares.pdb.datastore.Proposal;
import org.lucares.pdb.datastore.lang.Expression;
@@ -171,13 +172,13 @@ public class DataStore implements AutoCloseable {
public long createNewFile(final Tags tags) throws IOException {
final String filename = tags.serialize();
final long newFilesRootBlockNumber = diskStorage.appendNewBlock();
updateListingFile(tags, newFilesRootBlockNumber);
final ListingFileEntry listingFileEntry = new ListingFileEntry(filename, newFilesRootBlockNumber);
final long newFilesRootBlockOffset = diskStorage.allocateBlock(BSFile.BLOCK_SIZE);
updateListingFile(tags, newFilesRootBlockOffset);
final ListingFileEntry listingFileEntry = new ListingFileEntry(filename, newFilesRootBlockOffset);
cacheTagToFileMapping(tags, listingFileEntry);
return newFilesRootBlockNumber;
return newFilesRootBlockOffset;
}
private Tags toTags(final String filename) {