示例#1
0
  private Command newMergedCommand(
      final Map<Object, Command> mergeCommands,
      int mergeCount,
      final CommandCollector commandCollector,
      final CommandType commandType) {
    if (protocol == Protocol.Text) {
      String resultKey = (String) commandCollector.getResult();

      byte[] keyBytes = ByteUtils.getBytes(resultKey);
      byte[] cmdBytes = commandType == CommandType.GET_ONE ? Constants.GET : Constants.GETS;
      final byte[] buf = new byte[cmdBytes.length + 3 + keyBytes.length];
      ByteUtils.setArguments(buf, 0, cmdBytes, keyBytes);
      TextGetOneCommand cmd = new TextGetOneCommand(resultKey, keyBytes, commandType, null);
      cmd.setMergeCommands(mergeCommands);
      cmd.setWriteFuture(new FutureImpl<Boolean>());
      cmd.setMergeCount(mergeCount);
      cmd.setIoBuffer(IoBuffer.wrap(buf));
      return cmd;
    } else {
      BinaryGetMultiCommand result = (BinaryGetMultiCommand) commandCollector.getResult();
      result.setMergeCount(mergeCount);
      result.setMergeCommands(mergeCommands);
      return result;
    }
  }