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

Method serialize

src/MultiAction.java:216–248  ·  view source on GitHub ↗

Serializes this request.

(final byte server_version)

Source from the content-addressed store, hash-verified

214
215 /** Serializes this request. */
216 ChannelBuffer serialize(final byte server_version) {
217 if (server_version < RegionClient.SERVER_VERSION_095_OR_ABOVE) {
218 return serializeOld(server_version);
219 }
220
221 // we create a new RegionAction for each region.
222 Collections.sort(batch, SORT_BY_REGION_AND_KEY);
223 final MultiRequest.Builder req = MultiRequest.newBuilder();
224 RegionAction.Builder actions = null;
225 byte[] prev_region = HBaseClient.EMPTY_ARRAY;
226 int i = 0;
227 for (final BatchableRpc rpc : batch) {
228 final RegionInfo region = rpc.getRegion();
229 final boolean new_region = !Bytes.equals(prev_region, region.name());
230 if (new_region) {
231 if (actions != null) { // If not the first iteration ...
232 req.addRegionAction(actions.build()); // ... push actions thus far.
233 }
234 actions = RegionAction.newBuilder();
235 actions.setRegion(rpc.getRegion().toProtobuf());
236 prev_region = region.name();
237 }
238 final Action.Builder action = Action.newBuilder().setIndex(i++);
239 if (rpc instanceof GetRequest) {
240 action.setGet(((GetRequest)rpc).getPB());
241 } else {
242 action.setMutation(rpc.toMutationProto());
243 }
244 actions.addAction(action);
245 }
246 req.addRegionAction(actions.build());
247 return toChannelBuffer(MMULTI, req.build());
248 }
249
250 /** Serializes this request for HBase 0.94 and before. */
251 private ChannelBuffer serializeOld(final byte server_version) {

Callers 1

serdesOrderingMethod · 0.95

Calls 9

serializeOldMethod · 0.95
equalsMethod · 0.95
nameMethod · 0.95
setRegionMethod · 0.80
getPBMethod · 0.80
toChannelBufferMethod · 0.80
getRegionMethod · 0.45
toProtobufMethod · 0.45
toMutationProtoMethod · 0.45

Tested by 1

serdesOrderingMethod · 0.76