primaryKey, this.buildEntityColumnsForGet(table, metaEventOperation,
selectItem));
((GetAction)action).setForUpdate(queryInfo.isForUpdate());
if (context.isGenWholePlan()) {
// get entityGroupLocation according to entity group key.
EntityGroupLocation entityGroupLocation = this.connection
.locateEntityGroup(Bytes.toBytes(table.getTableName()), DruidParser
.convert(
table.getColumn(entityGroupKeyCondition.getFieldName()),
entityGroupKeyCondition.getValue()));
action.setEntityGroupLocation(entityGroupLocation);
}
qp = new LocalQueryPlan((GetAction) action);
LOG.debug(QueryInfo.QueryType.GET + " "
+ Bytes.toStringBinary(primaryKey) + " from " + table.getTableName());
} else if (queryInfo.getType() == QueryInfo.QueryType.SCAN) {
Index index = metaEventOperation.checkAndGetIndex(table,
queryInfo.getAllConditionFieldName());
if (index == null) {
throw new UnsupportedException("Don't get a Index!");
}
boolean isJustUseIndex = index.getIndexKeys().size() >= queryInfo.getAllConditionFieldName().size();
Pair<byte[], byte[]> startKeyAndEndKey = metaEventOperation.getStartkeyAndEndkey(index, queryInfo);
Pair<List<ColumnStruct>, List<ColumnStruct>> columnActionPair = this
.buildEntityColumnsForScan(table, index, metaEventOperation,
selectItem);
List<ColumnStruct> selectEntityColumns = columnActionPair.getFirst();
List<ColumnStruct> selectStoringColumns = columnActionPair.getSecond();
List<ColumnStruct> conditionNotInIndex = isJustUseIndex ? Collections.<ColumnStruct>emptyList()
: buildColumnsNotInIndex(table, index, queryInfo);
// instance scan action.
action = new ScanAction(context.getReadModel(),
StorageTableNameBuilder.buildIndexTableName(index),
table.getTableName(), startKeyAndEndKey.getFirst(),
startKeyAndEndKey.getSecond(), selectEntityColumns);
((ScanAction) action).setStoringColumns(selectStoringColumns);
((ScanAction) action).setLimit(limit);
((ScanAction) action).setNotIndexConditionColumns(conditionNotInIndex);
if (entityGroupKeyCondition != null
&& entityGroupKeyCondition.getType() == ConditionType.EQUAL) {
if (context.isGenWholePlan()) {
EntityGroupLocation entityGroupLocation = this.connection
.locateEntityGroup(Bytes.toBytes(table.getTableName()),
DruidParser.convert(
table.getColumn(entityGroupKeyCondition.getFieldName()),
entityGroupKeyCondition.getValue()));
action.setEntityGroupLocation(entityGroupLocation);