MCPcopy Create free account
hub / github.com/OpenTSDB/asynchbase / predictSerializedSize

Method predictSerializedSize

src/GetRequest.java:491–532  ·  view source on GitHub ↗

Predicts a lower bound on the serialized size of this RPC. This is to avoid using a dynamic buffer, to avoid re-sizing the buffer. Since we use a static buffer, if the prediction is wrong and turns out to be less than what we need, there will be an exception which will prevent the RPC from being ser

(final byte server_version)

Source from the content-addressed store, hash-verified

489 * prevent the RPC from being serialized. That'd be a severe bug.
490 */
491 int predictSerializedSize(final byte server_version) {
492 int size = 0;
493 size += 4; // int: Number of parameters.
494 size += 1; // byte: Type of the 1st parameter.
495 size += 3; // vint: region name length (3 bytes => max length = 32768).
496 size += region.name().length; // The region name.
497
498 size += 1; // byte: Type of the 2nd parameter.
499 size += 1; // byte: Type again (see HBASE-2877).
500 size += 1; // byte: Version of Get.
501 size += 3; // vint: row key length (3 bytes => max length = 32768).
502 size += key.length; // The row key.
503 size += 8; // long: Lock ID.
504 size += 4; // int: Max number of versions to return.
505 size += 1; // byte: Whether or not to use a filter.
506 if (filter != null) {
507 size += filter.predictSerializedSize(); // the serialized filter size
508 }
509 if (server_version >= 26) { // New in 0.90 (because of HBASE-3174).
510 size += 1; // byte: Whether or not to cache the blocks read.
511 }
512 size += 8; // long: Minimum timestamp.
513 size += 8; // long: Maximum timestamp.
514 size += 1; // byte: Boolean: "all time".
515 size += 4; // int: Number of families.
516 if (family != null) {
517 size += 1; // vint: Family length (guaranteed on 1 byte).
518 size += family.length; // The family.
519 size += 1; // byte: Boolean: do we want specific qualifiers?
520 if (qualifiers != null) {
521 size += 4; // int: How many qualifiers follow?
522 for (final byte[] qualifier : qualifiers) {
523 size += 3; // vint: Qualifier length.
524 size += qualifier.length; // The qualifier.
525 }
526 }
527 }
528 if (server_version >= RegionClient.SERVER_VERSION_092_OR_ABOVE) {
529 size += 4; // int: Attributes map. Always 0.
530 }
531 return size;
532 }
533
534 /** Serialize the raw underlying `Put' into the given buffer. */
535 void serializePayloadInto(final byte server_version, final ChannelBuffer buf) {

Callers 2

serializeOldMethod · 0.95
predictSerializedSizeMethod · 0.95

Calls 1

nameMethod · 0.45

Tested by

no test coverage detected