JkSelf commented on code in PR #10183:
URL:
https://github.com/apache/incubator-gluten/pull/10183#discussion_r2206212768
##########
cpp/velox/jni/VeloxJniWrapper.cc:
##########
@@ -401,45 +403,104 @@
Java_org_apache_gluten_datasource_VeloxDataSourceJniWrapper_splitBlockByPartitio
JNIEnv* env,
jobject wrapper,
jlong batchHandle,
- jintArray partitionColIndice,
- jboolean hasBucket,
- jlong memoryManagerId) {
+ jintArray partitionColIndices,
+ jboolean hasBucket) {
JNI_METHOD_START
- auto ctx = gluten::getRuntime(env, wrapper);
- auto batch = ObjectStore::retrieve<ColumnarBatch>(batchHandle);
+
+ GLUTEN_CHECK(!hasBucket, "Bucketing not supported by
splitBlockByPartitionAndBucket");
+
+ const auto ctx = gluten::getRuntime(env, wrapper);
+ const auto batch = ObjectStore::retrieve<ColumnarBatch>(batchHandle);
+
+ auto partitionKeyArray = gluten::getIntArrayElementsSafe(env,
partitionColIndices);
+ int numPartitionKeys = partitionKeyArray.length();
+ std::vector<uint32_t> partitionColIndicesVec;
+ for (int i = 0; i < numPartitionKeys; ++i) {
+ const auto partitionColumnIndex = partitionKeyArray.elems()[i];
+ GLUTEN_CHECK(partitionColumnIndex < batch->numColumns(), "Partition column
index overflow");
+ partitionColIndicesVec.emplace_back(partitionColumnIndex);
+ }
std::vector<int32_t> dataColIndicesVec;
- {
- auto partitionKeyArray = gluten::getIntArrayElementsSafe(env,
partitionColIndice);
- int numPartitionKeys = partitionKeyArray.length();
- std::unordered_set<int32_t> partitionColIndiceVec;
- for (int i = 0; i < numPartitionKeys; ++i) {
- partitionColIndiceVec.emplace(partitionKeyArray.elems()[i]);
- }
- for (int i = 0; i < batch->numColumns(); ++i) {
- if (partitionColIndiceVec.count(i) == 0) {
- // The column is not a partition column. Add it to the data column
vector.
- dataColIndicesVec.emplace_back(i);
- }
+ for (int i = 0; i < batch->numColumns(); ++i) {
+ if (std::find(partitionColIndicesVec.begin(),
partitionColIndicesVec.end(), i) == partitionColIndicesVec.end()) {
+ // The column is not a partition column. Add it to the data column
vector.
+ dataColIndicesVec.emplace_back(i);
}
}
- auto result = batch->toUnsafeRow(0);
- auto rowBytes = result.data();
- auto newBatchHandle = ctx->saveObject(ctx->select(batch, dataColIndicesVec));
+ auto pool =
dynamic_cast<VeloxMemoryManager*>(ctx->memoryManager())->getLeafMemoryPool();
+ const auto veloxBatch = VeloxColumnarBatch::from(pool.get(), batch);
+ const auto inputRowVector = veloxBatch->getRowVector();
+ const auto numRows = inputRowVector->size();
+
+ connector::hive::PartitionIdGenerator idGen{
+ asRowType(inputRowVector->type()), partitionColIndicesVec, 128,
pool.get(), true};
Review Comment:
Can we make the maxPartitions and partitionPathAsLowerCase be configurable?
--
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]