Github user kumarvishal09 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2454#discussion_r200870385
--- Diff:
core/src/main/java/org/apache/carbondata/core/util/BlockletDataMapUtil.java ---
@@ -321,4 +328,43 @@ private static boolean
isSameColumnSchemaList(List<ColumnSchema> indexFileColumn
}
return updatedValues;
}
+
+ /**
+ * Convert schema to binary
+ */
+ public static byte[] convertSchemaToBinary(List<ColumnSchema>
columnSchemas) throws IOException {
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ DataOutput dataOutput = new DataOutputStream(stream);
+ dataOutput.writeShort(columnSchemas.size());
+ for (ColumnSchema columnSchema : columnSchemas) {
+ if (columnSchema.getColumnReferenceId() == null) {
+
columnSchema.setColumnReferenceId(columnSchema.getColumnUniqueId());
+ }
+ columnSchema.write(dataOutput);
+ }
+ byte[] byteArray = stream.toByteArray();
+ // Compress with snappy to reduce the size of schema
+ return Snappy.rawCompress(byteArray, byteArray.length);
--- End diff --
Use compressor factory.
---