Skip to content

Commit

Permalink
fix duplicate entry write at max chunk size bound
Browse files Browse the repository at this point in the history
  • Loading branch information
chaokunyang committed Feb 6, 2025
1 parent f2d38ab commit 96df24a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,6 @@ protected Expression writeChunk(
writeKey,
writeValue,
new Assign(chunkSize, add(chunkSize, ofInt(1))),
new If(eq(chunkSize, ofInt(MAX_CHUNK_SIZE)), new Break()),
new If(
inlineInvoke(iterator, "hasNext", PRIMITIVE_BOOLEAN_TYPE),
new ListExpression(
Expand All @@ -1348,7 +1347,8 @@ protected Expression writeChunk(
key,
tryInlineCast(inlineInvoke(entry, "getKey", OBJECT_TYPE), keyType)),
new Assign(value, invokeInline(entry, "getValue", valueType))),
list(new Assign(entry, new Literal(null, MAP_ENTRY_TYPE)), new Break())));
list(new Assign(entry, new Literal(null, MAP_ENTRY_TYPE)), new Break())),
new If(eq(chunkSize, ofInt(MAX_CHUNK_SIZE)), new Break()));
});
expressions.add(writeLoop, new Invoke(buffer, "putByte", chunkSizeOffset, chunkSize));
if (!inline) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,7 @@ private Entry writeJavaChunk(
valueSerializer.write(buffer, value);
}
// noinspection Duplicates
if (++chunkSize == MAX_CHUNK_SIZE) {
break;
}
++chunkSize;
if (iterator.hasNext()) {
entry = iterator.next();
key = entry.getKey();
Expand All @@ -326,6 +324,9 @@ private Entry writeJavaChunk(
entry = null;
break;
}
if (chunkSize == MAX_CHUNK_SIZE) {
break;
}
}
buffer.putByte(chunkSizeOffset, (byte) chunkSize);
return entry;
Expand Down Expand Up @@ -433,10 +434,8 @@ private Entry writeJavaChunkGeneric(
fury.incDepth(-1);
}
generics.popGenericType();
++chunkSize;
// noinspection Duplicates
if (++chunkSize == MAX_CHUNK_SIZE) {
break;
}
if (iterator.hasNext()) {
entry = iterator.next();
key = entry.getKey();
Expand All @@ -445,6 +444,9 @@ private Entry writeJavaChunkGeneric(
entry = null;
break;
}
if (chunkSize == MAX_CHUNK_SIZE) {
break;
}
}
buffer.putByte(chunkSizeOffset, (byte) chunkSize);
return entry;
Expand Down

0 comments on commit 96df24a

Please sign in to comment.