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

Method predictSerializedSize

src/Scanner.java:1293–1336  ·  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

()

Source from the content-addressed store, hash-verified

1291 * prevent the RPC from being serialized. That'd be a severe bug.
1292 */
1293 private int predictSerializedSize() {
1294 int size = 0;
1295 size += 4; // int: Number of parameters.
1296 size += 1; // byte: Type of the 1st parameter.
1297 size += 3; // vint: region name length (3 bytes => max length = 32768).
1298 size += super.region.name().length; // The region name.
1299
1300 size += 1; // byte: Type of the 2nd parameter.
1301 size += 1; // byte: Type again (see HBASE-2877).
1302 size += 1; // byte: Version of Scan.
1303 size += 3; // vint: start key length (3 bytes => max length = 32768).
1304 size += start_key.length; // The start key.
1305 size += 3; // vint: stop key length (3 bytes => max length = 32768).
1306 size += stop_key.length; // The stop key.
1307 size += 4; // int: Max number of versions to return.
1308 size += 4; // int: Max number of KeyValues to get per RPC.
1309 size += 4; // int: Unused field only used by HBase's client.
1310 size += 1; // bool: Whether or not to populate the blockcache.
1311 size += 1; // byte: Whether or not to use a filter.
1312 if (filter != null) {
1313 size += filter.predictSerializedSize();
1314 }
1315 size += 8; // long: Minimum timestamp.
1316 size += 8; // long: Maximum timestamp.
1317 size += 1; // byte: Boolean: "all time".
1318 size += 4; // int: Number of families.
1319 if (families != null) {
1320 // vint: Family length (guaranteed on 1 byte) for each family.
1321 size += families.length;
1322 for (int i = 0; i < families.length; i++) {
1323 byte[] family = families[i];
1324 size += family.length; // The family.
1325 size += 4; // int: How many qualifiers follow?
1326 if (qualifiers != null && qualifiers[i] != null) {
1327 // vint: Qualifier length times number of qualifiers.
1328 size += 3 * qualifiers[i].length;
1329 for (byte[] qualifier : qualifiers[i]) {
1330 size += qualifier.length; // The qualifier.
1331 }
1332 }
1333 }
1334 }
1335 return size;
1336 }
1337
1338 /** Serializes this request. */
1339 ChannelBuffer serialize(final byte server_version) {

Callers 1

serializeOldMethod · 0.95

Calls 1

nameMethod · 0.45

Tested by

no test coverage detected