public static CompressedLongsIndexedSupplier fromByteBuffer(ByteBuffer buffer, ByteOrder order) {
    byte versionFromBuffer = buffer.get();

    if (versionFromBuffer == version) {
      final int totalSize = buffer.getInt();
      final int sizePer = buffer.getInt();
      final CompressedObjectStrategy.CompressionStrategy compression =
          CompressedObjectStrategy.CompressionStrategy.forId(buffer.get());
      return new CompressedLongsIndexedSupplier(
          totalSize,
          sizePer,
          GenericIndexed.read(
              buffer,
              CompressedLongBufferObjectStrategy.getBufferForOrder(order, compression, sizePer)),
          compression);
    } else if (versionFromBuffer == LZF_VERSION) {
      final int totalSize = buffer.getInt();
      final int sizePer = buffer.getInt();
      final CompressedObjectStrategy.CompressionStrategy compression =
          CompressedObjectStrategy.CompressionStrategy.LZF;
      return new CompressedLongsIndexedSupplier(
          totalSize,
          sizePer,
          GenericIndexed.read(
              buffer,
              CompressedLongBufferObjectStrategy.getBufferForOrder(order, compression, sizePer)),
          compression);
    }

    throw new IAE("Unknown version[%s]", versionFromBuffer);
  }
 public void writeToChannel(WritableByteChannel channel) throws IOException {
   channel.write(ByteBuffer.wrap(new byte[] {version}));
   channel.write(ByteBuffer.wrap(Ints.toByteArray(totalSize)));
   channel.write(ByteBuffer.wrap(Ints.toByteArray(sizePer)));
   channel.write(ByteBuffer.wrap(new byte[] {compression.getId()}));
   baseLongBuffers.writeToChannel(channel);
 }
  public static CompressedVSizeIntsIndexedSupplier fromByteBuffer(
      ByteBuffer buffer, ByteOrder order) {
    byte versionFromBuffer = buffer.get();

    if (versionFromBuffer == version) {
      final int numBytes = buffer.get();
      final int totalSize = buffer.getInt();
      final int sizePer = buffer.getInt();
      final int chunkBytes = sizePer * numBytes + bufferPadding(numBytes);

      final CompressedObjectStrategy.CompressionStrategy compression =
          CompressedObjectStrategy.CompressionStrategy.forId(buffer.get());

      return new CompressedVSizeIntsIndexedSupplier(
          totalSize,
          sizePer,
          numBytes,
          GenericIndexed.read(
              buffer,
              CompressedByteBufferObjectStrategy.getBufferForOrder(order, compression, chunkBytes)),
          compression);
    }

    throw new IAE("Unknown version[%s]", versionFromBuffer);
  }