/** * Count the number of bytes needed to represent a given sequence of 16-bit * char values as a UTF-8 encoded array. This method is written to be cheap * to invoke. * * Note: It is strongly assumed to character sequence is valid. */ public static int byteCount(CharSequence str) { return byteCount(str, 0, str.length()); }
public int getSerializedSize() { int size = 0; if (docId != null) { size += Utf8.byteCount(docId.toString()) + 1; } size += GlobalId.LENGTH; size += 8; size += 1; return size; }