@Override public void write(DataOutput output) throws IOException { output.writeInt(numOfRanges); output.writeInt(listOfColumns.size()); for (ColumnSchema aColSchema : listOfColumns) { aColSchema.write(output); } }
@Override public void write(DataOutput out) throws IOException { out.writeUTF(tableId); out.writeUTF(tableName); out.writeInt(listOfColumns.size()); for (ColumnSchema column : listOfColumns) { column.write(out); } out.writeInt(tableProperties.size()); for (Map.Entry<String, String> entry : tableProperties.entrySet()) { out.writeUTF(entry.getKey()); out.writeUTF(entry.getValue()); } if (null != partitionInfo) { out.writeBoolean(true); partitionInfo.write(out); } else { out.writeBoolean(false); } if (null != bucketingInfo) { out.writeBoolean(true); bucketingInfo.write(out); } else { out.writeBoolean(false); } }
@Override public void write(DataOutput output) throws IOException { output.writeInt(columnSchemaList.size()); for (ColumnSchema columnSchema: columnSchemaList) { columnSchema.write(output); } output.writeInt(partitionType.ordinal()); if (PartitionType.RANGE.equals(partitionType)) { output.writeInt(rangeInfo.size()); for (String value: rangeInfo) { output.writeUTF(value); } } output.writeInt(partitionIds.size()); for (Integer value: partitionIds) { output.writeInt(value); } if (PartitionType.LIST.equals(partitionType)) { output.writeInt(listInfo.size()); for (List<String> listValue: listInfo) { output.writeInt(listValue.size()); for (String value: listValue) { output.writeUTF(value); } } } output.writeInt(numPartitions); output.writeInt(maxPartitionId); }
/** * 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 to reduce the size of schema return CompressorFactory.NativeSupportedCompressor.SNAPPY.getCompressor().compressByte( byteArray); }