btree_search

Directory

eXtremeDB_rt/samples/btree_search

Description

'search' demonstrates search operations with tree indexes.

Used API

classname_indexname_search()

Code snippet

 
    /* Show objects with value > search_value */
          rc = mco_trans_start(db, MCO_READ_ONLY, MCO_TRANS_FOREGROUND, &t);
          if ( MCO_S_OK == rc )  {
            rc = anObject_Idx_index_cursor(t, &csr);    
            if ( MCO_S_OK == rc ) {
              printf("\nObjects with value  >  %d : ", search_value);
              for (rc = anObject_Idx_search(t, &csr, MCO_GT, search_value); MCO_S_OK == rc; rc = mco_cursor_next(t, &csr)) {
                anObject_from_cursor(t, &csr, &obj);
                anObject_value_get(&obj, &value);
                printf("(%d) ", value);
              }

What to expect as an output

 
    All objects             : (1) (2) (2) (3) (3) (3) (4) (4) (5) (5) (5) 
    Objects with value  > 3 : (4) (4) (5) (5) (5) 
    Objects with value >= 3 : (3) (3) (3) (4) (4) (5) (5) (5) 
    Objects with value == 3 : (3) (3) (3) 
    Objects with value <= 3 : (3) (3) (3) (2) (2) (1) 
    Objects with value  <3 : (2) (2) (1)