Adding Fields to a Previously Defined Space
ActiveSpaces allows you to alter the fields in a space that is already defined by using the as-admin utility or by calling Metaspace.alterspace(). The C API and the .NET API provide equivalent operations. There is no disruption in service when you alter the space.
Any new fields that you add must be nullable. If the space has not yet been defined or the space definition is incompatible with the one that is defined (for example, has new fields that are not nullable), ActiveSpaces generates an exception describing what was incorrect.
for( int j=0; j<500; j++){ spaceDef = space.getSpaceDef(); FieldDef newFieldDf = FieldDef.create("FieldId"+j, FieldType.INTEGER); newFieldDf.setNullable(true); space.putFieldDef(lNewFieldDf); metaspace.alterSpace(lSpaceDf); }The following is a good example:
for( int j=0; j<500; j++) { spaceDef = space.getSpaceDef(); FieldDef newFieldDf = FieldDef.create("FieldId"+j, FieldType.INTEGER); newFieldDf.setNullable(true); space.putFieldDef(lNewFieldDf); } metaspace.alterSpace(lSpaceDf);
Adding and Dropping Indexes
ActiveSpaces allows you to add indexes to a space that is already defined or drop indexes from the space. You can add or drop indexes by using the as-admin utility or by calling Metaspace.alterspace(). The C API and the .NET API provide equivalent operations. There is no disruption in service. ActiveSpaces builds the new indexes in the background, and when they are ready, sues them automatically to optimize queries.
The following example shows how to add and drop an index using the Java API.
SpaceDef spaceDef = metaspace.getSpaceDef(“test”); spacedef.removeIndexDef(“index1”); spaceDef.addIndexDef(…) spaceDef.addIndexDef(…) spaceDef.putFieldDef(FieldDef….) metaspace.alterSpace(spaceDef);