All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Fields | Private Attributes | Related Functions
as_scan Struct Reference

Detailed Description

In order to execute a scan using the Scan API, an as_scan object must be initialized and populated.

Initialization

Before using an as_scan, it must be initialized via either:

as_scan_init() should be used on a stack allocated as_scan. It will initialize the as_scan with the given namespace and set. On success, it will return a pointer to the initialized as_scan. Otherwise, NULL is returned.

as_scan scan;
as_scan_init(&scan, "namespace", "set");

as_scan_new() should be used to allocate and initialize a heap allocated as_scan. It will allocate the as_scan, then initialized it with the given namespace and set. On success, it will return a pointer to the initialized as_scan. Otherwise, NULL is returned.

as_scan * scan = as_scan_new("namespace", "set");

Destruction

When you are finished with the as_scan, you can destroy it and associated resources:

Usage

An initialized as_scan can be populated with additional fields.

Selecting Bins

as_scan_select() is used to specify the bins to be selected by the scan. If a scan specifies bins to be selected, then only those bins will be returned. If no bins are selected, then all bins will be returned.

as_scan_select(query, "bin1");
as_scan_select(query, "bin2");

Before adding bins to select, the select structure must be initialized via either:

Both functions are given the number of bins to be selected.

A complete example using as_scan_select_inita()

as_scan_select(query, "bin1");
as_scan_select(query, "bin2");

Returning only meta data

A scan can return only record meta data, and exclude bins.

as_scan_set_nobins(scan, true);

Scan nodes in parallel

A scan can be made to scan all the nodes in parallel

Scan a Percentage of Records

A scan can define the percentage of record in the cluster to be scaned.

Scan a Priority

To set the priority of the scan, the set as_scan.priority.

The priority of a scan can be defined as either:

Applying a UDF to each Record Scanned

A UDF can be applied to each record scanned.

To define the UDF for the scan, use as_scan_apply_each().

as_scan_apply_each(scan, "udf_module", "udf_function", arglist);

Definition at line 332 of file as_scan.h.

#include "as_scan.h"

+ Collaboration diagram for as_scan:

Data Fields

as_udf_call apply_each
 
bool concurrent
 
bool deserialize_list_map
 
bool include_ldt
 
bool no_bins
 
as_namespace ns
 
uint8_t percent
 
as_scan_predexp predexp
 
as_scan_priority priority
 
as_scan_bins select
 
as_set set
 

Private Attributes

bool _free
 

Related Functions

(Note that these are not member functions.)

bool as_scan_apply_each (as_scan *scan, const char *module, const char *function, as_list *arglist)
 
void as_scan_destroy (as_scan *scan)
 
as_scanas_scan_init (as_scan *scan, const as_namespace ns, const as_set set)
 
as_scanas_scan_new (const as_namespace ns, const as_set set)
 
bool as_scan_predexp_add (as_scan *scan, as_predexp_base *predexp)
 
bool as_scan_predexp_init (as_scan *scan, uint16_t n)
 
#define as_scan_predexp_inita(__scan, __n)
 
bool as_scan_select (as_scan *scan, const char *bin)
 
bool as_scan_select_init (as_scan *scan, uint16_t n)
 
bool as_scan_set_nobins (as_scan *scan, bool nobins)
 
bool as_scan_set_percent (as_scan *scan, uint8_t percent)
 
bool as_scan_set_priority (as_scan *scan, as_scan_priority priority)
 

Friends And Related Function Documentation

bool as_scan_apply_each ( as_scan scan,
const char *  module,
const char *  function,
as_list arglist 
)
related

Apply a UDF to each record scanned on the server.

as_arraylist arglist;
as_arraylist_init(&arglist, 2, 0);
as_scan_apply_each(&q, "module", "func", (as_list *) &arglist);
Parameters
scanThe scan to apply the UDF to.
moduleThe module containing the function to execute.
functionThe function to execute.
arglistThe arguments for the function.
Returns
On success, true. Otherwise an error occurred.
void as_scan_destroy ( as_scan scan)
related

Releases all resources allocated to the scan.

as_scan * as_scan_init ( as_scan scan,
const as_namespace  ns,
const as_set  set 
)
related

Initializes a scan.

as_scan scan;
as_scan_init(&scan, "test", "demo");

When you no longer require the scan, you should release the scan and related resources via as_scan_destroy().

Parameters
scanThe scan to initialize.
nsThe namespace to scan.
setThe set to scan.
Returns
On succes, the initialized scan. Otherwise NULL.
as_scan * as_scan_new ( const as_namespace  ns,
const as_set  set 
)
related

Create and initializes a new scan on the heap.

as_scan * scan = as_scan_new("test","demo");

When you no longer require the scan, you should release the scan and related resources via as_scan_destroy().

Parameters
nsThe namespace to scan.
setThe set to scan.
Returns
On success, a new scan. Otherwise NULL.
bool as_scan_predexp_add ( as_scan scan,
as_predexp_base predexp 
)
related

Adds predicate expressions to a scan.

You have to ensure as_scan.predexp has sufficient capacity, prior to adding a predexp. If capacity is sufficient then false is returned.

Parameters
scanThe scan to modify.
predexpPointer to a constructed predicate expression.
Returns
On success, true. Otherwise an error occurred.
bool as_scan_predexp_init ( as_scan scan,
uint16_t  n 
)
related

Initializes as_scan.predexp with a capacity of n using malloc().

For stack allocation, use as_scan_predexp_inita().

Parameters
scanThe scan to initialize.
nThe number of predicate expression slots to allocate.
Returns
On success, the initialized. Otherwise an error occurred.
#define as_scan_predexp_inita (   __scan,
  __n 
)
related
Value:
if ( (__scan) != NULL && (__scan)->predexp.entries == NULL ) { \
(__scan)->predexp.entries = \
alloca(__n * sizeof(as_predexp_base *)); \
if ( (__scan)->predexp.entries ) { \
(__scan)->predexp._free = false; \
(__scan)->predexp.capacity = __n; \
(__scan)->predexp.size = 0; \
} \
}

Initializes as_scan.predexp with a capacity of n using alloca

For heap allocation, use as_scan_predexp_init().

Parameters
__scanThe scan to initialize.
__nThe number of predicate expression slots to allocate.

Definition at line 593 of file as_scan.h.

bool as_scan_select ( as_scan scan,
const char *  bin 
)
related

Select bins to be projected from matching records.

You have to ensure as_scan.select has sufficient capacity, prior to adding a bin. If capacity is insufficient then false is returned.

as_scan_select(&scan, "bin1");
as_scan_select(&scan, "bin2");
Parameters
scanThe scan to modify.
binThe name of the bin to select.
Returns
On success, true. Otherwise an error occurred.
bool as_scan_select_init ( as_scan scan,
uint16_t  n 
)
related

Initializes as_scan.select with a capacity of n using malloc().

For stack allocation, use as_scan_select_inita().

as_scan_select(&scan, "bin1");
as_scan_select(&scan, "bin2");
Parameters
scanThe scan to initialize.
nThe number of bins to allocate.
Returns
On success, the initialized. Otherwise an error occurred.
bool as_scan_set_nobins ( as_scan scan,
bool  nobins 
)
related

Do not return bins. This will only return the metadata for the records.

Parameters
scanThe scan to set the priority on.
nobinsIf true, then do not return bins.
Returns
On success, true. Otherwise an error occurred.
bool as_scan_set_percent ( as_scan scan,
uint8_t  percent 
)
related

The percentage of data to scan.

Parameters
scanThe scan to set the priority on.
percentThe percent to scan.
Returns
On success, true. Otherwise an error occurred.
bool as_scan_set_priority ( as_scan scan,
as_scan_priority  priority 
)
related

Set the priority for the scan.

Parameters
scanThe scan to set the priority on.
priorityThe priority for the scan.
Returns
On success, true. Otherwise an error occurred.

Field Documentation

bool as_scan::_free
private

If true, then as_scan_destroy() will free this instance.

Definition at line 338 of file as_scan.h.

as_udf_call as_scan::apply_each

Apply the UDF for each record scanned on the server.

Should be set via as_scan_apply_each().

Definition at line 433 of file as_scan.h.

bool as_scan::concurrent

Set to true if the scan should scan all the nodes in parallel

Default value is AS_SCAN_CONCURRENT_DEFAULT.

Definition at line 366 of file as_scan.h.

bool as_scan::deserialize_list_map

Set to true if the scan should deserialize list and map raw bytes. Set to false for backup programs that just need access to raw bytes.

Default value is AS_SCAN_DESERIALIZE_DEFAULT.

Definition at line 383 of file as_scan.h.

bool as_scan::include_ldt

Include large data type bin values in addition to large data type bin names. If false, LDT bin names will be returned, but LDT bin values will be empty. If true, LDT bin names and the entire LDT bin values will be returned. This is useful for backups. Default: false

Definition at line 375 of file as_scan.h.

bool as_scan::no_bins

Set to true if the scan should return only the metadata of the record.

Default value is AS_SCAN_NOBINS_DEFAULT.

Definition at line 359 of file as_scan.h.

Namespace to be scanned.

Should be initialized via either:

Definition at line 394 of file as_scan.h.

uint8_t as_scan::percent

Percentage of the data to scan.

Default value is AS_SCAN_PERCENT_DEFAULT.

Definition at line 352 of file as_scan.h.

as_scan_predexp as_scan::predexp

Predicate Expressions for filtering.

Use either of the following function to initialize:

Use as_query_predexp() to populate.

Definition at line 426 of file as_scan.h.

as_scan_priority as_scan::priority

Priority of scan.

Default value is AS_SCAN_PRIORITY_DEFAULT.

Definition at line 345 of file as_scan.h.

as_scan_bins as_scan::select

Name of bins to select.

Use either of the following function to initialize:

Use as_scan_select() to populate.

Definition at line 415 of file as_scan.h.

as_set as_scan::set

Set to be scanned.

Should be initialized via either:

Definition at line 404 of file as_scan.h.


The documentation for this struct was generated from the following file: