Index Operations

WideTable exposes the API for adding indexes. Following APIs are to deal with indexes;

To create index;

int addIndex(char *idx_name, table_env *tenv);

and to drop index;

int dropIndex(char *idx_name);

For adding index, user can define the table_env and set proper values as required. For ex;

	table_env te;
	te.set_key_size_byte(24);
	te.set_idx_type(BTREE);
	te.set_sort_method(LEXICOGRAPH);
	te.set_sort_dirction(SORT_ASCENDING);
	te.set_persist_type(INMEM_PERSIST);
	te.set_allow_duplicate(true);

	if(addIndex("first_name", &te) < 0)
		bangdb_logger("error in creating index");
	
	

For two special use cases following APIs are provided for simplicity. When user wishes to create index on string filed value then following can be used; If you wish to override any table_env property here then should define the table_env object and call adIndex();

//always crates index with following property BTREE, INMEM_PERSIST, QUASI_LEXICOGRAPH, SORT_ASCENDING, log = off

int addIndex_str(char *idx_name, int idx_size, bool allowDuplicates);

On the other hand if you wish to create index on number field (int, long etc) then the following API comes handy.

int addIndex_num(char *idx_name, bool allowDuplicates);

Dropping index is simple, just call the dropIndex() API with the name of the index.