for (IndexSpecification index : indices) {
Set<ColumnQualifier> indexColumns = index.getIndexColumns();
// Don't worry . This Set is LinkedHashSet. So this will maintain the order.
Iterator<ColumnQualifier> indexColumnsIterator = indexColumns.iterator();
ColumnQualifier firstCQInIndex = indexColumnsIterator.next();
Column firstColInIndex =
new Column(firstCQInIndex.getColumnFamily(), firstCQInIndex.getQualifier(),
firstCQInIndex.getValuePartition());
if (firstColInIndex.equals(detail.column)) {
possibleUseIndices.add(new Pair<IndexSpecification, Integer>(index, indexColumns.size()));
// When we have condition on col1 and we have indices on col1&Col2 and col1&col3
// which one we should select? We dont know the data related details of every index.
// So select any one. May be the 1st come selected.
// TODO later we can add more intelligence and then add index level data details
if (indexColumns.size() < bestFitIndexColsSize) {
bestFitIndex = index;
bestFitIndexColsSize = indexColumns.size();
}
detail.maxValueLength = firstCQInIndex.getMaxValueLength();
detail.valueType = firstCQInIndex.getType();
}
// This index might be useful at a topper level....
// I will explain in detail
// When the filter from customer is coming this way as shown below
// &
// ___|___
// | |
// c1=10 c2=5
// Suppose we have an index on c2&c1 only on the table, when we check for c1=10 node
// we will not find any index for that as index is not having c1 as the 1st column.
// For c2=5 node, the index is a possible option. Now when we consider the & node,
// the index seems perfect match. That is why even for the c1=10 node also, we can not
// sat it is a NoIndexFilterNode, if there are any indices on the table which contain c1
// as one column in the index columns.
else {
ColumnQualifier cq = null;
Column column = null;
while (indexColumnsIterator.hasNext()) {
cq = indexColumnsIterator.next();
column = new Column(cq.getColumnFamily(), cq.getQualifier(), cq.getValuePartition());
if (column.equals(detail.column)) {
possibleFutureUseIndices.add(new Pair<IndexSpecification, Integer>(index, indexColumns
.size()));
detail.maxValueLength = firstCQInIndex.getMaxValueLength();
detail.valueType = firstCQInIndex.getType();
break;