aerospike

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2014 License: Apache-2.0 Imports: 19 Imported by: 0

README

Aerospike Go Client Build Status

An Aerospike library for Go.

This library is compatible with Go 1.2+ and supports the following operating systems: Linux, Mac OS X (Windows builds are possible, but untested)

Usage:

The following is a very simple example of CRUD operations in an Aerospike database.

package main

import (
  "fmt"

  . "github.com/aerospike/aerospike-client-go"
)

func panicOnError(err error) {
  if err != nil {
    panic(err)
  }
}

func main() {
  // define a client to connect to
  client, err := NewClient("127.0.0.1", 3000)
  panicOnError(err)

  key, err := NewKey("test", "aerospike", "key")
  panicOnError(err)

  // define some bins with data
  bins := BinMap{
    "bin1": 42,
    "bin2": "An elephant is a mouse with an operating system",
    "bin3": []interface{}{"Go", 2009},
  }

  // write the bins
  err = client.Put(nil, key, bins)
  panicOnError(err)

  // read it back!
  rec, err := client.Get(nil, key)
  panicOnError(err)

  fmt.Printf("%#v\n", *rec)

  // delete the key, and check if key exists
  existed, err := client.Delete(nil, key)
  panicOnError(err)
  fmt.Printf("Record existed before delete? %v\n", existed)
}

More examples illustrating the use of the API are located in the examples directory.

Details about the API are available in the docs directory.

Prerequisites

Go version v1.2+ is required. (It is possible to build the code in Go versions prior to 1.2, but our testing library depends on v1.2)

To install the latest stable version of Go, visit http://golang.org/dl/

Aerospike Go client implements the wire protocol, and does not depend on the C client. It is goroutine friendly, and works asynchronously.

Supported operating systems:

  • Major Linux distributions (Ubuntu, Debian, Redhat)
  • Mac OS X
  • Windows (untested)

Installation:

  1. Install Go 1.2+ and setup your environment as Documented
  2. Get the client in your GOPATH : go get github.com/aerospike/aerospike-client-go
  • To update the client library: go get -u github.com/aerospike/aerospike-client-go
Some Hints:
  • To run a go program directly: go run <filename.go>
  • to build: go build -o <output> <filename.go>
  • example: go build -o benchmark tools/benchmark/benchmark.go

Tests

This library is packaged with a number of tests. Tests require Ginkgo and Gomega library.

Before running the tests, you need to update the dependencies:

$ go get .

To run all the test cases with race detection:

$ ginkgo -r -race

Examples

A variety of example applications are provided in the examples directory. See the examples/README.md for details.

Tools

A variety of clones of original tools are provided in the tools directory. They show how to use more advanced features of the library to reimplement the same functionality in a more concise way.

Benchmarks

Benchmark utility is provided in the tools/benchmark directory. See the tools/benchmark/README.md for details.

API Documentation

API documentation is available using godocs.

A preformatted version is provided in the docs directory.

License

The Aerospike Go Client is made availabled under the terms of the Apache License, Version 2, as stated in the file LICENSE.

Individual files may be made available under their own specific license, all compatible with Apache License, Version 2. Please see individual files for details.

Documentation

Index

Constants

View Source
const (
	// Flags commented out are not supported by this client.
	// Contains a read operation.
	INFO1_READ int = (1 << 0)
	// Get all bins.
	INFO1_GET_ALL int = (1 << 1)

	// Do not read the bins
	INFO1_NOBINDATA int = (1 << 5)

	// Create or update record
	INFO2_WRITE int = (1 << 0)
	// Fling a record into the belly of Moloch.
	INFO2_DELETE int = (1 << 1)
	// Update if expected generation == old.
	INFO2_GENERATION int = (1 << 2)
	// Update if new generation >= old, good for restore.
	INFO2_GENERATION_GT int = (1 << 3)
	// Create a duplicate on a generation collision.
	INFO2_GENERATION_DUP int = (1 << 4)
	// Create only. Fail if record already exists.
	INFO2_CREATE_ONLY int = (1 << 5)

	// This is the last of a multi-part message.
	INFO3_LAST int = (1 << 0)
	// Update only. Merge bins.
	INFO3_UPDATE_ONLY int = (1 << 3)

	// Create or completely replace record.
	INFO3_CREATE_OR_REPLACE int = (1 << 4)
	// Completely replace existing record only.
	INFO3_REPLACE_ONLY int = (1 << 5)

	MSG_TOTAL_HEADER_SIZE     uint8 = 30
	FIELD_HEADER_SIZE         uint8 = 5
	OPERATION_HEADER_SIZE     uint8 = 8
	MSG_REMAINING_HEADER_SIZE uint8 = 22
	DIGEST_SIZE               uint8 = 20
	CL_MSG_VERSION            int64 = 2
	AS_MSG_TYPE               int64 = 3
)

Variables

This section is empty.

Functions

func BytesToParticle

func BytesToParticle(ptype int, buf []byte, offset int, length int) (interface{}, error)

func ComputeDigest

func ComputeDigest(setName string, key Value) ([]byte, error)

Generate unique server hash value from set name, key type and user defined key. The hash function is RIPEMD-160 (a 160 bit hash).

func PackAnyArray

func PackAnyArray(val []interface{}) ([]byte, error)

func PackAnyMap

func PackAnyMap(val map[interface{}]interface{}) ([]byte, error)

func PackValueArray

func PackValueArray(val []Value) ([]byte, error)

func RequestInfo

func RequestInfo(conn *Connection, names ...string) (map[string]string, error)

Get info values by name from the specified connection

func RequestInfoForHostName

func RequestInfoForHostName(hostname string, port int, names ...string) map[string]string

Get many info values by name from the specified database server node, using host name and port.

func RequestInfoForNode

func RequestInfoForNode(node Node, name ...string) (string, error)

Get info values by name from the specified database server node.

Types

type AerospikeBlob

type AerospikeBlob interface {
	// Encode returns a byte slice representing the encoding of the
	// receiver for transmission to a Decoder, usually of the same
	// concrete type.
	EncodeBlob() ([]byte, error)
}

type BaseCommand

type BaseCommand struct {
	// contains filtered or unexported fields
}

Holds data buffer for the command

func (*BaseCommand) SetDelete

func (this *BaseCommand) SetDelete(policy *WritePolicy, key *Key)

Writes the command for delete operations

func (*BaseCommand) SetExists

func (this *BaseCommand) SetExists(key *Key)

Writes the command for exist operations

func (*BaseCommand) SetOperate

func (this *BaseCommand) SetOperate(policy *WritePolicy, key *Key, operations []*Operation) error

Implements different command operations

func (*BaseCommand) SetRead

func (this *BaseCommand) SetRead(key *Key, binNames []string)

Writes the command for get operations (specified bins)

func (*BaseCommand) SetReadForKeyOnly

func (this *BaseCommand) SetReadForKeyOnly(key *Key)

Writes the command for get operations (all bins)

func (*BaseCommand) SetReadHeader

func (this *BaseCommand) SetReadHeader(key *Key)

Writes the command for getting metadata operations

func (*BaseCommand) SetScan

func (this *BaseCommand) SetScan(policy *ScanPolicy, namespace *string, setName *string, binNames []string)

func (*BaseCommand) SetTouch

func (this *BaseCommand) SetTouch(policy *WritePolicy, key *Key)

Writes the command for touch operations

func (*BaseCommand) SetWrite

func (this *BaseCommand) SetWrite(policy *WritePolicy, operation OperationType, key *Key, bins []*Bin) error

Writes the command for write operations

func (*BaseCommand) WriteFieldBytes

func (this *BaseCommand) WriteFieldBytes(bytes []byte, ftype FieldType)

func (*BaseCommand) WriteFieldHeader

func (this *BaseCommand) WriteFieldHeader(size int, ftype FieldType)

func (*BaseCommand) WriteFieldString

func (this *BaseCommand) WriteFieldString(str string, ftype FieldType)

type BasePolicy

type BasePolicy struct {
	Policy

	// Priority of request relative to other transactions.
	// Currently, only used for scans.
	Priority Priority //= Priority.DEFAULT;

	// Transaction timeout.
	// This timeout is used to set the socket timeout and is also sent to the
	// server along with the transaction in the wire protocol.
	// Default to no timeout (0).
	Timeout time.Duration

	// Maximum number of retries before aborting the current transaction.
	// A retry is attempted when there is a network error other than timeout.
	// If maxRetries is exceeded, the abort will occur even if the timeout
	// has not yet been exceeded.
	MaxRetries int //= 2;

	// Duration to sleep between retries if a transaction fails and the
	// timeout was not exceeded.  Enter zero to skip sleep.
	SleepBetweenRetries time.Duration //= 500;
}

Container object for transaction policy attributes used in all database operation calls.

func NewPolicy

func NewPolicy() *BasePolicy

func (*BasePolicy) GetBasePolicy

func (this *BasePolicy) GetBasePolicy() *BasePolicy

type Bin

type Bin struct {
	// Bin name. Current limit is 14 characters.
	Name string

	// Bin value.
	Value Value
}

Column name/value pair.

func NewBin

func NewBin(name string, value interface{}) *Bin

Constructor, specifying bin name and string value. For servers configured as "single-bin", enter an empty name.

func (*Bin) String

func (this *Bin) String() string

Implements Stringer interface. string representation of bin.

type BinMap

type BinMap map[string]interface{}

BinMap is used to define a map of bin names to values

type BytesValue

type BytesValue struct {
	// contains filtered or unexported fields
}

Byte array value.

func NewBlobValue

func NewBlobValue(object AerospikeBlob) *BytesValue

NewBlobValue accepts an AerospikeBlob interface, and automatically converts it to a BytesValue. If Encode returns an err, it will panic.

func NewBytesValue

func NewBytesValue(bytes []byte) *BytesValue

func (*BytesValue) EstimateSize

func (this *BytesValue) EstimateSize() int

func (*BytesValue) GetObject

func (this *BytesValue) GetObject() interface{}

func (*BytesValue) GetType

func (this *BytesValue) GetType() int

func (*BytesValue) Pack

func (this *BytesValue) Pack(packer *Packer) error

func (*BytesValue) String

func (this *BytesValue) String() string

func (*BytesValue) Write

func (this *BytesValue) Write(buffer []byte, offset int) (int, error)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(hostname string, port int) (*Client, error)

NewClient generates a new Client

func NewClientWithPolicy

func NewClientWithPolicy(policy *ClientPolicy, hostname string, port int) (*Client, error)

NewClientWithPolicy generates a new Client and sets the ClientPolicy

func NewClientWithPolicyAndHost

func NewClientWithPolicyAndHost(policy *ClientPolicy, hosts ...*Host) (*Client, error)

NewClientWithPolicyAndHost generates a new Client and sets the ClientPolicy and sets up the cluster

func (*Client) Add

func (this *Client) Add(policy *WritePolicy, key *Key, bins BinMap) error

Add integer bin values to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for integer values.

func (*Client) AddBins

func (this *Client) AddBins(policy *WritePolicy, key *Key, bins ...*Bin) error

func (*Client) Append

func (this *Client) Append(policy *WritePolicy, key *Key, bins BinMap) error

Append bin values string to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for string values.

func (*Client) AppendBins

func (this *Client) AppendBins(policy *WritePolicy, key *Key, bins ...*Bin) error

func (*Client) Close

func (this *Client) Close()

Close all client connections to database server nodes.

func (*Client) Delete

func (this *Client) Delete(policy *WritePolicy, key *Key) (bool, error)

Delete record for specified key. The policy specifies the transaction timeout.

func (*Client) Exists

func (this *Client) Exists(policy *BasePolicy, key *Key) (bool, error)

Determine if a record key exists. The policy can be used to specify timeouts.

func (*Client) Get

func (this *Client) Get(policy *BasePolicy, key *Key, binNames ...string) (*Record, error)

Read record header and bins for specified key. The policy can be used to specify timeouts.

func (*Client) GetHeader

func (this *Client) GetHeader(policy *BasePolicy, key *Key) (*Record, error)

Read record generation and expiration only for specified key. Bins are not read. The policy can be used to specify timeouts.

func (*Client) GetNodeNames

func (this *Client) GetNodeNames() []string

Return list of active server node names in the cluster.

func (*Client) GetNodes

func (this *Client) GetNodes() []*Node

Return array of active server nodes in the cluster.

func (*Client) IsConnected

func (this *Client) IsConnected() bool

Determine if we are ready to talk to the database server cluster.

func (*Client) Prepend

func (this *Client) Prepend(policy *WritePolicy, key *Key, bins BinMap) error

Prepend bin values string to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call works only for string values.

func (*Client) PrependBins

func (this *Client) PrependBins(policy *WritePolicy, key *Key, bins ...*Bin) error

func (*Client) Put

func (this *Client) Put(policy *WritePolicy, key *Key, bins BinMap) error

Write record bin(s). The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists.

func (*Client) PutBins

func (this *Client) PutBins(policy *WritePolicy, key *Key, bins ...*Bin) error

func (*Client) Touch

func (this *Client) Touch(policy *WritePolicy, key *Key) error

Create record if it does not already exist. If the record exists, the record's time to expiration will be reset to the policy's expiration.

type ClientPolicy

type ClientPolicy struct {
	// Initial host connection timeout in milliseconds.  The timeout when opening a connection
	// to the server host for the first time.
	Timeout time.Duration //= 1000 milliseconds

	// Size of the Connection Queue cache.
	ConnectionQueueSize int //= 64

	// Throw exception if host connection fails during addHost().
	FailIfNotConnected bool //= true
}

Container object for client policy Command.

func NewClientPolicy

func NewClientPolicy() *ClientPolicy

Generates a new ClientPolicy with default values

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

func NewCluster

func NewCluster(policy *ClientPolicy, hosts []*Host) (*Cluster, error)

func (*Cluster) AddSeeds

func (this *Cluster) AddSeeds(hosts []*Host)

Adds new hosts to the cluster They will be added to the cluster on next tend

func (*Cluster) Close

func (this *Cluster) Close()

Closes all cached connections to the cluster nodes and stops the tend goroutine

func (*Cluster) FindNodeName

func (this *Cluster) FindNodeName(list []*Node, name string) bool

FIXIT: This function is not well desined while it is expoted. Finds a node by name in a list of nodes

func (*Cluster) GetNode

func (this *Cluster) GetNode(partition *Partition) (*Node, error)

func (*Cluster) GetNodeByName

func (this *Cluster) GetNodeByName(nodeName string) (*Node, error)

Find a node by name and returns an error if not found

func (*Cluster) GetNodes

func (this *Cluster) GetNodes() []*Node

Returns a list of all nodes in the cluster

func (*Cluster) GetRandomNode

func (this *Cluster) GetRandomNode() (*Node, error)

Returns a random node on the cluster

func (*Cluster) IsConnected

func (this *Cluster) IsConnected() bool

type Command

type Command interface {

	// Executes the command
	Execute() error
	// contains filtered or unexported methods
}

Command intrerface describes all commands available

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection represents a connection with a timeout

func NewConnection

func NewConnection(address string, timeout time.Duration) (*Connection, error)

NewConnection creates a connection on the network and returns the pointer A minimum timeout of 2 seconds will always be applied. If the connection is not established in the specified timeout, an error will be returned

func (*Connection) Close

func (this *Connection) Close()

Closes the connection

func (*Connection) IsConnected

func (this *Connection) IsConnected() bool

Returns true if the connection is not closed

func (*Connection) Read

func (this *Connection) Read(buf []byte, length int) (int, error)

Reads from connection buffer to the slice

func (*Connection) SetTimeout

func (this *Connection) SetTimeout(timeout time.Duration)

sets connection timeout

func (*Connection) Write

func (this *Connection) Write(buf []byte) (int, error)

Writes the slice to the connection buffer.

type DeleteCommand

type DeleteCommand struct {
	SingleCommand
	// contains filtered or unexported fields
}

func NewDeleteCommand

func NewDeleteCommand(cluster *Cluster, policy *WritePolicy, key *Key) *DeleteCommand

func (*DeleteCommand) Execute

func (this *DeleteCommand) Execute() error

func (*DeleteCommand) Existed

func (this *DeleteCommand) Existed() bool

type ExistsCommand

type ExistsCommand struct {
	SingleCommand
	// contains filtered or unexported fields
}

func NewExistsCommand

func NewExistsCommand(cluster *Cluster, policy Policy, key *Key) *ExistsCommand

func (*ExistsCommand) Execute

func (this *ExistsCommand) Execute() error

func (*ExistsCommand) Exists

func (this *ExistsCommand) Exists() bool

type FieldType

type FieldType int

FieldType represents the type of the field in Aerospike Wire Protocol

const (
	NAMESPACE FieldType = 0
	TABLE     FieldType = 1
	KEY       FieldType = 2
	//BIN FieldType = 3;
	DIGEST_RIPE FieldType = 4
	//GU_TID FieldType = 5;
	DIGEST_RIPE_ARRAY FieldType = 6
	TRAN_ID           FieldType = 7 // user supplied transaction id, which is simply passed back
	SCAN_OPTIONS      FieldType = 8
	INDEX_NAME        FieldType = 21
	INDEX_RANGE       FieldType = 22
	INDEX_FILTER      FieldType = 23
	INDEX_LIMIT       FieldType = 24
	INDEX_ORDER_BY    FieldType = 25
	UDF_PACKAGE_NAME  FieldType = 30
	UDF_FUNCTION      FieldType = 31
	UDF_ARGLIST       FieldType = 32
	UDF_OP            FieldType = 33
	QUERY_BINLIST     FieldType = 40
)

type GenerationPolicy

type GenerationPolicy int

How to handle record writes based on record generation.

const (
	// Do not use record generation to restrict writes.
	NONE GenerationPolicy = iota

	// Update/delete record if expected generation is equal to server generation. Otherwise, fail.
	EXPECT_GEN_EQUAL

	// Update/delete record if expected generation greater than the server generation. Otherwise, fail.
	// This is useful for restore after backup.
	EXPECT_GEN_GT

	// Create duplicate record if expected generation is not equal to server generation.
	// Duplicates are only created when the server configuration option "allow-versions"
	// is true (default is false).
	DUPLICATE
)

type Host

type Host struct {

	// Host name or IP address of database server.
	Name string

	// Port of database server.
	Port int
}

Host name/port of database server.

func NewHost

func NewHost(name string, port int) *Host

Initialize host.

func (*Host) String

func (h *Host) String() string

Implements stringer interface

type Info

type Info struct {
	// contains filtered or unexported fields
}

Access server's info monitoring protocol.

func NewInfo

func NewInfo(conn *Connection, commands ...string) (*Info, error)

Send multiple commands to server and store results.

func (*Info) GetValue

func (this *Info) GetValue() string

Return single value from response buffer.

type IntegerValue

type IntegerValue struct {
	// contains filtered or unexported fields
}

Integer value.

func NewIntegerValue

func NewIntegerValue(value int) *IntegerValue

func (*IntegerValue) EstimateSize

func (this *IntegerValue) EstimateSize() int

func (*IntegerValue) GetObject

func (this *IntegerValue) GetObject() interface{}

func (*IntegerValue) GetType

func (this *IntegerValue) GetType() int

func (*IntegerValue) Pack

func (this *IntegerValue) Pack(packer *Packer) error

func (*IntegerValue) String

func (this *IntegerValue) String() string

func (*IntegerValue) Write

func (this *IntegerValue) Write(buffer []byte, offset int) (int, error)

type Key

type Key struct {
	// contains filtered or unexported fields
}

Unique record identifier. Records can be identified using a specified namespace, an optional set name, and a user defined key which must be unique within a set. Records can also be identified by namespace/digest which is the combination used on the server.

func NewKey

func NewKey(namespace string, setName string, key interface{}) (*Key, error)

Initialize key from namespace, optional set name and user key. The set name and user defined key are converted to a digest before sending to the server. The server handles record identifiers by digest only.

func NewKeyByDigest

func NewKeyByDigest(namespace string, setName string, digest [20]byte) *Key

Initialize key from namespace, digest and optional set name.

func (*Key) Digest

func (this *Key) Digest() []byte

Returns current key digest

func (*Key) Equals

func (this *Key) Equals(other *Key) bool

func (*Key) Namespace

func (this *Key) Namespace() *string

returns Namespace

func (*Key) SetName

func (this *Key) SetName() *string

Returns Set name

type ListValue

type ListValue struct {
	// contains filtered or unexported fields
}

List value. Supported by Aerospike 3 servers only.

func NewListValue

func NewListValue(list []interface{}) *ListValue

func (*ListValue) EstimateSize

func (this *ListValue) EstimateSize() int

func (*ListValue) GetObject

func (this *ListValue) GetObject() interface{}

func (*ListValue) GetType

func (this *ListValue) GetType() int

func (*ListValue) Pack

func (this *ListValue) Pack(packer *Packer) error

func (*ListValue) String

func (this *ListValue) String() string

func (*ListValue) Write

func (this *ListValue) Write(buffer []byte, offset int) (int, error)

type LongValue

type LongValue struct {
	// contains filtered or unexported fields
}

Long value.

func NewLongValue

func NewLongValue(value int64) *LongValue

func (*LongValue) EstimateSize

func (this *LongValue) EstimateSize() int

func (*LongValue) GetObject

func (this *LongValue) GetObject() interface{}

func (*LongValue) GetType

func (this *LongValue) GetType() int

func (*LongValue) Pack

func (this *LongValue) Pack(packer *Packer) error

func (*LongValue) String

func (this *LongValue) String() string

func (*LongValue) Write

func (this *LongValue) Write(buffer []byte, offset int) (int, error)

type MapValue

type MapValue struct {
	// contains filtered or unexported fields
}

Map value. Supported by Aerospike 3 servers only.

func NewMapValue

func NewMapValue(vmap map[interface{}]interface{}) *MapValue

func (*MapValue) EstimateSize

func (this *MapValue) EstimateSize() int

func (*MapValue) GetObject

func (this *MapValue) GetObject() interface{}

func (*MapValue) GetType

func (this *MapValue) GetType() int

func (*MapValue) Pack

func (this *MapValue) Pack(packer *Packer) error

func (*MapValue) String

func (this *MapValue) String() string

func (*MapValue) Write

func (this *MapValue) Write(buffer []byte, offset int) (int, error)

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node represents an Aerospike Database Server Node

func NewNode

func NewNode(cluster *Cluster, nv *NodeValidator) *Node

Initialize server node with connection parameters.

func (*Node) AddAlias

func (this *Node) AddAlias(aliasToAdd *Host)

Adds an alias for the node

func (*Node) Close

func (this *Node) Close()

Marks node as inactice and closes all cached connections

func (*Node) DecreaseHealth

func (this *Node) DecreaseHealth()

Decrease node Health as a result of bad connection or communication

func (*Node) Equals

func (this *Node) Equals(other *Node) bool

func (*Node) GetAliases

func (this *Node) GetAliases() []*Host

Returns node aliases

func (*Node) GetConnection

func (this *Node) GetConnection(timeout time.Duration) (*Connection, error)

Get a connection to the node. If no cached connection is not available, a new connection will be created

func (*Node) GetHost

func (this *Node) GetHost() *Host

Retrieves host for the node

func (*Node) GetName

func (this *Node) GetName() string

Returns node name

func (*Node) IsActive

func (this *Node) IsActive() bool

Checks if the node is active

func (*Node) IsUnhealthy

func (this *Node) IsUnhealthy() bool

Check if the node is unhealthy

func (*Node) PutConnection

func (this *Node) PutConnection(conn *Connection)

Put back a connection to the cache. If cache is full, the connection will be closed and discarded

func (*Node) Refresh

func (this *Node) Refresh(friends []*Host) error

Request current status from server node, and update node with the result

func (*Node) RestoreHealth

func (this *Node) RestoreHealth()

Mark the node as healthy

func (*Node) String

func (this *Node) String() string

Implements stringer interface

type NodeValidator

type NodeValidator struct {
	// contains filtered or unexported fields
}

Validates a Database server node

func NewNodeValidator

func NewNodeValidator(host *Host, timeout time.Duration) (*NodeValidator, error)

Generates a node validator

type NullValue

type NullValue struct{}

func (*NullValue) EstimateSize

func (this *NullValue) EstimateSize() int

func (*NullValue) GetObject

func (this *NullValue) GetObject() interface{}

func (*NullValue) GetType

func (this *NullValue) GetType() int

func (*NullValue) Pack

func (this *NullValue) Pack(packer *Packer) error

func (*NullValue) String

func (this *NullValue) String() string

func (*NullValue) Write

func (this *NullValue) Write(buffer []byte, offset int) (int, error)

type Operation

type Operation struct {

	// Type of operation.
	OpType OperationType

	// Optional bin name used in operation.
	BinName *string

	// Optional bin value used in operation.
	BinValue Value
}

Database operation definition. The class is used in client's operate() method.

func NewAddOp

func NewAddOp(bin Bin) *Operation

Create integer add database operation.

func NewAppendOp

func NewAppendOp(bin Bin) *Operation

Create string append database operation.

func NewGetHeaderOp

func NewGetHeaderOp() *Operation

Create read record header database operation.

func NewGetOp

func NewGetOp() *Operation

Create read all record bins database operation.

func NewGetOpByBinName

func NewGetOpByBinName(binName string) *Operation

Create read bin database operation.

func NewPrependOp

func NewPrependOp(bin Bin) *Operation

Create string prepend database operation.

func NewPutOp

func NewPutOp(bin Bin) *Operation

Create set database operation.

func NewTouchOp

func NewTouchOp() *Operation

Create touch database operation.

type OperationType

type OperationType int

Aerospike operation type

var (
	READ        OperationType = 1
	READ_HEADER OperationType = 1
	WRITE       OperationType = 2
	ADD         OperationType = 5
	APPEND      OperationType = 9
	PREPEND     OperationType = 10
	TOUCH       OperationType = 11
)

type Packer

type Packer struct {
	// contains filtered or unexported fields
}

func NewPacker

func NewPacker() *Packer

func (*Packer) PackAByte

func (this *Packer) PackAByte(val byte)

func (*Packer) PackAInt

func (this *Packer) PackAInt(val int)

func (*Packer) PackALong

func (this *Packer) PackALong(val int64)

func (*Packer) PackArrayBegin

func (this *Packer) PackArrayBegin(size int)

func (*Packer) PackByte

func (this *Packer) PackByte(valType int, val byte)

func (*Packer) PackByteArray

func (this *Packer) PackByteArray(src []byte, srcOffset int, srcLength int)

func (*Packer) PackByteArrayBegin

func (this *Packer) PackByteArrayBegin(length int)

func (*Packer) PackBytes

func (this *Packer) PackBytes(b []byte)

func (*Packer) PackInt

func (this *Packer) PackInt(valType int, val int32)

func (*Packer) PackList

func (this *Packer) PackList(list []interface{}) error

func (*Packer) PackLong

func (this *Packer) PackLong(valType int, val int64)

func (*Packer) PackMap

func (this *Packer) PackMap(theMap map[interface{}]interface{}) error

func (*Packer) PackMapBegin

func (this *Packer) PackMapBegin(size int)

func (*Packer) PackNil

func (this *Packer) PackNil()

func (*Packer) PackObject

func (this *Packer) PackObject(obj interface{}) error

func (*Packer) PackShort

func (this *Packer) PackShort(valType int, val int16)

func (*Packer) PackString

func (this *Packer) PackString(val string)

func (*Packer) PackValueArray

func (this *Packer) PackValueArray(values []Value) error

type Partition

type Partition struct {
	Namespace   string
	PartitionId int
}

func NewPartition

func NewPartition(namespace string, partitionId int) *Partition

func NewPartitionByKey

func NewPartitionByKey(key *Key) *Partition

func (*Partition) Equals

func (this *Partition) Equals(other *Partition) bool

func (*Partition) String

func (this *Partition) String() string

type PartitionTokenizer

type PartitionTokenizer interface {
	UpdatePartition(nmap map[string]atomicNodeArray, node *Node) map[string]atomicNodeArray
}

type PartitionTokenizerNew

type PartitionTokenizerNew struct {
	PartitionTokenizer
	// contains filtered or unexported fields
}

func NewPartitionTokenizerNew

func NewPartitionTokenizerNew(conn *Connection) (*PartitionTokenizerNew, error)

func (*PartitionTokenizerNew) UpdatePartition

func (this *PartitionTokenizerNew) UpdatePartition(nmap map[string]atomicNodeArray, node *Node) map[string]atomicNodeArray

type PartitionTokenizerOld

type PartitionTokenizerOld struct {
	// contains filtered or unexported fields
}

func NewPartitionTokenizerOld

func NewPartitionTokenizerOld(conn *Connection) (*PartitionTokenizerOld, error)

func (*PartitionTokenizerOld) UpdatePartition

func (this *PartitionTokenizerOld) UpdatePartition(hmap map[string]atomicNodeArray, node *Node) map[string]atomicNodeArray

type Policy

type Policy interface {
	// Retrives BasePolicy
	GetBasePolicy() *BasePolicy
}

Policy Interface

type Priority

type Priority int

Priority of operations on database server.

const (

	// The server defines the priority.
	DEFAULT Priority = iota

	// Run the database operation in a background thread.
	LOW

	// Run the database operation at medium priority.
	MEDIUM

	// Run the database operation at the highest priority.
	HIGH
)

type QueryPolicy

type QueryPolicy struct {
	BasePolicy

	// Maximum number of concurrent requests to server nodes at any poin int time.
	// If there are 16 nodes in the cluster and maxConcurrentNodes is 8, then queries
	// will be made to 8 nodes in parallel.  When a query completes, a new query will
	// be issued until all 16 nodes have been queried.
	// Default (0) is to issue requests to all server nodes in parallel.
	MaxConcurrentNodes int

	// Number of records to place in queue before blocking.
	// Records received from multiple server nodes will be placed in a queue.
	// A separate thread consumes these records in parallel.
	// If the queue is full, the producer threads will block until records are consumed.
	RecordQueueSize int //= 5000
}

Container object for policy attributes used in query operations.

type ReadCommand

type ReadCommand struct {
	SingleCommand
	// contains filtered or unexported fields
}

func NewReadCommand

func NewReadCommand(cluster *Cluster, policy Policy, key *Key, binNames []string) *ReadCommand

func (*ReadCommand) Execute

func (this *ReadCommand) Execute() error

func (*ReadCommand) GetRecord

func (this *ReadCommand) GetRecord() *Record

type ReadHeaderCommand

type ReadHeaderCommand struct {
	SingleCommand
	// contains filtered or unexported fields
}

func NewReadHeaderCommand

func NewReadHeaderCommand(cluster *Cluster, policy Policy, key *Key) *ReadHeaderCommand

func (*ReadHeaderCommand) Execute

func (this *ReadHeaderCommand) Execute() error

func (*ReadHeaderCommand) GetRecord

func (this *ReadHeaderCommand) GetRecord() *Record

type Record

type Record struct {

	// Map of requested name/value bins.
	Bins BinMap

	// List of all duplicate records (if any) for a given key.  Duplicates are only created when
	// the server configuration option "allow-versions" is true (default is false) and client
	// RecordExistsAction.DUPLICATE policy flag is set and there is a generation error.
	// Almost always null.
	Duplicates []BinMap

	// Record modification count.
	Generation int

	// Date record will expire, in seconds from Jan 01 2010 00:00:00 GMT
	Expiration int
}

Container object for records. Records are equivalent to rows.

func NewRecord

func NewRecord(bins BinMap, duplicates []BinMap, generation int, expiration int) *Record

func (*Record) String

func (this *Record) String() string

Return string representation of record.

type RecordExistsAction

type RecordExistsAction int

How to handle writes when the record already exists.

const (

	// Create or update record.
	// Merge write command bins with existing bins.
	UPDATE RecordExistsAction = iota

	// Update record only. Fail if record does not exist.
	// Merge write command bins with existing bins.
	UPDATE_ONLY

	// Create or replace record.
	// Delete existing bins not referenced by write command bins.
	// Supported by Aerospike 2 server versions >= 2.7.5 and
	// Aerospike 3 server versions >= 3.1.6.
	REPLACE

	// Replace record only. Fail if record does not exist.
	// Delete existing bins not referenced by write command bins.
	// Supported by Aerospike 2 server versions >= 2.7.5 and
	// Aerospike 3 server versions >= 3.1.6.
	REPLACE_ONLY

	// Create only.  Fail if record exists.
	CREATE_ONLY
)

type ScanPolicy

type ScanPolicy struct {
	BasePolicy

	// Percent of data to scan.  Valid integer range is 1 to 100.
	// Default is 100.
	ScanPercent int //= 100;

	// Maximum number of concurrent requests to server nodes at any poin int time.
	// If there are 16 nodes in the cluster and maxConcurrentNodes is 8, then scan requests
	// will be made to 8 nodes in parallel.  When a scan completes, a new scan request will
	// be issued until all 16 nodes have been scanned.
	// <p>
	// This field is only relevant when concurrentNodes is true.
	// Default (0) is to issue requests to all server nodes in parallel.
	MaxConcurrentNodes int

	// Issue scan requests in parallel or serially.
	ConcurrentNodes bool //= true;

	// Indicates if bin data is retrieved. If false, only record digests are retrieved.
	IncludeBinData bool //= true;

	// Terminate scan if cluster in fluctuating state.
	FailOnClusterChange bool
}

Container object for optional parameters used in scan operations.

type SingleCommand

type SingleCommand struct {
	BaseCommand
	// contains filtered or unexported fields
}

func NewSingleCommand

func NewSingleCommand(cluster *Cluster, key *Key) *SingleCommand

type StringValue

type StringValue struct {
	// contains filtered or unexported fields
}

value string.

func NewStringValue

func NewStringValue(value string) *StringValue

func (*StringValue) EstimateSize

func (this *StringValue) EstimateSize() int

func (*StringValue) GetObject

func (this *StringValue) GetObject() interface{}

func (*StringValue) GetType

func (this *StringValue) GetType() int

func (*StringValue) Pack

func (this *StringValue) Pack(packer *Packer) error

func (*StringValue) String

func (this *StringValue) String() string

func (*StringValue) Write

func (this *StringValue) Write(buffer []byte, offset int) (int, error)

type TouchCommand

type TouchCommand struct {
	SingleCommand
	// contains filtered or unexported fields
}

func NewTouchCommand

func NewTouchCommand(cluster *Cluster, policy *WritePolicy, key *Key) *TouchCommand

func (*TouchCommand) Execute

func (this *TouchCommand) Execute() error

type Unpacker

type Unpacker struct {
	// contains filtered or unexported fields
}

func NewUnpacker

func NewUnpacker(buffer []byte, offset int, length int) *Unpacker

func (*Unpacker) UnpackList

func (this *Unpacker) UnpackList() ([]interface{}, error)

func (*Unpacker) UnpackMap

func (this *Unpacker) UnpackMap() (map[interface{}]interface{}, error)

type Value

type Value interface {

	// Calculate number of this.bytes necessary to serialize the value in the wire protocol.
	EstimateSize() int

	// Serialize the value in the wire protocol.
	Write(buffer []byte, offset int) (int, error)

	// Serialize the value using MessagePack.
	Pack(packer *Packer) error

	// Get wire protocol value type.
	GetType() int

	// Return original value as an Object.
	GetObject() interface{}

	// Implement Stringer interface
	String() string
}

Polymorphic value classes used to efficiently serialize objects into the wire protocol.

func NewValue

func NewValue(v interface{}) Value

type ValueArray

type ValueArray struct {
	// contains filtered or unexported fields
}

Value array. Supported by Aerospike 3 servers only.

func NewValueArray

func NewValueArray(array []Value) *ValueArray

func (*ValueArray) EstimateSize

func (this *ValueArray) EstimateSize() int

func (*ValueArray) GetObject

func (this *ValueArray) GetObject() interface{}

func (*ValueArray) GetType

func (this *ValueArray) GetType() int

func (*ValueArray) Pack

func (this *ValueArray) Pack(packer *Packer) error

func (*ValueArray) String

func (this *ValueArray) String() string

func (*ValueArray) Write

func (this *ValueArray) Write(buffer []byte, offset int) (int, error)

type WriteCommand

type WriteCommand struct {
	SingleCommand
	// contains filtered or unexported fields
}

func NewWriteCommand

func NewWriteCommand(cluster *Cluster,
	policy *WritePolicy,
	key *Key,
	bins []*Bin,
	operation OperationType) *WriteCommand

func (*WriteCommand) Execute

func (this *WriteCommand) Execute() error

type WritePolicy

type WritePolicy struct {
	BasePolicy

	// Qualify how to handle writes where the record already exists.
	RecordExistsAction RecordExistsAction //= RecordExistsAction.UPDATE;

	// Qualify how to handle record writes based on record generation. The default (NONE)
	// indicates that the generation is not used to restrict writes.
	GenerationPolicy GenerationPolicy //= GenerationPolicy.NONE;

	// Expected generation. Generation is the number of times a record has been modified
	// (including creation) on the server. If a write operation is creating a record,
	// the expected generation would be 0
	Generation int

	// Record expiration. Also known as ttl (time to live).
	// Seconds record will live before being removed by the server.
	// Expiration values:
	// -1: Never expire for Aerospike 2 server versions >= 2.7.2 and Aerospike 3 server
	// versions >= 3.1.4.  Do not use -1 for older servers.
	// 0: Default to namespace configuration variable "default-ttl" on the server.
	// > 0: Actual expiration in seconds.
	Expiration int
}

Container object for policy attributes used in write operations. This object is passed into methods where database writes can occur.

func NewWritePolicy

func NewWritePolicy(generation, expiration int) *WritePolicy

Directories

Path Synopsis
tools
cli
utils

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL