Github user ajantha-bhat commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228040809 --- Diff: store/sdk/src/test/java/org/apache/carbondata/sdk/file/CarbonReaderTest.java --- @@ -1522,4 +1522,208 @@ public boolean accept(File dir, String name) { e.printStackTrace(); } } + + @Test + public void testReadNextRowWithRowUtil() { --- End diff -- As class not required. Test cases are not required for it --- |
In reply to this post by qiuchenjian-2
Github user ajantha-bhat commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228041857 --- Diff: store/CSDK/main.cpp --- @@ -21,6 +21,7 @@ #include <iostream> --- End diff -- Can we move this to test ? because this is not a product code. --- |
In reply to this post by qiuchenjian-2
Github user ajantha-bhat commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228044190 --- Diff: store/CSDK/CarbonRow.cpp --- @@ -0,0 +1,129 @@ +/* + * 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. + */ + +#include <jni.h> +#include <cstring> +#include "CarbonRow.h" + +CarbonRow::CarbonRow(JNIEnv *env) { + this->rowUtilClass = env->FindClass("org/apache/carbondata/sdk/file/RowUtil"); + this->jniEnv = env; + getShortId = jniEnv->GetStaticMethodID(rowUtilClass, "getShort", + "([Ljava/lang/Object;I)S"); + getIntId = jniEnv->GetStaticMethodID(rowUtilClass, "getInt", + "([Ljava/lang/Object;I)I"); + getLongId = jniEnv->GetStaticMethodID(rowUtilClass, "getLong", + "([Ljava/lang/Object;I)J"); + getDoubleId = jniEnv->GetStaticMethodID(rowUtilClass, "getDouble", + "([Ljava/lang/Object;I)D"); + getFloatId = jniEnv->GetStaticMethodID(rowUtilClass, "getFloat", + "([Ljava/lang/Object;I)F"); + getBooleanId = jniEnv->GetStaticMethodID(rowUtilClass, "getBoolean", + "([Ljava/lang/Object;I)Z"); + getStringId = jniEnv->GetStaticMethodID(rowUtilClass, "getString", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getDecimalId = jniEnv->GetStaticMethodID(rowUtilClass, "getDecimal", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getVarcharId = jniEnv->GetStaticMethodID(rowUtilClass, "getVarchar", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getArrayId = jniEnv->GetStaticMethodID(rowUtilClass, "getArray", + "([Ljava/lang/Object;I)[Ljava/lang/Object;"); +} + +void CarbonRow::setCarbonRow(jobject data) { + this->carbonRow = data; +} + +short CarbonRow::getShort(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticShortMethodA(rowUtilClass, getShortId, args); --- End diff -- Here rowUtils is just converting java object to Java data type. This is just a typecast operation. No need of rowUtil Class. Can directly typecast here. --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228046466 --- Diff: store/sdk/src/main/java/org/apache/carbondata/sdk/file/RowUtil.java --- @@ -0,0 +1,146 @@ +/* + * 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.carbondata.sdk.file; --- End diff -- How to cast type? --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228046803 --- Diff: store/CSDK/main.cpp --- @@ -21,6 +21,7 @@ #include <iostream> --- End diff -- SCDK will add test framework(such as google test) in the future. --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228046987 --- Diff: store/CSDK/CarbonRow.cpp --- @@ -0,0 +1,129 @@ +/* + * 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. + */ + +#include <jni.h> +#include <cstring> +#include "CarbonRow.h" + +CarbonRow::CarbonRow(JNIEnv *env) { + this->rowUtilClass = env->FindClass("org/apache/carbondata/sdk/file/RowUtil"); + this->jniEnv = env; + getShortId = jniEnv->GetStaticMethodID(rowUtilClass, "getShort", + "([Ljava/lang/Object;I)S"); + getIntId = jniEnv->GetStaticMethodID(rowUtilClass, "getInt", + "([Ljava/lang/Object;I)I"); + getLongId = jniEnv->GetStaticMethodID(rowUtilClass, "getLong", + "([Ljava/lang/Object;I)J"); + getDoubleId = jniEnv->GetStaticMethodID(rowUtilClass, "getDouble", + "([Ljava/lang/Object;I)D"); + getFloatId = jniEnv->GetStaticMethodID(rowUtilClass, "getFloat", + "([Ljava/lang/Object;I)F"); + getBooleanId = jniEnv->GetStaticMethodID(rowUtilClass, "getBoolean", + "([Ljava/lang/Object;I)Z"); + getStringId = jniEnv->GetStaticMethodID(rowUtilClass, "getString", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getDecimalId = jniEnv->GetStaticMethodID(rowUtilClass, "getDecimal", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getVarcharId = jniEnv->GetStaticMethodID(rowUtilClass, "getVarchar", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getArrayId = jniEnv->GetStaticMethodID(rowUtilClass, "getArray", + "([Ljava/lang/Object;I)[Ljava/lang/Object;"); +} + +void CarbonRow::setCarbonRow(jobject data) { + this->carbonRow = data; +} + +short CarbonRow::getShort(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticShortMethodA(rowUtilClass, getShortId, args); --- End diff -- How to cast type? --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228047898 --- Diff: docs/csdk-guide.md --- @@ -68,20 +68,42 @@ JNIEnv *initJVM() { bool readFromLocalWithoutProjection(JNIEnv *env) { CarbonReader carbonReaderClass; - carbonReaderClass.builder(env, "../resources/carbondata", "test"); + carbonReaderClass.builder(env, "../resources/carbondata"); --- End diff -- SDK guide also has this problem, do we need remove it too? --- |
In reply to this post by qiuchenjian-2
Github user ajantha-bhat commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228053433 --- Diff: store/CSDK/CarbonReader.cpp --- @@ -19,15 +19,14 @@ #include <jni.h> jobject CarbonReader::builder(JNIEnv *env, char *path, char *tableName) { - jniEnv = env; jclass carbonReaderClass = env->FindClass("org/apache/carbondata/sdk/file/CarbonReader"); jmethodID carbonReaderBuilderID = env->GetStaticMethodID(carbonReaderClass, "builder", --- End diff -- If class path is wrong or class is not found in given path. This will be NPE and jvm will crash. Need to validate this and throw exception or return null with log to the user. --- |
In reply to this post by qiuchenjian-2
Github user ajantha-bhat commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228054034 --- Diff: store/CSDK/CarbonReader.cpp --- @@ -38,9 +37,9 @@ jobject CarbonReader::builder(JNIEnv *env, char *path) { jclass carbonReaderClass = env->FindClass("org/apache/carbondata/sdk/file/CarbonReader"); --- End diff -- same as Above, for all the class in carbonReader.cpp handle the negative scenarios by adding validation. Else we get jvm crash. --- |
In reply to this post by qiuchenjian-2
Github user ajantha-bhat commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228055673 --- Diff: store/CSDK/main.cpp --- @@ -21,6 +21,7 @@ #include <iostream> --- End diff -- we just have to create a folder and move this file to that folder. other files we keep in source folder. update cmakelist with proper path. This gives good idea for new developer to identify which is source and which is test code. --- |
In reply to this post by qiuchenjian-2
Github user ajantha-bhat commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228055937 --- Diff: store/CSDK/CarbonRow.cpp --- @@ -0,0 +1,129 @@ +/* + * 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. + */ + +#include <jni.h> +#include <cstring> +#include "CarbonRow.h" + +CarbonRow::CarbonRow(JNIEnv *env) { + this->rowUtilClass = env->FindClass("org/apache/carbondata/sdk/file/RowUtil"); + this->jniEnv = env; + getShortId = jniEnv->GetStaticMethodID(rowUtilClass, "getShort", + "([Ljava/lang/Object;I)S"); + getIntId = jniEnv->GetStaticMethodID(rowUtilClass, "getInt", + "([Ljava/lang/Object;I)I"); + getLongId = jniEnv->GetStaticMethodID(rowUtilClass, "getLong", + "([Ljava/lang/Object;I)J"); + getDoubleId = jniEnv->GetStaticMethodID(rowUtilClass, "getDouble", + "([Ljava/lang/Object;I)D"); + getFloatId = jniEnv->GetStaticMethodID(rowUtilClass, "getFloat", + "([Ljava/lang/Object;I)F"); + getBooleanId = jniEnv->GetStaticMethodID(rowUtilClass, "getBoolean", + "([Ljava/lang/Object;I)Z"); + getStringId = jniEnv->GetStaticMethodID(rowUtilClass, "getString", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getDecimalId = jniEnv->GetStaticMethodID(rowUtilClass, "getDecimal", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getVarcharId = jniEnv->GetStaticMethodID(rowUtilClass, "getVarchar", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getArrayId = jniEnv->GetStaticMethodID(rowUtilClass, "getArray", + "([Ljava/lang/Object;I)[Ljava/lang/Object;"); +} + +void CarbonRow::setCarbonRow(jobject data) { + this->carbonRow = data; +} + +short CarbonRow::getShort(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticShortMethodA(rowUtilClass, getShortId, args); --- End diff -- (short)carbonRow[ordinal] --- |
In reply to this post by qiuchenjian-2
Github user ajantha-bhat commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228056225 --- Diff: store/CSDK/CarbonRow.cpp --- @@ -0,0 +1,129 @@ +/* + * 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. + */ + +#include <jni.h> +#include <cstring> +#include "CarbonRow.h" + +CarbonRow::CarbonRow(JNIEnv *env) { + this->rowUtilClass = env->FindClass("org/apache/carbondata/sdk/file/RowUtil"); + this->jniEnv = env; + getShortId = jniEnv->GetStaticMethodID(rowUtilClass, "getShort", + "([Ljava/lang/Object;I)S"); + getIntId = jniEnv->GetStaticMethodID(rowUtilClass, "getInt", + "([Ljava/lang/Object;I)I"); + getLongId = jniEnv->GetStaticMethodID(rowUtilClass, "getLong", + "([Ljava/lang/Object;I)J"); + getDoubleId = jniEnv->GetStaticMethodID(rowUtilClass, "getDouble", + "([Ljava/lang/Object;I)D"); + getFloatId = jniEnv->GetStaticMethodID(rowUtilClass, "getFloat", + "([Ljava/lang/Object;I)F"); + getBooleanId = jniEnv->GetStaticMethodID(rowUtilClass, "getBoolean", + "([Ljava/lang/Object;I)Z"); + getStringId = jniEnv->GetStaticMethodID(rowUtilClass, "getString", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getDecimalId = jniEnv->GetStaticMethodID(rowUtilClass, "getDecimal", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getVarcharId = jniEnv->GetStaticMethodID(rowUtilClass, "getVarchar", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getArrayId = jniEnv->GetStaticMethodID(rowUtilClass, "getArray", + "([Ljava/lang/Object;I)[Ljava/lang/Object;"); +} + +void CarbonRow::setCarbonRow(jobject data) { + this->carbonRow = data; +} + +short CarbonRow::getShort(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticShortMethodA(rowUtilClass, getShortId, args); +} + +int CarbonRow::getInt(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticIntMethodA(rowUtilClass, getIntId, args); +} + +long CarbonRow::getLong(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticLongMethodA(rowUtilClass, getLongId, args); +} + +double CarbonRow::getDouble(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticDoubleMethodA(rowUtilClass, getDoubleId, args); +} + + +float CarbonRow::getFloat(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticFloatMethodA(rowUtilClass, getFloatId, args); +} + +jboolean CarbonRow::getBoolean(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticBooleanMethodA(rowUtilClass, getBooleanId, args); --- End diff -- (jboolean)carobnRow[ordinal] just we can type cast like above ? --- |
In reply to this post by qiuchenjian-2
Github user ajantha-bhat commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228056749 --- Diff: docs/csdk-guide.md --- @@ -30,106 +30,13 @@ code and without CarbonSession. In the carbon jars package, there exist a carbondata-sdk.jar, including SDK reader for CSDK. ## Quick example -``` -// 1. init JVM -JavaVM *jvm; -JNIEnv *initJVM() { - JNIEnv *env; - JavaVMInitArgs vm_args; - int parNum = 3; - int res; - JavaVMOption options[parNum]; - - options[0].optionString = "-Djava.compiler=NONE"; - options[1].optionString = "-Djava.class.path=../../sdk/target/carbondata-sdk.jar"; - options[2].optionString = "-verbose:jni"; - vm_args.version = JNI_VERSION_1_8; - vm_args.nOptions = parNum; - vm_args.options = options; - vm_args.ignoreUnrecognized = JNI_FALSE; - - res = JNI_CreateJavaVM(&jvm, (void **) &env, &vm_args); - if (res < 0) { - fprintf(stderr, "\nCan't create Java VM\n"); - exit(1); - } - - return env; -} - -// 2. create carbon reader and read data -// 2.1 read data from local disk -/** - * test read data from local disk, without projection - * - * @param env jni env - * @return - */ -bool readFromLocalWithoutProjection(JNIEnv *env) { - - CarbonReader carbonReaderClass; - carbonReaderClass.builder(env, "../resources/carbondata", "test"); - carbonReaderClass.build(); - - while (carbonReaderClass.hasNext()) { - jobjectArray row = carbonReaderClass.readNextRow(); - jsize length = env->GetArrayLength(row); - int j = 0; - for (j = 0; j < length; j++) { - jobject element = env->GetObjectArrayElement(row, j); - char *str = (char *) env->GetStringUTFChars((jstring) element, JNI_FALSE); - printf("%s\t", str); - } - printf("\n"); - } - carbonReaderClass.close(); -} - -// 2.2 read data from S3 - -/** - * read data from S3 - * parameter is ak sk endpoint - * - * @param env jni env - * @param argv argument vector - * @return - */ -bool readFromS3(JNIEnv *env, char *argv[]) { - CarbonReader reader; - - char *args[3]; - // "your access key" - args[0] = argv[1]; - // "your secret key" - args[1] = argv[2]; - // "your endPoint" - args[2] = argv[3]; - - reader.builder(env, "s3a://sdk/WriterOutput", "test"); - reader.withHadoopConf(3, args); - reader.build(); - printf("\nRead data from S3:\n"); - while (reader.hasNext()) { - jobjectArray row = reader.readNextRow(); - jsize length = env->GetArrayLength(row); - - int j = 0; - for (j = 0; j < length; j++) { - jobject element = env->GetObjectArrayElement(row, j); - char *str = (char *) env->GetStringUTFChars((jstring) element, JNI_FALSE); - printf("%s\t", str); - } - printf("\n"); - } - - reader.close(); -} - -// 3. destory JVM - (jvm)->DestroyJavaVM(); -``` -Find example code at main.cpp of CSDK module + +Please find example code at main.cpp of CSDK module --- End diff -- can we add a link here for main.cpp ? so that just click will take to main.cpp --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228061918 --- Diff: store/CSDK/CarbonRow.cpp --- @@ -0,0 +1,129 @@ +/* + * 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. + */ + +#include <jni.h> +#include <cstring> +#include "CarbonRow.h" + +CarbonRow::CarbonRow(JNIEnv *env) { + this->rowUtilClass = env->FindClass("org/apache/carbondata/sdk/file/RowUtil"); + this->jniEnv = env; + getShortId = jniEnv->GetStaticMethodID(rowUtilClass, "getShort", + "([Ljava/lang/Object;I)S"); + getIntId = jniEnv->GetStaticMethodID(rowUtilClass, "getInt", + "([Ljava/lang/Object;I)I"); + getLongId = jniEnv->GetStaticMethodID(rowUtilClass, "getLong", + "([Ljava/lang/Object;I)J"); + getDoubleId = jniEnv->GetStaticMethodID(rowUtilClass, "getDouble", + "([Ljava/lang/Object;I)D"); + getFloatId = jniEnv->GetStaticMethodID(rowUtilClass, "getFloat", + "([Ljava/lang/Object;I)F"); + getBooleanId = jniEnv->GetStaticMethodID(rowUtilClass, "getBoolean", + "([Ljava/lang/Object;I)Z"); + getStringId = jniEnv->GetStaticMethodID(rowUtilClass, "getString", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getDecimalId = jniEnv->GetStaticMethodID(rowUtilClass, "getDecimal", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getVarcharId = jniEnv->GetStaticMethodID(rowUtilClass, "getVarchar", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getArrayId = jniEnv->GetStaticMethodID(rowUtilClass, "getArray", + "([Ljava/lang/Object;I)[Ljava/lang/Object;"); +} + +void CarbonRow::setCarbonRow(jobject data) { + this->carbonRow = data; +} + +short CarbonRow::getShort(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticShortMethodA(rowUtilClass, getShortId, args); +} + +int CarbonRow::getInt(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticIntMethodA(rowUtilClass, getIntId, args); +} + +long CarbonRow::getLong(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticLongMethodA(rowUtilClass, getLongId, args); +} + +double CarbonRow::getDouble(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticDoubleMethodA(rowUtilClass, getDoubleId, args); +} + + +float CarbonRow::getFloat(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticFloatMethodA(rowUtilClass, getFloatId, args); +} + +jboolean CarbonRow::getBoolean(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticBooleanMethodA(rowUtilClass, getBooleanId, args); --- End diff -- can't, I tried before. --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228062513 --- Diff: store/CSDK/CarbonRow.cpp --- @@ -0,0 +1,129 @@ +/* + * 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. + */ + +#include <jni.h> +#include <cstring> +#include "CarbonRow.h" + +CarbonRow::CarbonRow(JNIEnv *env) { + this->rowUtilClass = env->FindClass("org/apache/carbondata/sdk/file/RowUtil"); + this->jniEnv = env; + getShortId = jniEnv->GetStaticMethodID(rowUtilClass, "getShort", + "([Ljava/lang/Object;I)S"); + getIntId = jniEnv->GetStaticMethodID(rowUtilClass, "getInt", + "([Ljava/lang/Object;I)I"); + getLongId = jniEnv->GetStaticMethodID(rowUtilClass, "getLong", + "([Ljava/lang/Object;I)J"); + getDoubleId = jniEnv->GetStaticMethodID(rowUtilClass, "getDouble", + "([Ljava/lang/Object;I)D"); + getFloatId = jniEnv->GetStaticMethodID(rowUtilClass, "getFloat", + "([Ljava/lang/Object;I)F"); + getBooleanId = jniEnv->GetStaticMethodID(rowUtilClass, "getBoolean", + "([Ljava/lang/Object;I)Z"); + getStringId = jniEnv->GetStaticMethodID(rowUtilClass, "getString", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getDecimalId = jniEnv->GetStaticMethodID(rowUtilClass, "getDecimal", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getVarcharId = jniEnv->GetStaticMethodID(rowUtilClass, "getVarchar", + "([Ljava/lang/Object;I)Ljava/lang/String;"); + getArrayId = jniEnv->GetStaticMethodID(rowUtilClass, "getArray", + "([Ljava/lang/Object;I)[Ljava/lang/Object;"); +} + +void CarbonRow::setCarbonRow(jobject data) { + this->carbonRow = data; +} + +short CarbonRow::getShort(int ordinal) { + jvalue args[2]; + args[0].l = carbonRow; + args[1].i = ordinal; + return jniEnv->CallStaticShortMethodA(rowUtilClass, getShortId, args); --- End diff -- can't cast like this, I tried before --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228067726 --- Diff: store/CSDK/CarbonReader.cpp --- @@ -19,15 +19,14 @@ #include <jni.h> jobject CarbonReader::builder(JNIEnv *env, char *path, char *tableName) { - jniEnv = env; jclass carbonReaderClass = env->FindClass("org/apache/carbondata/sdk/file/CarbonReader"); jmethodID carbonReaderBuilderID = env->GetStaticMethodID(carbonReaderClass, "builder", --- End diff -- I planed to handle exception in the future before. Can we raise a new PR for exception? --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228067882 --- Diff: store/sdk/src/test/java/org/apache/carbondata/sdk/file/CarbonReaderTest.java --- @@ -1522,4 +1522,208 @@ public boolean accept(File dir, String name) { e.printStackTrace(); } } + + @Test + public void testReadNextRowWithRowUtil() { --- End diff -- If has cast type method, we can remove --- |
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:
https://github.com/apache/carbondata/pull/2792 Build Success with Spark 2.2.1, Please check CI http://95.216.28.178:8080/job/ApacheCarbonPRBuilder1/1221/ --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2792#discussion_r228072138 --- Diff: store/CSDK/main.cpp --- @@ -21,6 +21,7 @@ #include <iostream> --- End diff -- OKï¼done --- |
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:
https://github.com/apache/carbondata/pull/2792 Build Success with Spark 2.3.1, Please check CI http://136.243.101.176:8080/job/carbondataprbuilder2.3/9273/ --- |
Free forum by Nabble | Edit this page |