def set_operate(policy, key, operations)
      begin_cmd
      field_count = estimate_key_size(key, policy)
      read_attr = 0
      write_attr = 0
      read_header = false

      operations.each do |operation|
        case operation.op_type
        when Aerospike::Operation::READ
            read_attr |= INFO1_READ

          # Read all bins if no bin is specified.
          read_attr |= INFO1_GET_ALL unless operation.bin_name

        when Aerospike::Operation::READ_HEADER
            # The server does not currently return record header data with _INFO1_NOBINDATA attribute set.
            # The workaround is to request a non-existent bin.
            # TODO: Fix this on server.
            # read_attr |= _INFO1_READ | _INFO1_NOBINDATA
            read_attr |= INFO1_READ
          read_header = true

        else
          write_attr = INFO2_WRITE
        end

        estimate_operation_size_for_operation(operation)
      end
      size_buffer

      if write_attr != 0
        write_header_with_policy(policy, read_attr, write_attr, field_count, operations.length)
      else
        write_header(policy, read_attr, write_attr, field_count, operations.length)
      end
      write_key(key, policy)

      operations.each do |operation|
        write_operation_for_operation(operation)
      end

      write_operation_for_bin(nil, Aerospike::Operation::READ) if read_header

      end_cmd
    end
def set_operate(policy, key, operations)
      begin_cmd
      field_count = estimate_key_size(key, policy)
      read_attr = 0
      write_attr = 0
      read_header = false

      operations.each do |operation|
        case operation.op_type
        when Aerospike::Operation::READ
            read_attr |= INFO1_READ

          # Read all bins if no bin is specified.
          read_attr |= INFO1_GET_ALL unless operation.bin_name

        when Aerospike::Operation::READ_HEADER
            # The server does not currently return record header data with _INFO1_NOBINDATA attribute set.
            # The workaround is to request a non-existent bin.
            # TODO: Fix this on server.
            # read_attr |= _INFO1_READ | _INFO1_NOBINDATA
            read_attr |= INFO1_READ
          read_header = true

        else
          write_attr = INFO2_WRITE
        end

        estimate_operation_size_for_operation(operation)
      end
      size_buffer

      if write_attr != 0
        write_header_with_policy(policy, read_attr, write_attr, field_count, operations.length)
      else
        write_header(policy, read_attr, write_attr, field_count, operations.length)
      end
      write_key(key, policy)

      operations.each do |operation|
        write_operation_for_operation(operation)
      end

      write_operation_for_bin(nil, Aerospike::Operation::READ) if read_header

      end_cmd
    end
Implements different command operations