本文整理汇总了Java中org.apache.calcite.rel.type.RelProtoDataType类的典型用法代码示例。如果您正苦于以下问题:Java RelProtoDataType类的具体用法?Java RelProtoDataType怎么用?Java RelProtoDataType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RelProtoDataType类属于org.apache.calcite.rel.type包,在下文中一共展示了RelProtoDataType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DruidTable
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的package包/类
/**
* Creates a Druid table.
*
* @param schema Druid schema that contains this table
* @param dataSource Druid data source name
* @param protoRowType Field names and types
* @param metricFieldNames Names of fields that are metrics
* @param intervals Default interval if query does not constrain the time, or null
* @param timestampFieldName Name of the column that contains the time
*/
public DruidTable(DruidSchema schema, String dataSource,
RelProtoDataType protoRowType, Set<String> metricFieldNames,
String timestampFieldName, List<Interval> intervals,
Map<String, List<ComplexMetric>> complexMetrics, Map<String, SqlTypeName> allFields) {
this.timestampFieldName = Preconditions.checkNotNull(timestampFieldName);
this.schema = Preconditions.checkNotNull(schema);
this.dataSource = Preconditions.checkNotNull(dataSource);
this.protoRowType = protoRowType;
this.metricFieldNames = ImmutableSet.copyOf(metricFieldNames);
this.intervals = intervals != null ? ImmutableList.copyOf(intervals)
: ImmutableList.of(DEFAULT_INTERVAL);
this.complexMetrics = complexMetrics == null ? ImmutableMap.<String, List<ComplexMetric>>of()
: ImmutableMap.copyOf(complexMetrics);
this.allFields = allFields == null ? ImmutableMap.<String, SqlTypeName>of()
: ImmutableMap.copyOf(allFields);
}
示例2: ColumnLoader
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的package包/类
/** Creates a column loader, and performs the load.
*
* @param typeFactory Type factory
* @param sourceTable Source data
* @param protoRowType Logical row type
* @param repList Physical row types, or null if not known */
ColumnLoader(JavaTypeFactory typeFactory,
Enumerable<T> sourceTable,
RelProtoDataType protoRowType,
List<ColumnMetaData.Rep> repList) {
this.typeFactory = typeFactory;
final RelDataType rowType = protoRowType.apply(typeFactory);
if (repList == null) {
repList =
Collections.nCopies(rowType.getFieldCount(),
ColumnMetaData.Rep.OBJECT);
}
sourceTable.into(list);
final int[] sorts = {-1};
load(rowType, repList, sorts);
this.sortField = sorts[0];
}
示例3: getParameters
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的package包/类
public List<FunctionParameter> getParameters() {
final List<FunctionParameter> parameters = new ArrayList<>();
for (final Ord<RelProtoDataType> type : Ord.zip(getParams())) {
parameters.add(
new FunctionParameter() {
public int getOrdinal() {
return type.i;
}
public String getName() {
return "arg" + type.i;
}
public RelDataType getType(RelDataTypeFactory typeFactory) {
return type.e.apply(typeFactory);
}
public boolean isOptional() {
return false;
}
});
}
return parameters;
}
示例4: getRelDataType
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的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);
}
}
示例5: toCalciteRowType
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的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();
}
};
}
示例6: buildRowType
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的package包/类
private RelProtoDataType buildRowType() {
return new RelProtoDataType() {
@Override public RelDataType apply(RelDataTypeFactory a0) {
return a0.builder().add("id", SqlTypeName.INTEGER).add("order_id", SqlTypeName.BIGINT)
.add("price", SqlTypeName.FLOAT).add("amount", SqlTypeName.DOUBLE)
.add("user_name", SqlTypeName.VARCHAR).build();
}
};
}
示例7: genRowType
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的package包/类
private static BeamRecordSqlType genRowType() {
return CalciteUtils.toBeamRowType(new RelProtoDataType() {
@Override public RelDataType apply(RelDataTypeFactory a0) {
return a0.builder().add("order_id", SqlTypeName.BIGINT)
.add("site_id", SqlTypeName.INTEGER)
.add("price", SqlTypeName.DOUBLE).build();
}
}.apply(BeamQueryPlanner.TYPE_FACTORY));
}
示例8: encodeAndDecode
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的package包/类
@Test
public void encodeAndDecode() throws Exception {
final RelProtoDataType protoRowType = new RelProtoDataType() {
@Override
public RelDataType apply(RelDataTypeFactory a0) {
return a0.builder()
.add("col_tinyint", SqlTypeName.TINYINT)
.add("col_smallint", SqlTypeName.SMALLINT)
.add("col_integer", SqlTypeName.INTEGER)
.add("col_bigint", SqlTypeName.BIGINT)
.add("col_float", SqlTypeName.FLOAT)
.add("col_double", SqlTypeName.DOUBLE)
.add("col_decimal", SqlTypeName.DECIMAL)
.add("col_string_varchar", SqlTypeName.VARCHAR)
.add("col_time", SqlTypeName.TIME)
.add("col_timestamp", SqlTypeName.TIMESTAMP)
.add("col_boolean", SqlTypeName.BOOLEAN)
.build();
}
};
BeamRecordSqlType beamSQLRowType = CalciteUtils.toBeamRowType(
protoRowType.apply(new JavaTypeFactoryImpl(
RelDataTypeSystem.DEFAULT)));
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(new Date());
BeamRecord row = new BeamRecord(beamSQLRowType
, Byte.valueOf("1"), Short.valueOf("1"), 1, 1L, 1.1F, 1.1
, BigDecimal.ZERO, "hello", calendar, new Date(), true);
BeamRecordCoder coder = beamSQLRowType.getRecordCoder();
CoderProperties.coderDecodeEncodeEqual(coder, row);
}
示例9: create
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的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);
}
示例10: create
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的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);
}
示例11: MutableArrayTable
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的package包/类
/** Creates a MutableArrayTable.
*
* @param name Name of table within its schema
* @param protoStoredRowType Prototype of row type of stored columns (all
* columns except virtual columns)
* @param protoRowType Prototype of row type (all columns)
* @param initializerExpressionFactory How columns are populated
*/
MutableArrayTable(String name, RelProtoDataType protoStoredRowType,
RelProtoDataType protoRowType,
InitializerExpressionFactory initializerExpressionFactory) {
super(name);
this.protoStoredRowType = Preconditions.checkNotNull(protoStoredRowType);
this.protoRowType = Preconditions.checkNotNull(protoRowType);
this.initializerExpressionFactory =
Preconditions.checkNotNull(initializerExpressionFactory);
}
示例12: CassandraEnumerator
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的package包/类
/** Creates a CassandraEnumerator.
*
* @param results Cassandra result set ({@link com.datastax.driver.core.ResultSet})
* @param protoRowType The type of resulting rows
*/
CassandraEnumerator(ResultSet results, RelProtoDataType protoRowType) {
this.iterator = results.iterator();
this.current = null;
final RelDataTypeFactory typeFactory =
new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
this.fieldTypes = protoRowType.apply(typeFactory).getFieldList();
}
示例13: FileTable
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的package包/类
/** Creates a FileTable. */
private FileTable(Source source, String selector, Integer index,
RelProtoDataType protoRowType, List<Map<String, Object>> fieldConfigs)
throws Exception {
super(Object[].class);
this.protoRowType = protoRowType;
this.reader = new FileReader(source, selector, index);
this.converter = new FileRowConverter(this.reader, fieldConfigs);
}
示例14: getRelDataType
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的package包/类
RelProtoDataType getRelDataType(String catalogName, String schemaName,
String tableName) throws SQLException {
Connection connection = null;
try {
connection = dataSource.getConnection();
DatabaseMetaData metaData = connection.getMetaData();
return getRelDataType(metaData, catalogName, schemaName, tableName);
} finally {
close(connection, null, null);
}
}
示例15: createCloneTable
import org.apache.calcite.rel.type.RelProtoDataType; //导入依赖的package包/类
@Deprecated // to be removed before 2.0
public static <T> Table createCloneTable(final JavaTypeFactory typeFactory,
final RelProtoDataType protoRowType,
final List<ColumnMetaData.Rep> repList,
final Enumerable<T> source) {
return createCloneTable(typeFactory, protoRowType,
ImmutableList.<RelCollation>of(), repList, source);
}