WYRDTEK Home Features Reference Downloads About


Reference/es_mbc_addfldidx

Syntax

int es_mbc_addfldidx( struct es_mbc *cls, const char *fldnm );

Arguments

struct es_mbc *cls A database class.
const char *fieldnm Field name.

Return Codes

ES_ERROR_NONE Success. No errors.
ES_ERROR_INVALIDINDEX Cannot add index fields to a subclass if the super class has a shared index (ES_INDEX_SHARED).
ES_ERROR_INDEXDEFINED Cannot add more than one field to a None index (ES_INDEX_NONE).
ES_ERROR_UNKNOWNFIELD Field has not been added to class.
ES_ERROR_INVALIDINDEXTYPE Field is not of an integer type.

Description

Add a field to the index definition of a class. The set of all index fields must constitute a unique key for the class, unless the class is designated as ES_INDEX_NONE and has been assigned no index fields.

The index of a class is defined when the class is created, via a call to es_mbc_new. Depending on the type of the index, one or more fields may be added to the index definition via es_mbc_addfldidx. The field must first be defined and added to the class via es_mbc_addfld.

Only integer fields (i.e. 8,16,32 or 64bit integers) may form part of an index.

The order in which es_mbc_addfld() is invoked determines the ordering of fields in an index. This can impact the performance of look-up operations as described in the Index Types section.

  /* construct root class "Sales" and add three database field definitions */
  struct es_mbc *c_sales;
  es_mbc_new( schema, "Sales", 4096, ES_INDEX_PRIVATE, NULL, &c_sales );
  es_mbc_addfld( c_sales, "ProductId", ES_FLDTYPE_I16 );
  es_mbc_addfld( c_sales, "CustomerId", ES_FLDTYPE_I32 );
  es_mbc_addfld( c_sales, "UnitSales", ES_FLDTYPE_F64 );

  /* define ProductId and CustomerId to be the key */
  es_mbc_addfldidx( c_sales, "ProductId" );
  es_mbc_addfldidx( c_sales, "CustomerId" );

[Back To Reference] [Back To Reference/es_mbc]