Viewing a Created Index
The listIndices API is used to view index information.
listIndices API
- listIndices API
void listIndices(TableName tableName)
- Function description
Clients call this API to query indexes. It returns information about all index tables of a specified data table.
- API description
- Package name: package com.huawei.boostkit.hindex
- Class name: GlobalIndexAdmin
- Method name: listIndices
- Parameter description:
Parameter
Value
Description
tableName
TableName
User data table.
- Example
// Create a user table myuser and add data. Admin admin = connection.getAdmin(); TableName myuser = TableName.valueOf("myuser"); HTableDescriptor hTableDescriptor = new HTableDescriptor(myuser); HColumnDescriptor f1 = new HColumnDescriptor("f1"); hTableDescriptor.addFamily(f1); admin.createTable(hTableDescriptor); try (Table table = conn.getTable(myuser)) { Put put0 = new Put(Bytes.toBytes("001")); put0.addColumn(Bytes.toBytes("f1"), Bytes.toBytes("q1"), Bytes.toBytes("test")); table.put(ImmutableList.of(put0)); } // Create an index table myindex. TableIndices myindex = new TableIndices(); HIndexSpecification spec = new HIndexSpecification("myindex"); // Create an index for q1 in the f1 column family of the data table. The data type is STRING. spec.addIndexColumn(Bytes.toBytes("f1"), Bytes.toBytes("q1"), ValueType.STRING); myindex.addIndex(spec); GlobalIndexAdmin globalIndexAdmin = GlobalIndexClient.newIndexAdmin(admin); globalIndexAdmin.addIndicesWithData(myuser, myindex); // View all index tables of myuser. List<Pair<HIndexSpecification, IndexState>> indices = globalIndexAdmin.listIndices(myuser); - Result
Parent topic: APIs of Global Indexes