jt2594838 commented on a change in pull request #464: Modified Decoder and
SequenceReader to support old version of TsFile
URL: https://github.com/apache/incubator-iotdb/pull/464#discussion_r336981867
##########
File path:
tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/TsDigest.java
##########
@@ -65,18 +67,49 @@ public static int serializeNullTo(ByteBuffer buffer) {
*/
public static TsDigest deserializeFrom(InputStream inputStream) throws
IOException {
TsDigest digest = new TsDigest();
-
int size = ReadWriteIOUtils.readInt(inputStream);
digest.validSizeOfArray = size;
digest.serializedSize = Integer.BYTES;
if (size > 0) {
digest.statistics = new ByteBuffer[StatisticType.getTotalTypeNum()];
ByteBuffer value;
- for (int i = 0; i < size; i++) {
- short n = ReadWriteIOUtils.readShort(inputStream);
- value =
ReadWriteIOUtils.readByteBufferWithSelfDescriptionLength(inputStream);
- digest.statistics[n] = value;
- digest.serializedSize += Short.BYTES + Integer.BYTES +
value.remaining();
+ // check if it's old version of TsFile
+ String key = "";
+ if
(TSFileDescriptor.getInstance().getConfig().getEndian().equals("LITTLE_ENDIAN"))
{
+ for (int i = 0; i < size; i++) {
+ key = ReadWriteIOUtils.readString(inputStream);
+ value =
ReadWriteIOUtils.readByteBufferWithSelfDescriptionLength(inputStream);
+ short n;
+ switch (key) {
+ case "min_value":
+ n = 0;
+ break;
+ case "max_value":
+ n = 1;
+ break;
+ case "first":
+ n = 2;
+ break;
+ case "last":
+ n = 3;
+ break;
+ case "sum":
+ n = 4;
+ break;
+ default:
+ n = -1;
+ }
+ digest.statistics[n] = value;
+ digest.serializedSize += Short.BYTES + Integer.BYTES +
value.remaining();
+ }
+ }
+ else {
+ for (int i = 0; i < size; i++) {
+ short n = ReadWriteIOUtils.readShort(inputStream);
+ value =
ReadWriteIOUtils.readByteBufferWithSelfDescriptionLength(inputStream);
+ digest.statistics[n] = value;
+ digest.serializedSize += Short.BYTES + Integer.BYTES +
value.remaining();
+ }
Review comment:
Please reformat the above codes.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services