private void updateIndex() {
    Collections.sort(index, comparator);
    DataOutput dataOutput = new DataOutput();
    dataOutput.writeInt(index.size());

    for (Index i : index) {
      dataOutput.writeLong(i.getId());
      dataOutput.writeLong(i.getSortKey());
    }

    storage.setItem("list_" + prefix + "_index", toBase64(dataOutput.toByteArray()));
  }
  public byte[] buildContainer() throws IOException {
    DataOutput res = new DataOutput();
    BserWriter writer = new BserWriter(res);
    if (this instanceof ContentLocalContainer) {
      writer.writeInt(1, TYPE_LOCAL);
      writer.writeBytes(2, ((ContentLocalContainer) this).getContent().buildContainer());
    } else if (this instanceof ContentRemoteContainer) {
      writer.writeInt(1, TYPE_REMOTE);
      writer.writeBytes(2, ((ContentRemoteContainer) this).getMessage().buildContainer());
    } else {
      throw new IOException("Unknown type");
    }

    return res.toByteArray();
  }
 public byte[] serialize() {
   DataOutput res = new DataOutput();
   serialize(res);
   return res.toByteArray();
 }