当前位置: 首页>>代码示例>>Java>>正文


Java RelDataTypeFactory.builder方法代码示例

本文整理汇总了Java中org.apache.calcite.rel.type.RelDataTypeFactory.builder方法的典型用法代码示例。如果您正苦于以下问题:Java RelDataTypeFactory.builder方法的具体用法?Java RelDataTypeFactory.builder怎么用?Java RelDataTypeFactory.builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.rel.type.RelDataTypeFactory的用法示例。


在下文中一共展示了RelDataTypeFactory.builder方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRowType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RelDataType getRowType(RelDataTypeFactory typeFactory)
{
  RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
  if (fieldMapping != null) {
    for (Map.Entry<String, Class> entry : fieldMapping.entrySet()) {
      builder.add(entry.getKey(), convertField(typeFactory, entry.getValue()));
    }
  } else if (pojoClass != null) {
    for (Field field : pojoClass.getDeclaredFields()) {
      builder.add(field.getName(), convertField(typeFactory, field.getType()));
    }
  } else {
    throw new RuntimeException("Either fieldMapping or pojoClass needs to be set.");
  }

  return builder.build();
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:19,代码来源:StreamEndpoint.java

示例2: OctopusTable

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public OctopusTable(MetaTable metaTable, OctopusSchema schema) {
    super(Object[].class);
    name = metaTable.getName();

    try {
        //tableType = Schema.TableType.valueOf(table.getType().name());
        tableType = Schema.TableType.TABLE; // FIXME
    } catch (IllegalArgumentException e) {
        tableType = Schema.TableType.TABLE;
    }

    RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
    RelDataTypeFactory.FieldInfoBuilder fieldInfo = typeFactory.builder();
    for (MetaColumn metaColumn : metaTable.getColumns()) {
        String columnName = metaColumn.getName();
        //int jdbcType = metaColumn.getType().getJdbcType();
        int jdbcType = metaColumn.getType(); //FIXME
        SqlTypeName typeName = SqlTypeName.getNameForJdbcType(jdbcType);
        RelDataType sqlType = typeFactory.createSqlType(typeName);

        fieldInfo.add(columnName, sqlType);
    }
    protoRowType = RelDataTypeImpl.proto(fieldInfo.build());

    this.schema = schema;
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:27,代码来源:OctopusTable.java

示例3: createStructType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
 * Creates a record type with specified field names.
 *
 * <p>The array of field names may be null, or any of the names within it
 * can be null. We recommend using explicit names where possible, because it
 * makes it much easier to figure out the intent of fields when looking at
 * planner output.
 *
 * @param typeFactory Type factory
 * @param exprs       Expressions
 * @param names       Field names, may be null, or elements may be null
 * @param suggester   Generates alternative names if {@code names} is not
 *                    null and its elements are not unique
 * @return Record type
 */
public static RelDataType createStructType(
    RelDataTypeFactory typeFactory,
    final List<? extends RexNode> exprs,
    List<String> names,
    SqlValidatorUtil.Suggester suggester) {
  if (names != null && suggester != null) {
    names = SqlValidatorUtil.uniquify(names, suggester,
        typeFactory.getTypeSystem().isSchemaCaseSensitive());
  }
  final RelDataTypeFactory.Builder builder = typeFactory.builder();
  for (int i = 0; i < exprs.size(); i++) {
    String name;
    if (names == null || (name = names.get(i)) == null) {
      name = "$f" + i;
    }
    builder.add(name, exprs.get(i).getType());
  }
  return builder.build();
}
 
开发者ID:apache,项目名称:calcite,代码行数:35,代码来源:RexUtil.java

示例4: toCalciteRowType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
 * Create an instance of {@code RelDataType} so it can be used to create a table.
 */
public static RelProtoDataType toCalciteRowType(final BeamRecordSqlType that) {
  return new RelProtoDataType() {
    @Override
    public RelDataType apply(RelDataTypeFactory a) {
      RelDataTypeFactory.FieldInfoBuilder builder = a.builder();
      for (int idx = 0; idx < that.getFieldNames().size(); ++idx) {
        builder.add(that.getFieldNameByIndex(idx), toCalciteType(that.getFieldTypeByIndex(idx)));
      }
      return builder.build();
    }
  };
}
 
开发者ID:apache,项目名称:beam,代码行数:16,代码来源:CalciteUtils.java

示例5: getRowType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RelDataType getRowType(RelDataTypeFactory typeFactory)
{
  String schema = (String)operands.get(CSV_SCHEMA);
  RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();

  DelimitedSchema delimitedSchema = new DelimitedSchema(schema);
  for (DelimitedSchema.Field field : delimitedSchema.getFields()) {
    builder.add(field.getName(), convertField(typeFactory, field.getType()));
  }

  return builder.build();
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:14,代码来源:CSVMessageFormat.java

示例6: deriveRowType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private RelDataType deriveRowType(RelDataTypeFactory typeFactory) {
    RelDataTypeFactory.FieldInfoBuilder fieldInfo = typeFactory.builder();
    for (ColumnDesc column : sourceColumns) {
        RelDataType sqlType = createSqlType(typeFactory, column.getUpgradedType(), column.isNullable());
        sqlType = SqlTypeUtil.addCharsetAndCollation(sqlType, typeFactory);
        fieldInfo.add(column.getName(), sqlType);
    }
    return typeFactory.createStructType(fieldInfo);
}
 
开发者ID:apache,项目名称:kylin,代码行数:11,代码来源:OLAPTable.java

示例7: getRowType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
    RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
    RelDataType anyType = typeFactory.createSqlType(SqlTypeName.ANY);
    builder.add("thread", anyType);
    builder.add("depth", typeFactory.createJavaType(int.class));
    builder.add("text", typeFactory.createJavaType(String.class));
    builder.add("objects", typeFactory.createMultisetType(anyType, -1));
    return builder.build();
}
 
开发者ID:vlsi,项目名称:mat-calcite-plugin,代码行数:11,代码来源:SnapshotThreadStacksTable.java

示例8: getRowType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
  final RelDataTypeFactory.Builder builder = typeFactory.builder();
  for (TpcdsColumn<E> column : tpcdsTable.getColumns()) {
    builder.add(column.getColumnName().toUpperCase(Locale.ROOT),
        typeFactory.createJavaType(realType(column)));
  }
  return builder.build();
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:TpcdsSchema.java

示例9: getRowType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override public RelDataType getRowType(RelDataTypeFactory typeFactory) {
  final RelDataTypeFactory.Builder builder = typeFactory.builder();
  for (String fieldName : fieldNames) {
    // only supports CHARARRAY types for now
    final RelDataType relDataType = typeFactory
        .createSqlType(PigDataType.valueOf(DataType.CHARARRAY).getSqlType());
    final RelDataType nullableRelDataType = typeFactory
        .createTypeWithNullability(relDataType, true);
    builder.add(fieldName, nullableRelDataType);
  }
  return builder.build();
}
 
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:PigTable.java

示例10: apply

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType apply(RelDataTypeFactory typeFactory) {
  final RelDataTypeFactory.Builder builder = typeFactory.builder();
  for (Map.Entry<String, SqlTypeName> field : fields.entrySet()) {
    final String key = field.getKey();
    builder.add(key, field.getValue())
        // Druid's time column is always not null and the only column called __time.
        .nullable(!timestampColumn.equals(key));
  }
  return builder.build();
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:DruidTable.java

示例11: toType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType toType(RelDataTypeFactory typeFactory, Object o) {
  if (o instanceof List) {
    @SuppressWarnings("unchecked")
    final List<Map<String, Object>> jsonList = (List<Map<String, Object>>) o;
    final RelDataTypeFactory.Builder builder = typeFactory.builder();
    for (Map<String, Object> jsonMap : jsonList) {
      builder.add((String) jsonMap.get("name"), toType(typeFactory, jsonMap));
    }
    return builder.build();
  } else {
    final Map<String, Object> map = (Map<String, Object>) o;
    final SqlTypeName sqlTypeName =
        Util.enumVal(SqlTypeName.class, (String) map.get("type"));
    final Integer precision = (Integer) map.get("precision");
    final Integer scale = (Integer) map.get("scale");
    final RelDataType type;
    if (precision == null) {
      type = typeFactory.createSqlType(sqlTypeName);
    } else if (scale == null) {
      type = typeFactory.createSqlType(sqlTypeName, precision);
    } else {
      type = typeFactory.createSqlType(sqlTypeName, precision, scale);
    }
    final boolean nullable = (Boolean) map.get("nullable");
    return typeFactory.createTypeWithNullability(type, nullable);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:RelJson.java

示例12: getRelDataType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
RelProtoDataType getRelDataType(DatabaseMetaData metaData, String catalogName,
    String schemaName, String tableName) throws SQLException {
  final ResultSet resultSet =
      metaData.getColumns(catalogName, schemaName, tableName, null);

  // Temporary type factory, just for the duration of this method. Allowable
  // because we're creating a proto-type, not a type; before being used, the
  // proto-type will be copied into a real type factory.
  final RelDataTypeFactory typeFactory =
      new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  final RelDataTypeFactory.Builder fieldInfo = typeFactory.builder();
  while (resultSet.next()) {
    final String columnName = resultSet.getString(4);
    final int dataType = resultSet.getInt(5);
    final String typeString = resultSet.getString(6);
    final int precision;
    final int scale;
    switch (SqlType.valueOf(dataType)) {
    case TIMESTAMP:
    case TIME:
      precision = resultSet.getInt(9); // SCALE
      scale = 0;
      break;
    default:
      precision = resultSet.getInt(7); // SIZE
      scale = resultSet.getInt(9); // SCALE
      break;
    }
    RelDataType sqlType =
        sqlType(typeFactory, dataType, precision, scale, typeString);
    boolean nullable = resultSet.getInt(11) != DatabaseMetaData.columnNoNulls;
    fieldInfo.add(columnName, sqlType).nullable(nullable);
  }
  resultSet.close();
  return RelDataTypeImpl.proto(fieldInfo.build());
}
 
开发者ID:apache,项目名称:calcite,代码行数:37,代码来源:JdbcSchema.java

示例13: multiplicationTable

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/** A function that generates multiplication table of {@code ncol} columns x
 * {@code nrow} rows. */
public static QueryableTable multiplicationTable(final int ncol,
    final int nrow, Integer offset) {
  final int offs = offset == null ? 0 : offset;
  return new AbstractQueryableTable(Object[].class) {
    public RelDataType getRowType(RelDataTypeFactory typeFactory) {
      final RelDataTypeFactory.Builder builder = typeFactory.builder();
      builder.add("row_name", typeFactory.createJavaType(String.class));
      final RelDataType int_ = typeFactory.createJavaType(int.class);
      for (int i = 1; i <= ncol; i++) {
        builder.add("c" + i, int_);
      }
      return builder.build();
    }

    public Queryable<Object[]> asQueryable(QueryProvider queryProvider,
        SchemaPlus schema, String tableName) {
      final List<Object[]> table = new AbstractList<Object[]>() {
        @Override public Object[] get(int index) {
          Object[] cur = new Object[ncol + 1];
          cur[0] = "row " + index;
          for (int j = 1; j <= ncol; j++) {
            cur[j] = j * (index + 1) + offs;
          }
          return cur;
        }

        @Override public int size() {
          return nrow;
        }
      };
      return Linq4j.asEnumerable(table).asQueryable();
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:37,代码来源:Smalls.java

示例14: getRelDataType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
RelProtoDataType getRelDataType(String columnFamily, boolean view) {
  List<ColumnMetadata> columns;
  if (view) {
    columns = getKeyspace().getMaterializedView(columnFamily).getColumns();
  } else {
    columns = getKeyspace().getTable(columnFamily).getColumns();
  }

  // Temporary type factory, just for the duration of this method. Allowable
  // because we're creating a proto-type, not a type; before being used, the
  // proto-type will be copied into a real type factory.
  final RelDataTypeFactory typeFactory =
      new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  final RelDataTypeFactory.Builder fieldInfo = typeFactory.builder();
  for (ColumnMetadata column : columns) {
    final String columnName = column.getName();
    final DataType type = column.getType();

    // TODO: This mapping of types can be done much better
    SqlTypeName typeName = SqlTypeName.ANY;
    if (type == DataType.uuid() || type == DataType.timeuuid()) {
      // We currently rely on this in CassandraFilter to detect UUID columns.
      // That is, these fixed length literals should be unquoted in CQL.
      typeName = SqlTypeName.CHAR;
    } else if (type == DataType.ascii() || type == DataType.text()
          || type == DataType.varchar()) {
      typeName = SqlTypeName.VARCHAR;
    } else if (type == DataType.cint() || type == DataType.varint()) {
      typeName = SqlTypeName.INTEGER;
    } else if (type == DataType.bigint()) {
      typeName = SqlTypeName.BIGINT;
    } else if (type == DataType.cdouble() || type == DataType.cfloat()
        || type == DataType.decimal()) {
      typeName = SqlTypeName.DOUBLE;
    }

    fieldInfo.add(columnName, typeFactory.createSqlType(typeName)).nullable(true);
  }

  return RelDataTypeImpl.proto(fieldInfo.build());
}
 
开发者ID:apache,项目名称:calcite,代码行数:42,代码来源:CassandraSchema.java


注:本文中的org.apache.calcite.rel.type.RelDataTypeFactory.builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。