コード例 #1
0
  public void serialize(ReusableBuffer rb) {
    rb.put(CURRENT_VERSION);
    rb.putString(uuid);
    rb.putLong(getVersion());

    for (KeyValuePair kvp : configurationParameter) {
      rb.putString(kvp.getKey());
      rb.putString(kvp.getValue());
    }
  }
コード例 #2
0
  public int getSize() {

    final int BYTE_SIZE = Byte.SIZE / 8;
    final int INT_SIZE = Integer.SIZE / 8;
    final int LONG_SIZE = Long.SIZE / 8;

    // length of the uuid + 1*INT_SIZE for the uuid datatype
    int size = getUuid().length() + INT_SIZE;
    // +size of the version
    size += LONG_SIZE;
    // +size of the CURRENT_VERSION
    size += BYTE_SIZE;
    // +size of the data HashMap
    size += (getData().size() * INT_SIZE * 2);

    // +size of the values in the HashMap
    for (KeyValuePair kvp : configurationParameter) {
      size += kvp.getKey().length() + kvp.getValue().length();
    }

    return size;
  }