public void writeIndexes ( JobKey jobKey ) throws IOException { // Defensive coding if ( jobKey != null ) { Table historyByJobIdTable = null ; try { historyByJobIdTable = hbaseConnection . getTable ( TableName . valueOf ( Constants . HISTORY_BY_JOBID_TABLE ) ) ; byte [ ] jobKeyBytes = jobKeyConv . toBytes ( jobKey ) ; byte [ ] rowKeyBytes = jobIdConv . toBytes ( new QualifiedJobId ( jobKey . getCluster ( ) , jobKey . getJobId ( ) ) ) ; // Insert (or update) row with jobid as the key Put p = new Put ( rowKeyBytes ) ; p . addColumn ( Constants . INFO_FAM_BYTES , Constants . ROWKEY_COL_BYTES , jobKeyBytes ) ; historyByJobIdTable . put ( p ) ; } finally { if ( historyByJobIdTable != null ) { historyByJobIdTable . close ( ) ; } } } }
Create the secondary indexes records cluster!jobId - > jobKey .