Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ public int memory() {

public MemorySlice finish() throws IOException {
if (positions.isEmpty()) {
throw new IllegalStateException();
// Do not use alignment mode, as it is impossible to calculate how many records are
// inside when reading
aligned = false;
}

if (aligned) {
block.writeInt(alignedSize);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,24 @@ public void testNormal() throws IOException {
assertThat(cacheManager.indexCache().asMap()).isEmpty();
}

@TestTemplate
public void testEmpty() throws IOException {
CacheManager cacheManager = new CacheManager(MemorySize.ofMebiBytes(1));
SortLookupStoreFactory factory =
new SortLookupStoreFactory(Comparator.naturalOrder(), cacheManager, 1024, compress);

SortLookupStoreWriter writer =
factory.createWriter(file, createBloomFiler(bloomFilterEnabled));
Context context = writer.close();

SortLookupStoreReader reader = factory.createReader(file, context);
byte[] bytes = toBytes(rnd.nextInt(VALUE_COUNT));
assertThat(reader.lookup(bytes)).isNull();
reader.close();
assertThat(cacheManager.dataCache().asMap()).isEmpty();
assertThat(cacheManager.indexCache().asMap()).isEmpty();
}

@TestTemplate
public void testIntKey() throws IOException {
RowCompactedSerializer keySerializer =
Expand Down
Loading