code: private List<Pair<Long, Long>> getTransferSections(CompressionMetadata.Chunk[] chunks)
      {
          List<Pair<Long, Long>> transferSections = new ArrayList<>();
          Pair<Long, Long> lastSection = null;
          for (CompressionMetadata.Chunk chunk : chunks)
          {
              if (lastSection != null)
              {
                  if (chunk.offset == lastSection.right)
                  {
                      // extend previous section to end of this chunk
                      lastSection = Pair.create(lastSection.left, chunk.offset + chunk.length + 4); // 4 bytes for CRC
                  }
                  else
                  {
                      transferSections.add(lastSection);
                      lastSection = Pair.create(chunk.offset, chunk.offset + chunk.length + 4);
                  }
              }
              else
              {
                  lastSection = Pair.create(chunk.offset, chunk.offset + chunk.length + 4);
              }
          }
          if (lastSection != null)
              transferSections.add(lastSection);
          return transferSections;
      }
docs: chunks are assumed to be sorted by offset