Jimexist commented on a change in pull request #1107: URL: https://github.com/apache/arrow-datafusion/pull/1107#discussion_r727116759
########## File path: java/src/main/java/org/apache/arrow/datafusion/DefaultExecutionContext.java ########## @@ -0,0 +1,61 @@ +package org.apache.arrow.datafusion; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ThreadLocalRandom; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +class DefaultExecutionContext implements ExecutionContext { + + private static final Logger logger = LogManager.getLogger(DefaultExecutionContext.class); + + static native long querySql( + DefaultExecutionContext self, long contextId, long invocationId, String sql); + + public void onErrorMessage(long invocationId, String errorMessage) { + String oldError = errorMessageInbox.put(invocationId, errorMessage); + assert oldError == null : "impossibly got duplicated invocation id"; + } + + @Override + public DataFrame sql(String sql) { + long invocationId = ThreadLocalRandom.current().nextLong(); + long dataFramePointerId = querySql(this, this.pointer, invocationId, sql); + if (dataFramePointerId <= 0) { + throw getErrorForInvocation(invocationId); + } else { + DefaultDataFrame frame = new DefaultDataFrame(this, dataFramePointerId); + DefaultDataFrame absent = dataFrames.putIfAbsent(dataFramePointerId, frame); + assert null == absent : "got duplicated frame"; + return frame; + } + } + + private RuntimeException getErrorForInvocation(long invocationId) { + String errorMessage = errorMessageInbox.get(invocationId); Review comment: ```suggestion String errorMessage = errorMessageInbox.remove(invocationId); ``` -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org