// For local indexes, we optimize the initial index population by *not* sending Puts over
// the wire for the index rows, as we don't need to do that. Instead, we tap into our
// region observer to generate the index rows based on the data rows as we scan
if (index.getIndexType() == IndexType.LOCAL) {
final PhoenixStatement statement = new PhoenixStatement(connection);
String tableName = getFullTableName(dataTableRef);
String query = "SELECT count(*) FROM " + tableName;
QueryPlan plan = statement.compileQuery(query);
TableRef tableRef = plan.getContext().getResolver().getTables().get(0);
// Set attribute on scan that UngroupedAggregateRegionObserver will switch on.
// We'll detect that this attribute was set the server-side and write the index
// rows per region as a result. The value of the attribute will be our persisted
// index maintainers.