viirya commented on code in PR #7692:
URL: https://github.com/apache/datafusion-comet/pull/7692#discussion_r4657313986
##########
native/core/src/local.rs:
##########
@@ -122,6 +133,12 @@ pub extern "system" fn
Java_org_apache_comet_local_NativeLocal_createQuery(
);
JVMClasses::init(env);
let serialized_plan = env.convert_byte_array(serialized_query)?;
+ let mut scan_partitions_vec =
Vec::with_capacity(scan_partitions.len(env)?);
+ for i in 0..scan_partitions.len(env)? {
+ let bytes = scan_partitions.get_element(env, i)?;
+ let bytes = unsafe { JByteArray::from_raw(&*env, bytes.into_raw())
};
+ scan_partitions_vec.push(env.convert_byte_array(bytes)?);
+ }
Review Comment:
Done: the loop reads the length once, converts through `&bytes` and deletes
each element's local reference, with the same comment as `credential_bridge.rs`.
##########
native/core/src/local.rs:
##########
@@ -305,6 +403,12 @@ pub extern "system" fn
Java_org_apache_comet_local_NativeLocal_nextBatch(
) -> jlong {
try_unwrap_or_throw(&e, |env| {
let result = next(env, id, arrays, schemas);
+ if result.is_err() {
+ let partition = QUERIES.lock().get(&id).map(|entry|
entry.query.partition());
+ if let Some(partition) = partition {
+ FAILED_PARTITIONS.lock().insert(id, partition);
+ }
+ }
if result.is_err() || matches!(result, Ok(-1)) {
close(id);
Review Comment:
Done. `nextBatch` now closes the query only at EOF, and `failedPartition`
reads `entry.query.partition()` from the registered entry, so
`FAILED_PARTITIONS`, its removal in `close` and its count in `activeQueries`
are gone. As you expected, `fail` has already dropped the partitions by then,
so the entry holds only the context until the JVM closes it right after reading
the partition.
##########
native/local/src/lib.rs:
##########
@@ -344,6 +362,11 @@ impl Stream for PartitionOrder {
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) ->
Poll<Option<Self::Item>> {
loop {
self.start_partitions();
+ if self.running.is_empty() {
+ return Poll::Ready(None);
+ }
+ let turn = self.next - self.running.len();
+ self.turn.store(turn, Ordering::Release);
let Some(partition) = self.running.front_mut() else {
return Poll::Ready(None);
};
Review Comment:
Removed the `is_empty` check and kept the `let ... else`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]