Space Definition Through the API
By calling the SpaceDef functions or methods provided in the ActiveSpaces API you can specify the basic attributes and policies for a space.
Using the SpaceDef Object
In the Java API, defining a space is done using the defineSpace method of the Metaspace object, which takes a SpaceDef object as its sole parameter. In the C API, you define a space by calling the tibasSpaceDef_Create() function.
If the space was already defined in the metaspace, then defineSpace compares the space definition that was passed to it as an argument with the space definition currently stored in the metaspace; if the definitions match then defineSpace returns successfully, otherwise an error is thrown.
Using the Admin Object
A space can also be defined through the API by using the admin object’s execute method to execute a define Space admin language command.
The following example shows how to create a space using the admin object using the Java API:
//In the following code, assume that 'ms' is the Metaspace object Admin admin = Admin.create(); String adminCmd = "define space name 'myspace' (field name 'key' type 'integer', field name 'value' type 'string') key (fields('key'))"; admin.execute(ms, adminCmd); ************* //The C API uses tibasAdmin_Execute(), with more parameters but in a similar fashion.