Skip to content

Commit

Permalink
7.0.0 rebase gazelle test fix (apache#85)
Browse files Browse the repository at this point in the history
* 7.0.0 rebase gazelle test fix

* fix

* fix
  • Loading branch information
zhztheplayer committed Mar 15, 2022
1 parent 7b7dcae commit 8df7c5c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
8 changes: 5 additions & 3 deletions cpp/src/gandiva/function_registry_datetime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,16 @@ std::vector<NativeFunction> GetDateTimeFunctionRegistry() {

DATE_TYPES(LAST_DAY_SAFE_NULL_IF_NULL, last_day, {}),
BASE_NUMERIC_TYPES(TO_TIME_SAFE_NULL_IF_NULL, to_time, {}),
BASE_NUMERIC_TYPES(TO_TIMESTAMP_SAFE_NULL_IF_NULL, to_timestamp, {})};
BASE_NUMERIC_TYPES(TO_TIMESTAMP_SAFE_NULL_IF_NULL, to_timestamp, {}),

NativeFunction("convertTimestampUnit", {}, DataTypeVector{timestamp()}, arrow::timestamp(arrow::TimeUnit::MICRO),
kResultNullIfNull, "convertTimestampUnit_ms"),

NativeFunction("convertTimestampUnit", {}, DataTypeVector{arrow::timestamp(arrow::TimeUnit::MICRO)}, timestamp(),
kResultNullIfNull, "convertTimestampUnit_us"),

NativeFunction("castDATE", {}, DataTypeVector{date64()}, date32(),
kResultNullIfNull, "castDATE_date64"),
kResultNullIfNull, "castDATE32_date64"),

NativeFunction("castTIMESTAMP", {}, DataTypeVector{date32()}, timestamp(),
kResultNullIfNull, "castTIMESTAMP_date32"),
Expand Down Expand Up @@ -204,7 +205,8 @@ std::vector<NativeFunction> GetDateTimeFunctionRegistry() {
NativeFunction("date_diff", {}, DataTypeVector{date32(), date32()}, int32(),
kResultNullIfNull, "micros_to_timestamp_date32_date32"),

DATE_TYPES(LAST_DAY_SAFE_NULL_IF_NULL, last_day, {});
DATE_TYPES(LAST_DAY_SAFE_NULL_IF_NULL, last_day, {})
};

return date_time_fn_registry_;
}
Expand Down
12 changes: 10 additions & 2 deletions cpp/src/jni/dataset/jni_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ class ReserveFromJava : public arrow::jniutil::ReservationListener {
arrow::Status OnReservation(int64_t size) override {
JNIEnv* env;
if (vm_->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION) != JNI_OK) {
return arrow::Status::Invalid("JNIEnv was not attached to current thread");
if (vm_->AttachCurrentThreadAsDaemon(
reinterpret_cast<void**>(&env), nullptr) != JNI_OK) {
return arrow::Status::Invalid(
"JNIEnv was not able to be attached to current thread");
}
}
env->CallObjectMethod(java_reservation_listener_, reserve_memory_method, size);
RETURN_NOT_OK(arrow::jniutil::CheckException(env));
Expand All @@ -94,7 +98,11 @@ class ReserveFromJava : public arrow::jniutil::ReservationListener {
arrow::Status OnRelease(int64_t size) override {
JNIEnv* env;
if (vm_->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION) != JNI_OK) {
return arrow::Status::Invalid("JNIEnv was not attached to current thread");
if (vm_->AttachCurrentThreadAsDaemon(
reinterpret_cast<void**>(&env), nullptr) != JNI_OK) {
return arrow::Status::Invalid(
"JNIEnv was not able to be attached to current thread");
}
}
env->CallObjectMethod(java_reservation_listener_, unreserve_memory_method, size);
RETURN_NOT_OK(arrow::jniutil::CheckException(env));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

/*
* 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 org.apache.arrow.dataset.jni;

import java.util.Iterator;

/**
* Iterate on flatbuffers-serialized {@link org.apache.arrow.vector.ipc.message.ArrowRecordBatch}.
* <p>
* {@link #next()} should be called from C++ scanner to read Java-generated Arrow data.
*/
public interface NativeSerializedRecordBatchIterator extends Iterator<byte[]>, AutoCloseable {

/**
* Return next serialized {@link org.apache.arrow.vector.ipc.message.ArrowRecordBatch} Java
* byte array.
*/
@Override
byte[] next();
}

0 comments on commit 8df7c5c

Please sign in to comment.