Changing Index Status
The index status in the index information reflects the current index usage. The index status can be ACTIVE, UNUSABLE, INACTIVE, BUILDING, or DROPPING. You can run commands to change the index status.
Index Status
The status of an index reflects how the index is being used. A global secondary index (GSI) can be in one of the five states:
- ACTIVE: The index is normal and can be read and written properly.
- UNUSABLE: The index is disabled. The index data is updated properly, but the index cannot be used for data query.
- INACTIVE: The index is abnormal. The index data is inconsistent with the data table and is not updated. The index cannot be used during data query.
- BUILDING: The index data is being generated. After the index data generation tool is executed, the index enters the ACTIVE state. When an index is in the BUILDING state, the associated data table cannot be modified.
- DROPPING: The index is being deleted and cannot be used for data query.
Figure 1 shows the conditions for index status changes.
Scenarios
You can use the GSI tool or call the API to change the index status.
How to Use
Run the following command to enable or disable an index:
hbase com.huawei.boostkit.hindex.mapreduce.GlobalTableIndexer -Dtablename.to.index='table' -D[idx_state_opt]='idx1'
Parameter description:
- tablename.to.index: Name of the data table where the index whose status you want to change is located.
- idx_state_opt: target status of the index. The optional values are as follows:
- indexnames.to.inactive: changes the index status to INACTIVE.
- indexnames.to.active: changes the index status to ACTIVE.
- indexnames.to.unusable: changes the index status to UNUSABLE.
For example, change the status of the idx_1 index of the tablename table whose status is ACTIVE to UNUSABLE.
1
|
hbase com.huawei.boostkit.hindex.mapreduce.GlobalTableIndexer -Dtablename.to.index='tablename' -Dindexnames.to.unusable='idx_1' |
After the command is executed, view the index information.
1
|
hbase com.huawei.boostkit.hindex.mapreduce.GlobalTableIndexer -Dtablename.to.show=tablename |
The command output shows that the status of idx_1 has been changed to UNUSABLE.
1 2 3 |
The index information of table : IndexName : idx_0, IndexColumns : [cf_0:q_0 -> type:STRING, cf_0:q_1 -> type:STRING], CoveredColumns : [cf_0:q_0 -> type:STRING], IndexState : ATIVE IndexName : idx_1, IndexColumns : [cf_0:q_0 -> type:STRING, cf_0:q_1 -> type:STRING, cf_0:q_2 -> type:STRING], CoveredColumns : [], IndexState : UNUSABLE |
