All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Fields | 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.

as_scan_set_percent(scan, 100);

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:

as_scan_set_priority(scan, AS_SCAN_PRIORITY_LOW);

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 257 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 no_bins
 
as_namespace ns
 
struct as_operations_s * ops
 
bool paginate
 
as_partitions_statusparts_all
 
as_scan_bins select
 
as_set set
 
uint32_t ttl
 

Related Functions

(Note that these are not member functions.)

AS_EXTERN bool as_scan_apply_each (as_scan *scan, const char *module, const char *function, as_list *arglist)
 
AS_EXTERN bool as_scan_compare (as_scan *s1, as_scan *s2)
 
AS_EXTERN void as_scan_destroy (as_scan *scan)
 
AS_EXTERN bool as_scan_from_bytes (as_scan *scan, const uint8_t *bytes, uint32_t bytes_size)
 
AS_EXTERN as_scanas_scan_from_bytes_new (const uint8_t *bytes, uint32_t bytes_size)
 
AS_EXTERN as_scanas_scan_init (as_scan *scan, const char *ns, const char *set)
 
static bool as_scan_is_done (as_scan *scan)
 
AS_EXTERN as_scanas_scan_new (const char *ns, const char *set)
 
AS_EXTERN bool as_scan_select (as_scan *scan, const char *bin)
 
AS_EXTERN bool as_scan_select_init (as_scan *scan, uint16_t n)
 
AS_EXTERN bool as_scan_set_nobins (as_scan *scan, bool nobins)
 
static void as_scan_set_paginate (as_scan *scan, bool paginate)
 
static void as_scan_set_partitions (as_scan *scan, as_partitions_status *parts_all)
 
AS_EXTERN bool as_scan_to_bytes (const as_scan *scan, uint8_t **bytes, uint32_t *bytes_size)
 

Friends And Related Function Documentation

AS_EXTERN 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.
AS_EXTERN bool as_scan_compare ( as_scan s1,
as_scan s2 
)
related

Compare scan objects.

AS_EXTERN void as_scan_destroy ( as_scan scan)
related

Releases all resources allocated to the scan.

AS_EXTERN bool as_scan_from_bytes ( as_scan scan,
const uint8_t *  bytes,
uint32_t  bytes_size 
)
related

Deserialize bytes to scan definition. Scan definition is assumed to be on the stack. as_scan_destroy() should be called when done with the scan definition.

Returns
true on success and false on failure.
AS_EXTERN as_scan * as_scan_from_bytes_new ( const uint8_t *  bytes,
uint32_t  bytes_size 
)
related

Create scan definition on the heap and deserialize bytes to that scan definition. as_scan_destroy() should be called when done with the scan definition.

Returns
scan definition on success and NULL on failure.
AS_EXTERN as_scan * as_scan_init ( as_scan scan,
const char *  ns,
const char *  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.
static bool as_scan_is_done ( as_scan scan)
related

If using scan pagination, did previous paginated scan with this scan instance return all records?

Definition at line 593 of file as_scan.h.

References as_partitions_status::done, and parts_all.

AS_EXTERN as_scan * as_scan_new ( const char *  ns,
const char *  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.
AS_EXTERN 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.
AS_EXTERN 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.
AS_EXTERN 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.
static void as_scan_set_paginate ( as_scan scan,
bool  paginate 
)
related

Set to true if as_policy_scan.max_records is set and you need to scan data in pages.

Definition at line 567 of file as_scan.h.

References paginate.

static void as_scan_set_partitions ( as_scan scan,
as_partitions_status parts_all 
)
related

Set completion status of all partitions from a previous scan that ended early. The scan will resume from this point.

Definition at line 580 of file as_scan.h.

References as_partitions_status_reserve(), and parts_all.

AS_EXTERN bool as_scan_to_bytes ( const as_scan scan,
uint8_t **  bytes,
uint32_t *  bytes_size 
)
related

Serialize scan definition to bytes.

Field Documentation

as_udf_call as_scan::apply_each

UDF to apply to results of the background scan.

Should be set via as_scan_apply_each().

Definition at line 294 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 340 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 348 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 333 of file as_scan.h.

Namespace to be scanned.

Should be initialized via either:

Definition at line 267 of file as_scan.h.

struct as_operations_s* as_scan::ops

Perform write operations on a background scan. If ops is set, ops will be destroyed when as_scan_destroy() is called.

Definition at line 300 of file as_scan.h.

bool as_scan::paginate

Set to true if as_policy_scan.max_records is set and you need to scan data in pages.

Default: false

Definition at line 326 of file as_scan.h.

as_partitions_status* as_scan::parts_all

Status of all partitions.

Definition at line 305 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 287 of file as_scan.h.

as_set as_scan::set

Set to be scanned.

Should be initialized via either:

Definition at line 276 of file as_scan.h.

uint32_t as_scan::ttl

The time-to-live (expiration) of the record in seconds. Note that ttl is only used on background scan writes.

There are also special values that can be set in the record ttl:

  • AS_RECORD_DEFAULT_TTL: Use the server default ttl from the namespace.
  • AS_RECORD_NO_EXPIRE_TTL: Do not expire the record.
  • AS_RECORD_NO_CHANGE_TTL: Keep the existing record ttl when the record is updated.
  • AS_RECORD_CLIENT_DEFAULT_TTL: Use the default client ttl in as_policy_scan.

Definition at line 319 of file as_scan.h.


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