Serializes this request.
(final byte server_version)
| 1337 | |
| 1338 | /** Serializes this request. */ |
| 1339 | ChannelBuffer serialize(final byte server_version) { |
| 1340 | // Save the region in the Scanner. This kind of a kludge but it really |
| 1341 | // is the easiest way to give the Scanner the RegionInfo it needs. |
| 1342 | Scanner.this.region = super.region; |
| 1343 | if (server_version < RegionClient.SERVER_VERSION_095_OR_ABOVE) { |
| 1344 | return serializeOld(server_version); |
| 1345 | } |
| 1346 | final Scan.Builder scan = Scan.newBuilder() |
| 1347 | .setStartRow(Bytes.wrap(start_key)) |
| 1348 | .setStopRow(Bytes.wrap(stop_key)) |
| 1349 | .setReversed(is_reversed); |
| 1350 | if (families != null) { |
| 1351 | for (int i = 0; i < families.length; i++) { |
| 1352 | final Column.Builder columns = Column.newBuilder(); |
| 1353 | columns.setFamily(Bytes.wrap(families[i])); |
| 1354 | if (qualifiers != null && qualifiers[i] != null) { |
| 1355 | for (byte[] qualifier : qualifiers[i]) { |
| 1356 | columns.addQualifier(Bytes.wrap(qualifier)); |
| 1357 | } |
| 1358 | } |
| 1359 | scan.addColumn(columns); |
| 1360 | } |
| 1361 | } |
| 1362 | if (filter != null) { |
| 1363 | scan.setFilter(FilterPB.Filter.newBuilder() |
| 1364 | .setNameBytes(Bytes.wrap(filter.name())) |
| 1365 | .setSerializedFilter(Bytes.wrap(filter.serialize())) |
| 1366 | .build()); |
| 1367 | } |
| 1368 | if (min_timestamp != 0 || max_timestamp != Long.MAX_VALUE) { |
| 1369 | final TimeRange.Builder time = TimeRange.newBuilder(); |
| 1370 | if (min_timestamp != 0) { |
| 1371 | time.setFrom(min_timestamp); |
| 1372 | } |
| 1373 | if (max_timestamp != Long.MAX_VALUE) { |
| 1374 | time.setTo(max_timestamp); |
| 1375 | } |
| 1376 | scan.setTimeRange(time.build()); |
| 1377 | } |
| 1378 | if (versions != 1) { |
| 1379 | scan.setMaxVersions(versions); |
| 1380 | } |
| 1381 | if (!populate_blockcache) { |
| 1382 | scan.setCacheBlocks(false); |
| 1383 | } |
| 1384 | if (max_num_kvs > 0) { |
| 1385 | scan.setBatchSize(max_num_kvs); |
| 1386 | } |
| 1387 | scan.setMaxResultSize(max_num_bytes); |
| 1388 | final ScanRequest req = ScanRequest.newBuilder() |
| 1389 | .setRegion(region.toProtobuf()) |
| 1390 | .setScan(scan.build()) |
| 1391 | .setNumberOfRows(max_num_rows) |
| 1392 | // Hardcoded these parameters to false since AsyncHBase cannot support them |
| 1393 | .setClientHandlesHeartbeats(false) |
| 1394 | .setClientHandlesPartials(false) |
| 1395 | .build(); |
| 1396 | return toChannelBuffer(SCAN, req); |
nothing calls this directly
no test coverage detected