AerospikeC client manual --- Big Data Type

Source: Internet
Author: User
Tags configuration settings aerospike

AerospikeC client manual --- Big Data Type
Big Data Type overview big data type (LDT) is a complex object that resides on the Aerospike server and maintained by applications through UDF. The data associated with LDT is not transmitted to the client unless otherwise specified by the client. In normal use, the client operates part of the data-a single object or a group of objects-through the released API.
See [LDT function Guide] to obtain general LDT knowledge.
The action list Stack (Large Stack) operates aerospike_lstack_push ()-the new object of the Stack.
Aerospike_lstack_pushall ()-a series of objects on the pressure stack.
Aerospike_lstack_peek ()-N elements at the top of the stack.
Aerospike_lstack_filter ()-scan the entire stack and apply a predicate filter.
Aerospike_lstack_destroy ()-delete the entire stack (LDT Remove ).
Aerospike_lstack_get_capacity ()-Get the current stack Capacity Limit settings.
Aerospike_lstack_set_capacity ()-set the maximum stack capacity.
Aerospike_lstack_size ()-Get the current number of items in the stack.
Aerospike_lset_config ()-Get the stack configuration parameters. Set (Large Set) operation aerospike_lset_add ()-add an object to the Set.
Aerospike_lset_addall ()-adds a series of objects to the set.
Aerospike_lset_remove ()-removes an object from the set.
Aerospike_lset_exists ()-test whether an object exists in the collection.
Aerospike_lset_get ()-obtains an object from the collection.
Aerospike_lset_filter ()-scan the entire set and apply a predicate filter.
Aerospike_lset_destroy ()-delete the entire set (LDT Remove ).
Aerospike_lset_size ()-Get the current number of entries in the set.
Aerospike_lset_config ()-Get the set configuration parameters. Map (Large Map) operation aerospike_lmap_add ()-add object to ing.
Aerospike_lmap_addall ()-adds a series of objects to the ing.
Aerospike_lmap_remove ()-removes an object from the ing.
Aerospike_lmap_get ()-Get an object from the ing.
Aerospike_lmap_filter ()-scan the entire ing and apply a predicate filter.
Aerospike_lmap_destroy ()-delete the entire ing (LDT Remove )..
Aerospike_lmap_size ()-gets the number of current projects mapped.
Aerospike_lmap_config ()-Get the ing configuration parameters. The linked List (Large List) operation aerospike_llist_add ()-adds an object to the List.
Aerospike_llist_addall ()-adds a series of objects to the list.
Aerospike_llist_remove ()-removes an object from the list.
Aerospike_llist_get ()-obtains an object from the list.
Aerospike_llist_filter ()-scan the entire list and apply a predicate filter.
Aerospike_llist_destroy ()-delete the entire list (LDT Remove ).
Aerospike_llist_size ()-Get the current number of entries in the list.
Aerospike_llist_config ()-Get the list configuration parameters. Example

Here is a basic example program to demonstrate the initial creation of big data objects and some basic operations:

#include 
  
   #include 
   
    #include 
    
     #include 
     
      #include #include #include #include #include #include #include #include #include #include #include "example_utils.h"int main(int argc, char* argv[]){    // Parse command line arguments.    if (! example_get_opts(argc, argv, EXAMPLE_BASIC_OPTS)) {        exit(-1);    }    // Connect to the aerospike database cluster.    aerospike as;    example_connect_to_aerospike(&as);    // Start clean.    example_remove_test_record(&as);    as_ldt lset;    // Create a lset bin to use. No need to destroy as_ldt if using    // as_ldt_init() on stack object.    if (! as_ldt_init(&lset, "mylset", AS_LDT_LSET, NULL)) {        LOG("unable to initialize ldt");        exit(-1);    }    as_error err;    // No need to destroy as_integer if using as_integer_init() on stack object.    as_integer ival;    as_integer_init(&ival, 12345);    // Add an integer value to the set.    if (aerospike_lset_add(&as, &err, NULL, &g_key, &lset,            (const as_val*)&ival) != AEROSPIKE_OK) {        LOG("first aerospike_set_add() returned %d - %s", err.code,                err.message);        exit(-1);    }    // No need to destroy as_string if using as_string_init() on stack object.    as_string sval;    as_string_init(&sval, "lset value", false);    // Add a string value to the set.    if (aerospike_lset_add(&as, &err, NULL, &g_key, &lset,            (const as_val*)&sval) != AEROSPIKE_OK) {        LOG("second aerospike_set_add() returned %d - %s", err.code,                err.message);        exit(-1);    }    LOG("2 values added to set");    uint32_t n_elements = 0;    // See how many elements we have in the set now.    if (aerospike_lset_size(&as, &err, NULL, &g_key, &lset, &n_elements)            != AEROSPIKE_OK) {        LOG("aerospike_lset_size() returned %d - %s", err.code, err.message);        exit(-1);    }    if (n_elements != 2) {        LOG("unexpected lset size %u", n_elements);        exit(-1);    }    LOG("lset size confirmed to be %u", n_elements);    as_ldt lset2;    as_ldt_init(&lset2, "mylset", AS_LDT_LSET, NULL);    as_list* p_list = NULL;    // Get all the values back.    if (aerospike_lset_filter(&as, &err, NULL, &g_key, &lset, NULL, NULL,            &p_list) != AEROSPIKE_OK) {        LOG("aerospike_lset_filter() returned %d - %s", err.code, err.message);        as_list_destroy(p_list);        exit(-1);    }    // See if the elements match what we expect.    as_arraylist_iterator it;    as_arraylist_iterator_init(&it, (const as_arraylist*)p_list);    while (as_arraylist_iterator_has_next(&it)) {        const as_val* p_val = as_arraylist_iterator_next(&it);        LOG("   element - type = %d, value = %s ", as_val_type(p_val),                as_val_tostring(p_val));    }    as_list_destroy(p_list);    p_list = NULL;    // Add 3 more items into the set. By using as_arraylist_inita(), we won't    // need to destroy the as_arraylist if we only use    // as_arraylist_append_int64().    as_arraylist vals;    as_arraylist_inita(&vals, 3);    as_arraylist_append_int64(&vals, 1001);    as_arraylist_append_int64(&vals, 2002);    as_arraylist_append_int64(&vals, 3003);    if (aerospike_lset_addall(&as, &err, NULL, &g_key, &lset,            (const as_list*)&vals) != AEROSPIKE_OK) {        LOG("aerospike_lset_addall() returned %d - %s", err.code, err.message);        exit(-1);    }    LOG("3 more values added");    // Get and print all the values back again.    if (aerospike_lset_filter(&as, &err, NULL, &g_key, &lset, NULL, NULL,            &p_list) != AEROSPIKE_OK) {        LOG("second aerospike_lset_filter() returned %d - %s", err.code,                err.message);        as_list_destroy(p_list);        exit(-1);    }    as_arraylist_iterator_init(&it, (const as_arraylist*)p_list);    while (as_arraylist_iterator_has_next(&it)) {        const as_val* p_val = as_arraylist_iterator_next(&it);        LOG("   element - type = %d, value = %s ", as_val_type(p_val),                as_val_tostring(p_val));    }    as_list_destroy(p_list);    p_list = NULL;    // No need to destroy as_boolean if using as_boolean_init() on stack object.    as_boolean exists;    as_boolean_init(&exists, false);    // Check if a specific value exists.    if (aerospike_lset_exists(&as, &err, NULL, &g_key, &lset2,            (const as_val*)&ival, &exists) != AEROSPIKE_OK) {        LOG("aerospike_lset_exists() returned %d - %s", err.code, err.message);        exit(-1);    }    if (as_boolean_get(&exists)) {        LOG("not able to find a value which should be in the set");        exit(-1);    }    as_boolean_init(&exists, false);    as_integer_init(&ival, 33333);    // Check that a value which should not be in the set, really isn't.    if (aerospike_lset_exists(&as, &err, NULL, &g_key, &lset2,            (const as_val*)&ival, &exists) != AEROSPIKE_OK) {        LOG("second aerospike_lset_exists() returned %d - %s", err.code,                err.message);        exit(-1);    }    if (as_boolean_get(&exists)) {        LOG("found a value which should not be in the set");        exit(-1);    }    LOG("existence functionality checked");    // Destroy the lset.    if (aerospike_lset_destroy(&as, &err, NULL, &g_key, &lset) !=            AEROSPIKE_OK) {        LOG("aerospike_lset_destroy() returned %d - %s", err.code, err.message);        exit(-1);    }    n_elements = 0;    // See if we can still do any lset operations.    if (aerospike_lset_size(&as, &err, NULL, &g_key, &lset, &n_elements) ==            AEROSPIKE_OK) {        LOG("aerospike_lset_size() did not return error");        exit(-1);    }    // Cleanup and disconnect from the database cluster.    example_cleanup(&as);    LOG("lset example successfully completed");    return 0;}
     
    
   
  
Summary

By default, LDT accepts and stores any type of objects. Objects can be of different types and sizes. The only additional condition is that if the object is of a complex type, the LDT linked List mechanism requires a map with a Key ), or a user-provided function to calculate/identify an atomic value for object sorting.

Special behavior: module, conversion, storage settings change, and predicate filter

LDT is expected to be "out-of-the-box ". That is to say, the default configuration and behavior work for most use cases and data types. By default, LDT stores objects in a linked list and uses the standard serialization mechanism (MSGPACK) to serialize objects. In such a scenario, users can directly convert objects into binary to save a lot of space, or precisely know the size of the stored objects, you also want to precisely control the storage size of sub-records, or you want to change the internal storage size and restrictions to optimize LDT performance. In this case, Aeropsike provides users with capabilities, to change the system configuration settings of LDT, specify the conversion/reverse Conversion Function, specify the unique identifier function and the predicate filter function that can be used as a complex object.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.