Package com.aerospike.client.query

Source Code of com.aerospike.client.query.ServerCommand

/*
* Aerospike Client - Java Library
*
* Copyright 2013 by Aerospike, Inc. All rights reserved.
*
* Availability of this source code to partners and customers includes
* redistribution rights covered by individual contract. Please check your
* contract for exact rights and responsibilities.
*/
package com.aerospike.client.query;

import java.io.IOException;

import com.aerospike.client.AerospikeException;
import com.aerospike.client.ResultCode;
import com.aerospike.client.cluster.Node;
import com.aerospike.client.command.Buffer;
import com.aerospike.client.command.Command;

public final class ServerCommand extends QueryCommand {
 
  public ServerCommand(Node node) {
    super(node);
  }
 
  @Override
  protected boolean parseRecordResults(int receiveSize)
    throws AerospikeException, IOException {
    // Server commands (Query/Execute UDF) should only send back a return code.
    // Keep parsing logic to empty socket buffer just in case server does
    // send records back.
    receiveOffset = 0;
   
    while (receiveOffset < receiveSize) {
        readBytes(MSG_REMAINING_HEADER_SIZE);       
      int resultCode = receiveBuffer[5] & 0xFF;
     
      if (resultCode != 0) {
        if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) {
          return false;
        }
        throw new AerospikeException(resultCode);
      }

      byte info3 = receiveBuffer[3];
     
      // If this is the end marker of the response, do not proceed further
      if ((info3 & Command.INFO3_LAST) == Command.INFO3_LAST) {
        return false;
      }   
     
      int fieldCount = Buffer.bytesToShort(receiveBuffer, 18);
      int opCount = Buffer.bytesToShort(receiveBuffer, 20);
     
      parseKey(fieldCount);

      for (int i = 0 ; i < opCount; i++) {
          readBytes(8)
        int opSize = Buffer.bytesToInt(receiveBuffer, 0);
        byte nameSize = receiveBuffer[7];
         
        readBytes(nameSize);
   
        int particleBytesSize = (int) (opSize - (4 + nameSize));
        readBytes(particleBytesSize);
        }
     
      if (! valid) {
        throw new AerospikeException.QueryTerminated();
      }
    }
    return true;
  }
}
TOP

Related Classes of com.aerospike.client.query.ServerCommand

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.