Provides batching functionality

package ArangoDBClient
since 1.1

 Methods

Constructor for Batch instance. Batch instance by default starts capturing request after initiated.

__construct(\ArangoDBClient\Connection $connection, array $options = array()

To disable this, pass startCapture=>false inside the options array parameter

Parameters

$connection

\ArangoDBClient\Connection

that this batch class will monitor for requests in order to batch them. Connection parameter is mandatory.

$options

array

An array of options for Batch construction. See below for options:

Options are :

  • '_sanitize' - True to remove _id and _rev attributes from result documents returned from this batch. Defaults to false.
  • 'startCapture' - Start batch capturing immediately after batch instantiation. Defaults to true.
  • 'batchSize' - Defines a fixed array size for holding the batch parts. The id's of the batch parts can only be integers. When this option is defined, the batch mechanism will use an SplFixedArray instead of the normal PHP arrays. In most cases, this will result in increased performance of about 5% to 15%, depending on batch size and data.
  • Activates the batch. This sets the batch active in its associated connection and also starts capturing.

    activate() : \ArangoDBClient\Batch

    Returns

    \ArangoDBClient\Batch$this

    Append the request to the batch-part

    append(mixed $method, mixed $request) : \ArangoDBClient\HttpResponse

    Parameters

    $method

    mixed
    • The method of the request (GET, POST...)

    $request

    mixed
    • The request that will get appended to the batch

    Exceptions

    \ArangoDBClient\ClientException

    Returns

    \ArangoDBClient\HttpResponse

    Get the total count of the batch parts

    countParts() : integer

    Returns

    integer$count

    Gets active batch in given connection.

    getActive(\ArangoDBClient\Connection $connection) : \ArangoDBClient\Batch
    fluent This method is part of a fluent interface and will return the same instance

    Parameters

    $connection

    \ArangoDBClient\Connection

    Returns

    \ArangoDBClient\Batch

    Returns the array of batch-parts

    getBatchParts() : array

    Returns

    array$_batchParts

    Return this batch's connection

    getConnection() : \ArangoDBClient\Connection

    Returns

    \ArangoDBClient\Connection

    Returns true, if given connection is in batch-capture mode.

    getConnectionCaptureMode(\ArangoDBClient\Connection $connection) : boolean

    Parameters

    $connection

    \ArangoDBClient\Connection

    Returns

    boolean

    Get the batch part identified by the array key (0.

    getPart(mixed $partId) : mixed

    ..n) or its id (if it was set with nextBatchPartId($id) )

    Parameters

    $partId

    mixed

    the batch part id. Either it's numeric key or a given name.

    Exceptions

    \ArangoDBClient\ClientException

    Returns

    mixed$batchPart

    Get the batch part identified by the array key (0.

    getPartResponse(mixed $partId) : mixed

    ..n) or its id (if it was set with nextBatchPartId($id) )

    Parameters

    $partId

    mixed

    the batch part id. Either it's numeric key or a given name.

    Exceptions

    \ArangoDBClient\ClientException

    Returns

    mixed$partId

    Get the batch part identified by the array key (0.

    getProcessedPartResponse(mixed $partId) : mixed

    ..n) or its id (if it was set with nextBatchPartId($id) )

    Parameters

    $partId

    mixed

    the batch part id. Either it's numeric key or a given name.

    Exceptions

    \ArangoDBClient\ClientException

    Returns

    mixed$partId

    Returns true, if this batch is active in its associated connection.

    isActive() : boolean

    Returns

    boolean

    Returns true, if this batch is capturing requests.

    isCapturing() : boolean

    Returns

    boolean

    Set client side cursor options (for example: sanitize) for the next batch part.

    nextBatchPartCursorOptions(mixed $batchPartCursorOptions) : \ArangoDBClient\Batch

    Parameters

    $batchPartCursorOptions

    mixed

    Returns

    \ArangoDBClient\Batch

    Sets the id of the next batch-part. The id can later be used to retrieve the batch-part.

    nextBatchPartId(mixed $batchPartId) : \ArangoDBClient\Batch

    Parameters

    $batchPartId

    mixed

    Returns

    \ArangoDBClient\Batch

    Processes this batch. This sends the captured requests to the server as one batch.

    process() : \ArangoDBClient\HttpResponse | \ArangoDBClient\Batch

    Exceptions

    \ArangoDBClient\ClientException
    \ArangoDBClient\Exception

    Returns

    \ArangoDBClient\HttpResponse\ArangoDBClient\Batch- Batch if processing of the batch was successful or the HttpResponse object in case of a failure. A successful process just means that tha parts were processed. Each part has it's own response though and should be checked on its own.

    Sets the batch active in its associated connection.

    setActive() : \ArangoDBClient\Batch

    Returns

    \ArangoDBClient\Batch$this

    Sets the batch's associated connection into capture mode.

    setCapture(boolean $state) : \ArangoDBClient\Batch

    Parameters

    $state

    boolean

    Returns

    \ArangoDBClient\Batch$this

    Sets the connection for he current batch. (mostly internal function)

    setConnection(\ArangoDBClient\Connection $connection) : \ArangoDBClient\Batch

    Parameters

    $connection

    \ArangoDBClient\Connection

    Returns

    \ArangoDBClient\Batch

    Sets the document class to use

    setDocumentClass(string $class) : \ArangoDBClient\DocumentClassable
    Inherited

    Parameters

    $class

    string

    Document class to use

    Returns

    \ArangoDBClient\DocumentClassable

    Sets the edge class to use

    setEdgeClass(string $class) : \ArangoDBClient\DocumentClassable
    Inherited

    Parameters

    $class

    string

    Edge class to use

    Returns

    \ArangoDBClient\DocumentClassable

    Split batch request and use ContentId as array key

    splitWithContentIdKey(mixed $pattern, mixed $string) : array

    Parameters

    $pattern

    mixed

    $string

    mixed

    Exceptions

    \ArangoDBClient\ClientException

    Returns

    array$array - Array of batch-parts

    Start capturing requests. To stop capturing, use stopCapture()

    startCapture() : \ArangoDBClient\Batch

    see ArangoDBClient\Batch::stopCapture()

    Returns

    \ArangoDBClient\Batch

    Stop capturing requests. If the batch has not been processed yet, more requests can be appended by calling startCapture() again.

    stopCapture() : \ArangoDBClient\Batch

    see Batch::startCapture()

    Exceptions

    \ArangoDBClient\ClientException

    Returns

    \ArangoDBClient\Batch

    Return an array of cursor options

    getCursorOptions() : array

    Returns

    array- array of options

    Sets connection into Batch-Request mode. This is necessary to distinguish between normal and the batch request.

    setBatchRequest(boolean $state) : \ArangoDBClient\Batch
    fluent This method is part of a fluent interface and will return the same instance

    Parameters

    $state

    boolean

    Returns

    \ArangoDBClient\Batch

     Properties

     

    Batch Response Object

    $_batchResponse : \ArangoDBClient\HttpResponse

    Default

     

    Document class to use

    $_documentClass : string

    Default

    '\ArangoDBClient\Document'
     

    Edge class to use

    $_edgeClass : string

    Default

    '\ArangoDBClient\Edge'
     

    An array of BatchPartCursor options

    $_batchPartCursorOptions : array

    Default

    array()
     

    The array of BatchPart objects

    $_batchParts : array

    Default

    array()
     

    The connection object

    $_connection : \ArangoDBClient\Connection

    Default

     

    The next batch part id

    $_nextBatchPartId : integer | string

    Default

     

    The Batch NextId

    $_nextId : integer | string

    Default

    0
     

    Flag that signals if this batch was processed or not. Processed => true ,or not processed => false

    $_processed : boolean

    Default

    false
     

    The sanitize default value

    $_sanitize : boolean

    Default

    false