Пример #1
0
 public int estimateSize() {
   int size = (pesTokens.length << 3) + pesStreamIds.estimateSize();
   for (MPSStreamIndex mpsStreamIndex : streams) {
     size += mpsStreamIndex.estimateSize();
   }
   return size + 64;
 }
Пример #2
0
  public void serializeTo(ByteBuffer index) {
    index.putInt(pesTokens.length);
    for (int i = 0; i < pesTokens.length; i++) {
      index.putLong(pesTokens[i]);
    }
    pesStreamIds.serialize(index);

    for (MPSStreamIndex mpsStreamIndex : streams) {
      mpsStreamIndex.serialize(index);
    }
  }
Пример #3
0
  public static MPSIndex parseIndex(ByteBuffer index) {
    int pesCnt = index.getInt();
    long[] pesTokens = new long[pesCnt];

    for (int i = 0; i < pesCnt; i++) {
      pesTokens[i] = index.getLong();
    }

    RunLength.Integer pesStreamId = RunLength.Integer.parse(index);

    ArrayList<MPSStreamIndex> list = new ArrayList<MPSStreamIndex>();
    while (index.hasRemaining()) {
      int stream = index.get() & 0xff;
      list.add(MPSStreamIndex.parseIndex(stream, index));
    }
    return new MPSIndex(pesTokens, pesStreamId, list.toArray(new MPSStreamIndex[0]));
  }