Skip to content

Commit

Permalink
Fixed computation of item id index.
Browse files Browse the repository at this point in the history
  • Loading branch information
kenwenzel committed Aug 1, 2024
1 parent 441fd4a commit 7ff4216
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ private synchronized void putInternal(Iterable<KvinTuple> tuples) throws IOExcep
internalTuple.setFirst(true);
}
writerState.writer.write(internalTuple);
writerState.minMax[0] = Math.min(writerState.minMax[0], writeContext.itemIdCounter);
writerState.minMax[1] = Math.max(writerState.minMax[1], writeContext.itemIdCounter);
writerState.minMax[0] = Math.min(writerState.minMax[0], writeContext.lastItemId);
writerState.minMax[1] = Math.max(writerState.minMax[1], writeContext.lastItemId);
prevTuple = internalTuple;
}

Expand Down Expand Up @@ -548,10 +548,12 @@ private byte[] generateId(KvinTuple tuple,
if (writeContext.hasExistingData) {
long id = getId(tuple.item, IdType.ITEM_ID);
if (id != 0L) {
writeContext.lastItemId = id;
return id;
}
}
long newId = ++writeContext.itemIdCounter;
writeContext.lastItemId = newId;
IdMapping mapping = new SimpleMapping();
mapping.setId(newId);
mapping.setValue(key);
Expand Down Expand Up @@ -1232,6 +1234,7 @@ static class IdMappings {
class WriteContext {
boolean hasExistingData;
long itemIdCounter = 0, propertyIdCounter = 0, contextIdCounter = 0;
long lastItemId = 0;
Map<String, Long> itemMap = new HashMap<>();
Map<String, Long> propertyMap = new HashMap<>();
Map<String, Long> contextMap = new HashMap<>();
Expand Down

0 comments on commit 7ff4216

Please sign in to comment.