public List parseCompressData()

in backup-core/src/main/java/org/apache/iotdb/backup/core/pipeline/in/source/InCompressDataSource.java [306:341]


  public List<String[]> parseCompressData(InputStream in, int lopSize, String compressType)
      throws IOException {
    byte[] block = new byte[5];
    int flag = in.read(block, 0, 5);
    List<String[]> data = new ArrayList<>();
    if (flag != -1) {
      for (int i = 0; i < lopSize; i++) {
        byte[] b = new byte[8];
        in.read(b, 0, 8);
        int originalLength = ToByteArrayUtils.byteArrayToInt(ArrayUtils.subarray(b, 0, 4));
        int compressedLength = ToByteArrayUtils.byteArrayToInt(ArrayUtils.subarray(b, 4, 8));
        byte[] compressedValue = new byte[compressedLength];
        in.read(compressedValue, 0, compressedLength);
        byte[] originalBytes;
        switch (compressType) {
          case "01":
            originalBytes = Snappy.uncompress(compressedValue);
            break;
          case "02":
            originalBytes = ICompressor.GZIPCompress.uncompress(compressedValue);
            break;
          case "03":
            LZ4Factory factory = LZ4Factory.fastestInstance();
            LZ4FastDecompressor decompressor = factory.fastDecompressor();
            originalBytes = new byte[originalLength];
            decompressor.decompress(compressedValue, originalBytes);
            break;
          default:
            throw new IllegalStateException("Unexpected value: " + compressType);
        }
        String[] originalArr = (String[]) ToByteArrayUtils.convertToObject(originalBytes);
        data.add(originalArr);
      }
    }
    return data;
  }