• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RelDataTypeImpl类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.apache.calcite.rel.type.RelDataTypeImpl的典型用法代码示例。如果您正苦于以下问题:Java RelDataTypeImpl类的具体用法?Java RelDataTypeImpl怎么用?Java RelDataTypeImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

RelDataTypeImpl类属于org.apache.calcite.rel.type包,在下文中一共展示了RelDataTypeImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: OctopusTable

点赞 3

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的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

示例2: execute

点赞 3

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的package包/类
public void execute(CalcitePrepare.Context context) {
  final List<String> path = context.getDefaultSchemaPath();
  CalciteSchema schema = context.getRootSchema();
  for (String p : path) {
    schema = schema.getSubSchema(p, true);
  }
  final JavaTypeFactory typeFactory = new JavaTypeFactoryImpl();
  final RelDataTypeFactory.Builder builder = typeFactory.builder();
  for (Pair<SqlIdentifier, SqlDataTypeSpec> pair : nameTypes()) {
    builder.add(pair.left.getSimple(),
        pair.right.deriveType(typeFactory, true));
  }
  final RelDataType rowType = builder.build();
  schema.add(name.getSimple(),
      new MutableArrayTable(name.getSimple(),
          RelDataTypeImpl.proto(rowType)));
}
 

开发者ID:apache,
项目名称:calcite,
代码行数:18,
代码来源:SqlCreateTable.java

示例3: getRelDataType

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的package包/类
@Override
RelProtoDataType getRelDataType(
		DatabaseMetaData metaData,
		String catalogName,
		String schemaName,
		String tableName
) throws SQLException {
	if (journalledTableKeys.containsKey(tableName)) {
		// 1: Find columns for journal table
		RelDataType relDataType = super
				.getRelDataType(metaData, catalogName, schemaName, journalNameFor(tableName))
				.apply(new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT) {
					@Override
					public RelDataType copyType(RelDataType type) {
						return type;
					}
				});

		RelDataTypeFactory.FieldInfoBuilder fieldInfo = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT).builder();

		// 2: Filter out journal-implementation columns
		for (RelDataTypeField field : relDataType.getFieldList()) {
			String fieldName = field.getName();
			if (fieldName.equals(versionField) || fieldName.equals(subsequentVersionField)) {
				continue;
			}
			fieldInfo.add(field);
		}

		return RelDataTypeImpl.proto(fieldInfo.build());
	} else {
		return super.getRelDataType(metaData, catalogName, schemaName, tableName);
	}
}
 

开发者ID:tzolov,
项目名称:calcite-sql-rewriter,
代码行数:35,
代码来源:JournalledJdbcSchema.java

示例4: create

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的package包/类
public CsvTable create(SchemaPlus schema, String name,
    Map<String, Object> operand, RelDataType rowType) {
  String fileName = (String) operand.get("file");
  final File base =
      (File) operand.get(ModelHandler.ExtraOperand.BASE_DIRECTORY.camelName);
  final Source source = Sources.file(base, fileName);
  final RelProtoDataType protoRowType =
      rowType != null ? RelDataTypeImpl.proto(rowType) : null;
  return new CsvScannableTable(source, protoRowType);
}
 

开发者ID:apache,
项目名称:calcite,
代码行数:11,
代码来源:CsvTableFactory.java

示例5: create

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的package包/类
public CsvTable create(SchemaPlus schema, String name,
    Map<String, Object> operand, RelDataType rowType) {
  String fileName = (String) operand.get("file");
  File file = new File(fileName);
  final File base =
      (File) operand.get(ModelHandler.ExtraOperand.BASE_DIRECTORY.camelName);
  if (base != null && !file.isAbsolute()) {
    file = new File(base, fileName);
  }
  final Source source = Sources.of(file);
  final RelProtoDataType protoRowType =
      rowType != null ? RelDataTypeImpl.proto(rowType) : null;
  return new CsvStreamScannableTable(source, protoRowType);
}
 

开发者ID:apache,
项目名称:calcite,
代码行数:15,
代码来源:CsvStreamTableFactory.java

示例6: execute

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的package包/类
public void execute(CalcitePrepare.Context context) {
  final Pair<CalciteSchema, String> pair =
      SqlDdlNodes.schema(context, true, name);
  if (pair.left.plus().getTable(pair.right) != null) {
    // Materialized view exists.
    if (!ifNotExists) {
      // They did not specify IF NOT EXISTS, so give error.
      throw SqlUtil.newContextException(name.getParserPosition(),
          RESOURCE.tableExists(pair.right));
    }
    return;
  }
  final SqlNode q = SqlDdlNodes.renameColumns(columnList, query);
  final String sql = q.toSqlString(CalciteSqlDialect.DEFAULT).getSql();
  final List<String> schemaPath = pair.left.path(null);
  final ViewTableMacro viewTableMacro =
      ViewTable.viewMacro(pair.left.plus(), sql, schemaPath,
          context.getObjectPath(), false);
  final TranslatableTable x = viewTableMacro.apply(ImmutableList.of());
  final RelDataType rowType = x.getRowType(context.getTypeFactory());

  // Table does not exist. Create it.
  final MaterializedViewTable table =
      new MaterializedViewTable(pair.right, RelDataTypeImpl.proto(rowType));
  pair.left.add(pair.right, table);
  SqlDdlNodes.populate(name, query, context);
  table.key =
      MaterializationService.instance().defineMaterialization(pair.left, null,
          sql, schemaPath, pair.right, true, true);
}
 

开发者ID:apache,
项目名称:calcite,
代码行数:31,
代码来源:SqlCreateMaterializedView.java

示例7: getRelDataType

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的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

示例8: modifiableViewTable

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的package包/类
/** Allows a sub-class to return an extension of {@link ModifiableViewTable}
 * by overriding this method. */
protected ModifiableViewTable modifiableViewTable(CalcitePrepare.AnalyzeViewResult parsed,
    String viewSql, List<String> schemaPath, List<String> viewPath,
    CalciteSchema schema) {
  final JavaTypeFactory typeFactory = (JavaTypeFactory) parsed.typeFactory;
  final Type elementType = typeFactory.getJavaClass(parsed.rowType);
  return new ModifiableViewTable(elementType,
      RelDataTypeImpl.proto(parsed.rowType), viewSql, schemaPath, viewPath,
      parsed.table, Schemas.path(schema.root(), parsed.tablePath),
      parsed.constraint, parsed.columnMapping);
}
 

开发者ID:apache,
项目名称:calcite,
代码行数:13,
代码来源:ViewTableMacro.java

示例9: viewTable

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的package包/类
/** Allows a sub-class to return an extension of {@link ViewTable} by
 * overriding this method. */
protected ViewTable viewTable(CalcitePrepare.AnalyzeViewResult parsed,
    String viewSql, List<String> schemaPath, List<String> viewPath) {
  final JavaTypeFactory typeFactory = (JavaTypeFactory) parsed.typeFactory;
  final Type elementType = typeFactory.getJavaClass(parsed.rowType);
  return new ViewTable(elementType,
      RelDataTypeImpl.proto(parsed.rowType), viewSql, schemaPath, viewPath);
}
 

开发者ID:apache,
项目名称:calcite,
代码行数:10,
代码来源:ViewTableMacro.java

示例10: testLoadSorted

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的package包/类
@Test public void testLoadSorted() {
  final JavaTypeFactoryImpl typeFactory =
      new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  final RelDataType rowType =
      typeFactory.builder()
          .add("empid", typeFactory.createType(int.class))
          .add("deptno", typeFactory.createType(int.class))
          .add("name", typeFactory.createType(String.class))
          .build();
  final Enumerable<Object[]> enumerable =
      Linq4j.asEnumerable(
          Arrays.asList(
              new Object[]{100, 10, "Bill"},
              new Object[]{200, 20, "Eric"},
              new Object[]{150, 10, "Sebastian"},
              new Object[]{160, 10, "Theodore"}));
  final ColumnLoader<Object[]> loader =
      new ColumnLoader<Object[]>(typeFactory, enumerable,
          RelDataTypeImpl.proto(rowType), null);
  checkColumn(
      loader.representationValues.get(0),
      ArrayTable.RepresentationType.BIT_SLICED_PRIMITIVE_ARRAY,
      "Column(representation=BitSlicedPrimitiveArray(ordinal=0, bitCount=8, primitive=INT, signed=false), value=[100, 150, 160, 200, 0, 0, 0, 0])");
  checkColumn(
      loader.representationValues.get(1),
      ArrayTable.RepresentationType.BIT_SLICED_PRIMITIVE_ARRAY,
      "Column(representation=BitSlicedPrimitiveArray(ordinal=1, bitCount=5, primitive=INT, signed=false), value=[10, 10, 10, 20, 0, 0, 0, 0, 0, 0, 0, 0])");
  checkColumn(
      loader.representationValues.get(2),
      ArrayTable.RepresentationType.OBJECT_ARRAY,
      "Column(representation=ObjectArray(ordinal=2), value=[Bill, Sebastian, Theodore, Eric])");
}
 

开发者ID:apache,
项目名称:calcite,
代码行数:33,
代码来源:ArrayTableTest.java

示例11: testLoadSorted2

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的package包/类
/** As {@link #testLoadSorted()} but column #1 is the unique column, not
 * column #0. The algorithm needs to go back and permute the values of
 * column #0 after it discovers that column #1 is unique and sorts by it. */
@Test public void testLoadSorted2() {
  final JavaTypeFactoryImpl typeFactory =
      new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  final RelDataType rowType =
      typeFactory.builder()
          .add("deptno", typeFactory.createType(int.class))
          .add("empid", typeFactory.createType(int.class))
          .add("name", typeFactory.createType(String.class))
          .build();
  final Enumerable<Object[]> enumerable =
      Linq4j.asEnumerable(
          Arrays.asList(
              new Object[]{10, 100, "Bill"},
              new Object[]{20, 200, "Eric"},
              new Object[]{30, 150, "Sebastian"},
              new Object[]{10, 160, "Theodore"}));
  final ColumnLoader<Object[]> loader =
      new ColumnLoader<Object[]>(typeFactory, enumerable,
          RelDataTypeImpl.proto(rowType), null);
  // Note that values have been sorted with {20, 200, Eric} last because the
  // value 200 is the highest value of empid, the unique column.
  checkColumn(
      loader.representationValues.get(0),
      ArrayTable.RepresentationType.BIT_SLICED_PRIMITIVE_ARRAY,
      "Column(representation=BitSlicedPrimitiveArray(ordinal=0, bitCount=5, primitive=INT, signed=false), value=[10, 30, 10, 20, 0, 0, 0, 0, 0, 0, 0, 0])");
  checkColumn(
      loader.representationValues.get(1),
      ArrayTable.RepresentationType.BIT_SLICED_PRIMITIVE_ARRAY,
      "Column(representation=BitSlicedPrimitiveArray(ordinal=1, bitCount=8, primitive=INT, signed=false), value=[100, 150, 160, 200, 0, 0, 0, 0])");
  checkColumn(
      loader.representationValues.get(2),
      ArrayTable.RepresentationType.OBJECT_ARRAY,
      "Column(representation=ObjectArray(ordinal=2), value=[Bill, Sebastian, Theodore, Eric])");
}
 

开发者ID:apache,
项目名称:calcite,
代码行数:38,
代码来源:ArrayTableTest.java

示例12: modifiableViewTable

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的package包/类
@Override protected ModifiableViewTable modifiableViewTable(
    CalcitePrepare.AnalyzeViewResult parsed, String viewSql,
    List<String> schemaPath, List<String> viewPath, CalciteSchema schema) {
  final JavaTypeFactory typeFactory = (JavaTypeFactory) parsed.typeFactory;
  final Type elementType = typeFactory.getJavaClass(parsed.rowType);
  return new MockModifiableViewTable(elementType,
      RelDataTypeImpl.proto(parsed.rowType), viewSql, schemaPath, viewPath,
      parsed.table, Schemas.path(schema.root(), parsed.tablePath),
      parsed.constraint, parsed.columnMapping);
}
 

开发者ID:apache,
项目名称:calcite,
代码行数:11,
代码来源:MockCatalogReader.java

示例13: getRelDataType

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的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

示例14: explicit

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的package包/类
/**
 * Creates an inference rule which returns a copy of a given data type.
 */
public static ExplicitReturnTypeInference explicit(RelDataType type) {
  return explicit(RelDataTypeImpl.proto(type));
}
 

开发者ID:apache,
项目名称:calcite,
代码行数:7,
代码来源:ReturnTypes.java

示例15: onRegister

点赞 2

import org.apache.calcite.rel.type.RelDataTypeImpl; //导入依赖的package包/类
@Override public void onRegister(RelDataTypeFactory typeFactory) {
  super.onRegister(typeFactory);
  // To simulate getRowType() behavior in ViewTable.
  final RelProtoDataType protoRowType = RelDataTypeImpl.proto(rowType);
  rowType = protoRowType.apply(typeFactory);
}
 

开发者ID:apache,
项目名称:calcite,
代码行数:7,
代码来源:MockCatalogReader.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)