本文整理汇总了Java中org.eigenbase.reltype.RelDataTypeField类的典型用法代码示例。如果您正苦于以下问题:Java RelDataTypeField类的具体用法?Java RelDataTypeField怎么用?Java RelDataTypeField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RelDataTypeField类属于org.eigenbase.reltype包,在下文中一共展示了RelDataTypeField类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildColumnRowType
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
private ColumnRowType buildColumnRowType() {
List<TblColRef> columns = new ArrayList<TblColRef>();
List<Set<TblColRef>> sourceColumns = new ArrayList<Set<TblColRef>>();
OLAPRel olapChild = (OLAPRel) getChild();
ColumnRowType inputColumnRowType = olapChild.getColumnRowType();
for (int i = 0; i < this.rewriteProjects.size(); i++) {
RexNode rex = this.rewriteProjects.get(i);
RelDataTypeField columnField = this.rowType.getFieldList().get(i);
String fieldName = columnField.getName();
Set<TblColRef> sourceCollector = new HashSet<TblColRef>();
TblColRef column = translateRexNode(rex, inputColumnRowType, fieldName, sourceCollector);
columns.add(column);
sourceColumns.add(sourceCollector);
}
return new ColumnRowType(columns, sourceColumns);
}
示例2: implementRewrite
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
/**
* Because OLAPTableScan is reused for the same table, we can't use
* this.context and have to use parent context
*/
@Override
public void implementRewrite(RewriteImplementor implementor) {
Map<String, RelDataType> rewriteFields = this.context.rewriteFields;
if (implementor.getParentContext() != null) {
rewriteFields = implementor.getParentContext().rewriteFields;
}
for (Map.Entry<String, RelDataType> rewriteField : rewriteFields.entrySet()) {
String fieldName = rewriteField.getKey();
RelDataTypeField field = rowType.getField(fieldName, true);
if (field != null) {
RelDataType fieldType = field.getType();
rewriteField.setValue(fieldType);
}
}
}
示例3: convertCurrentRow
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
private Object[] convertCurrentRow(ITuple tuple) {
// build field index map
if (this.fieldIndexes == null) {
List<String> fields = tuple.getAllFields();
int size = fields.size();
this.fieldIndexes = new int[size];
for (int i = 0; i < size; i++) {
String field = fields.get(i);
RelDataTypeField relField = olapContext.olapRowType.getField(field, true);
if (relField != null) {
fieldIndexes[i] = relField.getIndex();
} else {
fieldIndexes[i] = -1;
}
}
}
// set field value
Object[] values = tuple.getAllValues();
for (int i = 0, n = values.length; i < n; i++) {
Object value = values[i];
int index = fieldIndexes[i];
if (index >= 0) {
current[index] = value;
}
}
return current;
}
示例4: populateResult
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
private boolean populateResult() {
try {
boolean hasNext = rs.next();
if (hasNext) {
for (RelDataTypeField relField : olapContext.olapRowType.getFieldList()) {
Object value = rs.getObject(relField.getName().toLowerCase());
current[relField.getIndex()] = value;
}
}
return hasNext;
} catch (SQLException e) {
throw new IllegalStateException("Can't populate result!", e);
}
}
示例5: buildAliasMap
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
private void buildAliasMap() {
int size = this.rowType.getFieldList().size();
for (int i = 0; i < size; i++) {
RelDataTypeField field = this.rowType.getFieldList().get(i);
TblColRef column = this.columnRowType.getColumnByIndex(i);
context.storageContext.addAlias(column, field.getName());
}
}
示例6: implementRewrite
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
@Override
public void implementRewrite(RewriteImplementor implementor) {
implementor.visitChild(this, this.left);
implementor.visitChild(this, this.right);
this.rowType = this.deriveRowType();
if (this.isTopJoin && RewriteImplementor.needRewrite(this.context)) {
// find missed rewrite fields
int paramIndex = this.rowType.getFieldList().size();
List<RelDataTypeField> newFieldList = new LinkedList<RelDataTypeField>();
for (Map.Entry<String, RelDataType> rewriteField : this.context.rewriteFields.entrySet()) {
String fieldName = rewriteField.getKey();
if (this.rowType.getField(fieldName, true) == null) {
RelDataType fieldType = rewriteField.getValue();
RelDataTypeField newField = new RelDataTypeFieldImpl(fieldName, paramIndex++, fieldType);
newFieldList.add(newField);
}
}
// rebuild row type
FieldInfoBuilder fieldInfo = getCluster().getTypeFactory().builder();
fieldInfo.addAll(this.rowType.getFieldList());
fieldInfo.addAll(newFieldList);
this.rowType = getCluster().getTypeFactory().createStructType(fieldInfo);
this.context.olapRowType = this.rowType;
// rebuild columns
this.columnRowType = this.buildColumnRowType();
}
}
示例7: fillbackOptimizedColumn
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
private void fillbackOptimizedColumn() {
// some aggcall will be optimized out in sub-query (e.g. tableau generated sql)
// we need to fill them back
RelDataType inputAggRow = getChild().getRowType();
RelDataType outputAggRow = getRowType();
if (inputAggRow.getFieldCount() != outputAggRow.getFieldCount()) {
for (RelDataTypeField inputField : inputAggRow.getFieldList()) {
String inputFieldName = inputField.getName();
if (outputAggRow.getField(inputFieldName, true) == null) {
TblColRef column = this.columnRowType.getColumnByIndex(inputField.getIndex());
this.context.metricsColumns.add(column);
}
}
}
}
示例8: rewriteAggregateCall
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
private AggregateCall rewriteAggregateCall(AggregateCall aggCall, FunctionDesc func) {
// rebuild parameters
List<Integer> newArgList = new ArrayList<Integer>(1);
String fieldName = func.getRewriteFieldName();
RelDataTypeField field = getChild().getRowType().getField(fieldName, true);
newArgList.add(field.getIndex());
// rebuild function
RelDataType fieldType = aggCall.getType();
Aggregation newAgg = aggCall.getAggregation();
if (func.isCountDistinct()) {
newAgg = createHyperLogLogAggFunction(fieldType);
} else if (func.isCount()) {
newAgg = new SqlSumEmptyIsZeroAggFunction(fieldType);
}
// rebuild aggregate call
AggregateCall newAggCall = new AggregateCall(newAgg, false, newArgList, fieldType, newAgg.getName());
// To make sure specified type matches the inferReturnType, or otherwise
// there will be assertion failure in optiq
// The problem is BIGINT != BIGINT NOT NULL
// Details see https://github.scm.corp.ebay.com/Kylin/Kylin/issues/323
SqlAggFunction aggFunction = (SqlAggFunction) newAggCall.getAggregation();
AggCallBinding callBinding = newAggCall.createBinding(this);
RelDataType inferReturnType = aggFunction.inferReturnType(callBinding);
return new AggregateCall(newAgg, false, newArgList, inferReturnType, newAgg.getName());
}
示例9: deriveRowType
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
@Override
public RelDataType deriveRowType() {
final List<RelDataTypeField> fieldList = table.getRowType().getFieldList();
final RelDataTypeFactory.FieldInfoBuilder builder = getCluster().getTypeFactory().builder();
for (int field : fields) {
builder.add(fieldList.get(field));
}
return getCluster().getTypeFactory().createStructType(builder);
}
示例10: getFieldList
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
@Override
public List<RelDataTypeField> getFieldList() {
if(fields == null) {
List<RelDataTypeField> ret = new ArrayList<RelDataTypeField>();
RelDataTypeFieldImpl defaultField = new RelDataTypeFieldImpl("*", 0, typeFactory.createSqlType(SqlTypeName.ANY));
ret.add(defaultField);
fieldNames.add("*");
fields = ret;
}
return fields;
}
示例11: getField
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
@Override
public RelDataTypeField getField(String fieldName, boolean caseSensitive) {
for(int i = 0; i < fieldNames.size(); i++) {
if(fieldNames.get(i).equals(fieldName)) {
return fields.get(i);
}
}
throw new RuntimeException("unknow field");
}
示例12: getReturnType
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
public RelDataType getReturnType() {
final RelDataTypeFactory.FieldInfoBuilder builder = new RelDataTypeFactory.FieldInfoBuilder();
for (RelDataTypeField field : super.deriveRowType().getFieldList()) {
String name = field.getName();
int index = super.deriveRowType().getFieldOrdinal(name);
builder.add(new RelDataTypeFieldImpl(name, index, getCluster().getTypeFactory().createJavaType(List.class)));
}
return getCluster().getTypeFactory().createStructType(builder);
}
示例13: visitInputRef
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
@Override
public ChildVisitor visitInputRef(RexInputRef inputRef) {
final int index = inputRef.getIndex();
final RelDataTypeField field = input.getRowType().getFieldList().get(index);
return new Field(field.getName());
}
示例14: implementRewrite
import org.eigenbase.reltype.RelDataTypeField; //导入依赖的package包/类
@Override
public void implementRewrite(RewriteImplementor implementor) {
implementor.visitChild(this, getChild());
this.rewriting = true;
// project before join or is just after OLAPToEnumerableConverter
if (!RewriteImplementor.needRewrite(this.context) || (this.hasJoin && !this.afterJoin) || this.afterAggregate) {
this.columnRowType = this.buildColumnRowType();
return;
}
// find missed rewrite fields
int paramIndex = this.rowType.getFieldList().size();
List<RelDataTypeField> newFieldList = new LinkedList<RelDataTypeField>();
List<RexNode> newExpList = new LinkedList<RexNode>();
ColumnRowType inputColumnRowType = ((OLAPRel) getChild()).getColumnRowType();
for (Map.Entry<String, RelDataType> rewriteField : this.context.rewriteFields.entrySet()) {
String rewriteFieldName = rewriteField.getKey();
int rowIndex = this.columnRowType.getIndexByName(rewriteFieldName);
if (rowIndex < 0) {
int inputIndex = inputColumnRowType.getIndexByName(rewriteFieldName);
if (inputIndex >= 0) {
// new field
RelDataType fieldType = rewriteField.getValue();
RelDataTypeField newField = new RelDataTypeFieldImpl(rewriteFieldName, paramIndex++, fieldType);
newFieldList.add(newField);
// new project
RelDataTypeField inputField = getChild().getRowType().getFieldList().get(inputIndex);
RexInputRef newFieldRef = new RexInputRef(inputField.getIndex(), inputField.getType());
newExpList.add(newFieldRef);
}
}
}
if (!newFieldList.isEmpty()) {
// rebuild projects
List<RexNode> newProjects = new ArrayList<RexNode>(this.rewriteProjects);
newProjects.addAll(newExpList);
this.rewriteProjects = newProjects;
// rebuild row type
FieldInfoBuilder fieldInfo = getCluster().getTypeFactory().builder();
fieldInfo.addAll(this.rowType.getFieldList());
fieldInfo.addAll(newFieldList);
this.rowType = getCluster().getTypeFactory().createStructType(fieldInfo);
}
// rebuild columns
this.columnRowType = this.buildColumnRowType();
this.rewriting = false;
}