JingsongLi commented on code in PR #2239:
URL: https://github.com/apache/incubator-paimon/pull/2239#discussion_r1379621951
##########
paimon-core/src/main/java/org/apache/paimon/disk/InMemoryBuffer.java:
##########
@@ -190,4 +200,33 @@ public BinaryRow next() throws IOException {
@Override
public void close() {}
}
+
+ // Use this to return an empty iterator, instead of use an interface
(virtual function call will
+ // cause performance loss)
+ private static class EmptyInMemoryBufferIterator extends
InMemoryBufferIterator {
+
+ private EmptyInMemoryBufferIterator() {
+ super(null, new InternalRowSerializer());
+ }
+
+ @Override
+ public boolean advanceNext() {
+ return false;
+ }
+
+ @Override
+ public BinaryRow getRow() {
+ return null;
Review Comment:
throw new UnsupportedException
##########
paimon-core/src/main/java/org/apache/paimon/disk/InMemoryBuffer.java:
##########
@@ -126,6 +133,9 @@ long getCurrentDataBufferOffset() {
}
int getNumRecordBuffers() {
+ if (currentDataBufferOffset < 0) {
Review Comment:
if (!isInitialized) {
return 0;
}
##########
paimon-core/src/main/java/org/apache/paimon/disk/InMemoryBuffer.java:
##########
@@ -68,7 +72,8 @@ private void tryInitialize() {
@Override
public void reset() {
if (this.isInitialized) {
- this.currentDataBufferOffset = 0;
+ // we need to set -1 here to avoid been preempt
+ this.currentDataBufferOffset = -1;
Review Comment:
I don't know why to set to -1.
I think we should modify `MemoryPoolFactory.preemptMemory`, if
(memoryOccupancy > 0) assign to max.
##########
paimon-core/src/main/java/org/apache/paimon/disk/InMemoryBuffer.java:
##########
@@ -110,7 +115,9 @@ public long memoryOccupancy() {
@Override
public InMemoryBufferIterator newIterator() {
- tryInitialize();
+ if (!isInitialized) {
+ return EMPTY_ITERATOR;
Review Comment:
Add comment: to avoid request memory.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]