[GitHub] [carbondata] xubo245 commented on a change in pull request #3173: [CARBONDATA-3351] Support Binary Data Type

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] xubo245 commented on a change in pull request #3173: [CARBONDATA-3351] Support Binary Data Type

GitBox
xubo245 commented on a change in pull request #3173: [CARBONDATA-3351] Support Binary Data Type
URL: https://github.com/apache/carbondata/pull/3173#discussion_r275773021
 
 

 ##########
 File path: store/sdk/src/main/java/org/apache/carbondata/test/util/BinaryUtil.java
 ##########
 @@ -0,0 +1,126 @@
+/*
+ * 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.test.util;
+
+import java.io.*;
+
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import org.apache.carbondata.sdk.file.CarbonReader;
+import org.apache.carbondata.sdk.file.CarbonWriter;
+import org.apache.carbondata.sdk.file.Field;
+import org.apache.carbondata.sdk.file.Schema;
+
+import static org.apache.carbondata.sdk.file.utils.SDKUtil.listFiles;
+
+public class BinaryUtil {
+  public static void binaryToCarbon(String sourceImageFolder, String outputPath,
+                                    String sufAnnotation, final String sufImage) throws Exception {
+    Field[] fields = new Field[5];
+    fields[0] = new Field("binaryId", DataTypes.INT);
+    fields[1] = new Field("binaryName", DataTypes.STRING);
+    fields[2] = new Field("binary", DataTypes.BINARY);
+    fields[3] = new Field("labelName", DataTypes.STRING);
+    fields[4] = new Field("labelContent", DataTypes.STRING);
+    CarbonWriter writer = CarbonWriter
+        .builder()
+        .outputPath(outputPath)
+        .withCsvInput(new Schema(fields))
+        .withBlockSize(256)
+        .writtenBy("SDKS3Example").withPageSizeInMb(1)
+        .build();
+    binaryToCarbon(sourceImageFolder, writer, sufAnnotation, sufImage);
+  }
+
+  public static boolean binaryToCarbon(String sourceImageFolder, CarbonWriter writer,
+      String sufAnnotation, final String sufImage) throws Exception {
+    int num = 1;
+
+    byte[] originBinary = null;
+
+    // read and write image data
+    for (int j = 0; j < num; j++) {
+
+      Object[] files = listFiles(sourceImageFolder, sufImage).toArray();
+
+      if (null != files) {
+        for (int i = 0; i < files.length; i++) {
+          // read image and encode to Hex
 
 Review comment:
   For byte[], no need encode. I replied in previous comments.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services