Github user nonstop-qfchen commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/255#discussion_r49477153
--- Diff: core/sql/generator/GenPreCode.cpp ---
@@ -11412,9 +11924,54 @@ RelExpr * HbaseAccess::preCodeGen(Generator *
generator,
}
}
- // add all the key columns. If values are missing in hbase, then
atleast the key
+ // add key columns. If values are missing in hbase, then atleast the
key
// value is needed to retrieve a row.
-
HbaseAccess::addColReferenceFromVIDlist(getIndexDesc()->getIndexKey(),
retColRefSet_);
+ //only if needed. If there is already a non nullable non added non
nullable with default columns in the set, we should not need to add
+ //any other columns.
+ if (CmpCommon::getDefault(HBASE_FILTER_PREDS) == DF_MEDIUM &&
getMdamKeyPtr() == NULL){ //only enable column retrieval optimization with
DF_MEDIUM and not for MDAM scan
+ bool needAddingNonNullableColumn = true; //assume we need to add
one non nullable column
+ for (ValueId vid = retColRefSet_.init();// look for each
column in th eresult set if one match the criteria non null non added non
nullable with default
+ retColRefSet_.next(vid);
+ retColRefSet_.advance(vid))
+ {
+ if (originExePreds->isNotNullable(vid)){// it is non
nullable
+ NAColumn * nac;
+ switch (vid.getItemExpr()->getOperatorType()){
+ case ITM_BASECOLUMN:
+ nac =
((BaseColumn*)vid.getItemExpr())->getNAColumn();
+ break;
+ case ITM_INDEXCOLUMN:
+ nac =
((IndexColumn*)vid.getItemExpr())->getNAColumn();
+ break;
+ default:
+ break;
+ }
+ if (nac && !(nac->isAddedColumn() &&
nac->getDefaultValue())){//check if added and with default... notgood
+ needAddingNonNullableColumn = false; //
we found one column meeting all criteria
--- End diff --
Same comment before. this body of logic should be refactored into a method
on ValueId and we can that method here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---