This repository has been archived by the owner on Sep 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NSE-469] Lazy Read: Iterator objects are not correctly released (#470)
* [NSE-469] Lazy Read: Iterator objects are not correctly released * style * debugging * debugging * fixup
- Loading branch information
1 parent
5ab09b9
commit 18f2a19
Showing
5 changed files
with
148 additions
and
62 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
native-sql-engine/core/src/main/java/com/intel/oap/execution/ColumnarNativeIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.intel.oap.execution; | ||
|
||
import com.intel.oap.expression.ConverterUtils; | ||
import org.apache.arrow.dataset.jni.NativeSerializedRecordBatchIterator; | ||
import org.apache.arrow.dataset.jni.UnsafeRecordBatchSerializer; | ||
import org.apache.arrow.vector.ipc.message.ArrowRecordBatch; | ||
import org.apache.spark.sql.vectorized.ColumnarBatch; | ||
|
||
import java.util.Iterator; | ||
|
||
public class ColumnarNativeIterator implements NativeSerializedRecordBatchIterator { | ||
private final Iterator<ColumnarBatch> delegated; | ||
private ColumnarBatch nextBatch = null; | ||
|
||
public ColumnarNativeIterator(Iterator<ColumnarBatch> delegated) { | ||
this.delegated = delegated; | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
while (delegated.hasNext()) { | ||
nextBatch = delegated.next(); | ||
if (nextBatch.numRows() > 0) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public byte[] next() { | ||
ColumnarBatch dep_cb = nextBatch; | ||
if (dep_cb.numRows() > 0) { | ||
ArrowRecordBatch dep_rb = ConverterUtils.createArrowRecordBatch(dep_cb); | ||
return serialize(dep_rb); | ||
} else { | ||
throw new IllegalStateException(); | ||
} | ||
} | ||
|
||
private byte[] serialize(ArrowRecordBatch batch) { | ||
return UnsafeRecordBatchSerializer.serializeUnsafe(batch); | ||
} | ||
|
||
@Override | ||
public void close() throws Exception { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters