Skip to content

Commit

Permalink
Improve warning comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jmao-denver committed Jan 10, 2024
1 parent 7a4bb1e commit 5d7fe30
Showing 1 changed file with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ private static BarrageProtoUtil.MessageInfo parseArrowIpcMessage(final ByteBuffe
return mi;
}

/**
* The input ByteBuffer instance (especially originated from Python) can't be assumed to be valid after the return
* of this method. Until jpy-consortium/jpy#126 is resolved, we need to copy the input ByteBuffer to a new
* ByteBuffer instance that is safe to use after the return of this method.
*/
@ScriptApi
public synchronized void setSchema(final ByteBuffer ipcMessage) {
// The input ByteBuffer instance (especially originated from Python) can't be assumed to be valid after the
// return
// of this method. Until https://github.com/jpy-consortium/jpy/issues/126 is resolved, we need to copy the data
// out of
// the input ByteBuffer to use after the return of this method.
if (completed) {
throw new IllegalStateException("Conversion is complete; cannot process additional messages");
}
Expand All @@ -85,25 +85,25 @@ public synchronized void setSchema(final ByteBuffer ipcMessage) {
parseSchema((Schema) mi.header.header(new Schema()));
}

/**
* The input ByteBuffer instance (especially originated from Python) can't be assumed to be valid after the return
* of this method. Until jpy-consortium/jpy#126 is resolved, we need to copy the input ByteBuffer to a new
* ByteBuffer instance that is safe to use after the return of this method.
*/
@ScriptApi
public synchronized void addRecordBatches(final ByteBuffer... ipcMessages) {
// The input ByteBuffer instance (especially originated from Python) can't be assumed to be valid after the
// return
// of this method. Until https://github.com/jpy-consortium/jpy/issues/126 is resolved, we need to copy the data
// out of
// the input ByteBuffer to use after the return of this method.
for (final ByteBuffer ipcMessage : ipcMessages) {
addRecordBatch(ipcMessage);
}
}

/**
* The input ByteBuffer instance (especially originated from Python) can't be assumed to be valid after the return
* of this method. Until jpy-consortium/jpy#126 is resolved, we need to copy the input ByteBuffer to a new
* ByteBuffer instance that is safe to use after the return of this method.
*/
@ScriptApi
public synchronized void addRecordBatch(final ByteBuffer ipcMessage) {
// The input ByteBuffer instance (especially originated from Python) can't be assumed to be valid after the
// return
// of this method. Until https://github.com/jpy-consortium/jpy/issues/126 is resolved, we need to copy the data
// out of
// the input ByteBuffer to use after the return of this method.
if (completed) {
throw new IllegalStateException("Conversion is complete; cannot process additional messages");
}
Expand Down Expand Up @@ -142,6 +142,9 @@ public synchronized void onCompleted() throws InterruptedException {
}

protected void parseSchema(final Schema header) {
// The Schema instance (especially originated from Python) can't be assumed to be valid after the return
// of this method. Until https://github.com/jpy-consortium/jpy/issues/126 is resolved, we need to make a copy of
// the header to use after the return of this method.
if (resultTable != null) {
throw Exceptions.statusRuntimeException(Code.INVALID_ARGUMENT, "Schema evolution not supported");
}
Expand All @@ -160,6 +163,9 @@ protected void parseSchema(final Schema header) {
}

protected BarrageMessage createBarrageMessage(BarrageProtoUtil.MessageInfo mi, int numColumns) {
// The BarrageProtoUtil.MessageInfo instance (especially originated from Python) can't be assumed to be valid
// after the return of this method. Until https://github.com/jpy-consortium/jpy/issues/126 is resolved, we need
// to make a copy of it to use after the return of this method.
final BarrageMessage msg = new BarrageMessage();
final RecordBatch batch = (RecordBatch) mi.header.header(new RecordBatch());

Expand Down

0 comments on commit 5d7fe30

Please sign in to comment.