本文整理汇总了Java中com.facebook.presto.spi.type.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于com.facebook.presto.spi.type包,在下文中一共展示了Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseAgent
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
@ScalarFunction("parse_agent")
@Description("Returns Map, which has keys such as 'category', 'name', 'os', 'version', 'vendor' and 'os_version'")
@SqlType("map<varchar,varchar>")
public Block parseAgent(@TypeParameter("map<varchar,varchar>") Type mapType, @SqlType(StandardTypes.VARCHAR) Slice slice) {
String argument = slice.toStringUtf8();
Map<String, String> stringMap = Classifier.parse(argument);
if (pageBuilder.isFull()) {
pageBuilder.reset();
}
BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(0);
BlockBuilder singleMapBlockBuilder = blockBuilder.beginBlockEntry();
for (Map.Entry<String, String> entry : stringMap.entrySet()) {
VARCHAR.writeSlice(singleMapBlockBuilder, Slices.utf8Slice(entry.getKey()));
VARCHAR.writeSlice(singleMapBlockBuilder, Slices.utf8Slice(entry.getValue()));
}
blockBuilder.closeEntry();
pageBuilder.declarePosition();
return (Block) mapType.getObject(blockBuilder, blockBuilder.getPositionCount() - 1);
}
示例2: getTableColMetadata
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
public Optional<List<ColumnMetadata>> getTableColMetadata(String connectorId, String dbName, String tblName)
{
log.debug("Get list of column metadata of table " + formName(dbName, tblName));
List<ColumnMetadata> colMetadatas = new ArrayList<>();
MetaProto.StringListType dataTypeList = metaClient.listColumnsDataType(dbName, tblName);
MetaProto.StringListType colNameList = metaClient.listColumns(dbName, tblName);
if (dataTypeList.getIsEmpty() || colNameList.getIsEmpty()) {
log.warn("No col matches!");
return Optional.empty();
}
for (int i = 0; i < dataTypeList.getStrCount(); i++) {
String dataType = dataTypeList.getStr(i);
Type type = getType(dataType);
ColumnMetadata metadata = new ColumnMetadata(
colNameList.getStr(i),
type,
"",
false);
colMetadatas.add(metadata);
}
return Optional.of(colMetadatas);
}
示例3: getSliceExpressedValue
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
private static Slice getSliceExpressedValue(Object value, Type type) {
Slice sliceValue;
if (value instanceof String) {
sliceValue = Slices.utf8Slice((String) value);
} else if (value instanceof byte[]) {
sliceValue = Slices.wrappedBuffer((byte[]) value);
} else if (value instanceof Integer) {
sliceValue = Slices.utf8Slice(value.toString());
} else {
throw new IllegalStateException("unsupported string field type: " + value.getClass().getName());
}
if (isVarcharType(type)) {
sliceValue = truncateToLength(sliceValue, type);
}
if (isCharType(type)) {
sliceValue = trimSpacesAndTruncateToLength(sliceValue, type);
}
return sliceValue;
}
示例4: serializePrimitive
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
private static void serializePrimitive(Type type, BlockBuilder builder, Object object) {
requireNonNull(builder, "parent builder is null");
if (object == null) {
builder.appendNull();
return;
}
if (BOOLEAN.equals(type)) {
BOOLEAN.writeBoolean(builder, (Boolean) object);
} else if (BIGINT.equals(type) || INTEGER.equals(type) || SMALLINT.equals(type) || TINYINT.equals(type)
|| REAL.equals(type) || DATE.equals(type) || TIMESTAMP.equals(type)) {
type.writeLong(builder, getLongExpressedValue(object));
} else if (DOUBLE.equals(type)) {
DOUBLE.writeDouble(builder, ((Number) object).doubleValue());
} else if (isVarcharType(type) || VARBINARY.equals(type) || isCharType(type)) {
type.writeSlice(builder, getSliceExpressedValue(object, type));
} else {
throw new UnsupportedOperationException("Unsupported primitive type: " + type);
}
}
示例5: KuduRecordSet
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
public KuduRecordSet(KuduTables kuduTables, KuduClientManager kuduClientManager, KuduSplit split, List<KuduColumnHandle> columns)
{
//将要查询的kudu列
this.columns = requireNonNull(columns, "column handles is null");
this.columnNames = columns.stream().map(kuduColumn -> kuduColumn.getColumnName()).collect(Collectors.toList());
requireNonNull(split, "split is null");
//将要查询的kudu列的数据类型
ImmutableList.Builder<Type> types = ImmutableList.builder();
for (KuduColumnHandle column : columns) {
types.add(column.getColumnType());
}
this.columnTypes = types.build();
// this.address = Iterables.getOnlyElement(split.getAddresses());
this.effectivePredicate = split.getEffectivePredicate();
this.tableName = split.getTableName();
this.kuduTables = requireNonNull(kuduTables, "kuduTables is null");
this.kuduSplit = requireNonNull(split, "kuduTables is null");
this.kuduClientManager = requireNonNull(kuduClientManager, "kuduClientManager is null");
}
示例6: createLocalQueryRunner
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
private static LocalQueryRunner createLocalQueryRunner()
{
Session defaultSession = testSessionBuilder()
.setCatalog("tpch")
.setSchema(TINY_SCHEMA_NAME)
.build();
LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager();
localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of());
HyperLogLogPlugin plugin = new HyperLogLogPlugin();
for (Type type : plugin.getTypes()) {
localQueryRunner.getTypeManager().addType(type);
}
for (ParametricType parametricType : plugin.getParametricTypes()) {
localQueryRunner.getTypeManager().addParametricType(parametricType);
}
localQueryRunner.getMetadata().addFunctions(extractFunctions(plugin.getFunctions()));
return localQueryRunner;
}
示例7: getSetBits
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
/**
* Sets the vector element to true if the bit is set, skipping the null values.
*/
public void getSetBits(Type type, int batchSize, BlockBuilder builder, boolean[] isNull)
throws IOException
{
for (int i = 0; i < batchSize; i++) {
if (isNull[i]) {
builder.appendNull();
}
else {
// read more data if necessary
if (bitsInData == 0) {
readByte();
}
// read bit
type.writeBoolean(builder, (data & HIGH_BIT_MASK) != 0);
// mark bit consumed
data <<= 1;
bitsInData--;
}
}
}
示例8: getWindowFunctionImplementation
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
public WindowFunctionSupplier getWindowFunctionImplementation(Signature signature)
{
checkArgument(signature.getKind() == WINDOW || signature.getKind() == AGGREGATE, "%s is not a window function", signature);
checkArgument(signature.getTypeParameterRequirements().isEmpty(), "%s has unbound type parameters", signature);
Iterable<SqlFunction> candidates = functions.get(QualifiedName.of(signature.getName()));
// search for exact match
for (SqlFunction operator : candidates) {
Type returnType = typeManager.getType(signature.getReturnType());
List<Type> argumentTypes = resolveTypes(signature.getArgumentTypes(), typeManager);
Map<String, Type> boundTypeParameters = operator.getSignature().bindTypeParameters(returnType, argumentTypes, false, typeManager);
if (boundTypeParameters != null) {
try {
return specializedWindowCache.getUnchecked(new SpecializedFunctionKey(operator, boundTypeParameters, signature.getArgumentTypes().size()));
}
catch (UncheckedExecutionException e) {
throw Throwables.propagate(e.getCause());
}
}
}
throw new PrestoException(FUNCTION_IMPLEMENTATION_MISSING, format("%s not found", signature));
}
示例9: configure
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
@Override
public void configure(Binder binder)
{
binder.bind(TypeManager.class).toInstance(typeManager);
binder.bind(ExampleConnector.class).in(Scopes.SINGLETON);
binder.bind(ExampleConnectorId.class).toInstance(new ExampleConnectorId(connectorId));
binder.bind(ExampleMetadata.class).in(Scopes.SINGLETON);
binder.bind(ExampleClient.class).in(Scopes.SINGLETON);
binder.bind(ExampleSplitManager.class).in(Scopes.SINGLETON);
binder.bind(ExampleRecordSetProvider.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(ExampleConfig.class);
jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
jsonCodecBinder(binder).bindMapJsonCodec(String.class, listJsonCodec(ExampleTable.class));
}
示例10: TopNOperatorFactory
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
public TopNOperatorFactory(
int operatorId,
PlanNodeId planNodeId,
List<? extends Type> types,
int n,
List<Integer> sortChannels,
List<SortOrder> sortOrders,
boolean partial)
{
this.operatorId = operatorId;
this.planNodeId = requireNonNull(planNodeId, "planNodeId is null");
this.sourceTypes = ImmutableList.copyOf(requireNonNull(types, "types is null"));
this.n = n;
ImmutableList.Builder<Type> sortTypes = ImmutableList.builder();
for (int channel : sortChannels) {
sortTypes.add(types.get(channel));
}
this.sortTypes = sortTypes.build();
this.sortChannels = ImmutableList.copyOf(requireNonNull(sortChannels, "sortChannels is null"));
this.sortOrders = ImmutableList.copyOf(requireNonNull(sortOrders, "sortOrders is null"));
this.partial = partial;
}
示例11: createStreamReaders
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
private static StreamReader[] createStreamReaders(OrcDataSource orcDataSource,
List<OrcType> types,
DateTimeZone hiveStorageTimeZone,
Map<Integer, Type> includedColumns)
{
List<StreamDescriptor> streamDescriptors = createStreamDescriptor("", "", 0, types, orcDataSource).getNestedStreams();
OrcType rowType = types.get(0);
StreamReader[] streamReaders = new StreamReader[rowType.getFieldCount()];
for (int columnId = 0; columnId < rowType.getFieldCount(); columnId++) {
if (includedColumns.containsKey(columnId)) {
StreamDescriptor streamDescriptor = streamDescriptors.get(columnId);
streamReaders[columnId] = StreamReaders.createStreamReader(streamDescriptor, hiveStorageTimeZone);
}
}
return streamReaders;
}
示例12: ScanFilterAndProjectOperatorFactory
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
public ScanFilterAndProjectOperatorFactory(
int operatorId,
PlanNodeId planNodeId,
PlanNodeId sourceId,
PageSourceProvider pageSourceProvider,
CursorProcessor cursorProcessor,
PageProcessor pageProcessor,
Iterable<ColumnHandle> columns,
List<Type> types)
{
this.operatorId = operatorId;
this.planNodeId = requireNonNull(planNodeId, "planNodeId is null");
this.cursorProcessor = requireNonNull(cursorProcessor, "cursorProcessor is null");
this.pageProcessor = requireNonNull(pageProcessor, "pageProcessor is null");
this.sourceId = requireNonNull(sourceId, "sourceId is null");
this.pageSourceProvider = requireNonNull(pageSourceProvider, "pageSourceProvider is null");
this.columns = ImmutableList.copyOf(requireNonNull(columns, "columns is null"));
this.types = requireNonNull(types, "types is null");
}
示例13: RowType
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
public RowType(List<Type> fieldTypes, Optional<List<String>> fieldNames)
{
super(new TypeSignature(
ROW,
Lists.transform(fieldTypes, Type::getTypeSignature),
fieldNames.orElse(ImmutableList.of()).stream()
.collect(toImmutableList())),
Block.class);
ImmutableList.Builder<RowField> builder = ImmutableList.builder();
for (int i = 0; i < fieldTypes.size(); i++) {
int index = i;
builder.add(new RowField(fieldTypes.get(i), fieldNames.map((names) -> names.get(index))));
}
fields = builder.build();
}
示例14: instantiateParametricType
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
private Type instantiateParametricType(TypeSignature signature)
{
List<TypeParameter> parameters = new ArrayList<>();
for (TypeSignatureParameter parameter : signature.getParameters()) {
TypeParameter typeParameter = TypeParameter.of(parameter, this);
if (typeParameter == null) {
return null;
}
parameters.add(typeParameter);
}
ParametricType parametricType = parametricTypes.get(signature.getBase().toLowerCase(Locale.ENGLISH));
if (parametricType == null) {
return null;
}
Type instantiatedType = parametricType.createType(parameters);
checkState(instantiatedType.getTypeSignature().equals(signature), "Instantiated parametric type name (%s) does not match expected name (%s)", instantiatedType, signature);
return instantiatedType;
}
示例15: equalTo
import com.facebook.presto.spi.type.Type; //导入依赖的package包/类
@Override
public boolean equalTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
Block leftRow = leftBlock.getObject(leftPosition, Block.class);
Block rightRow = rightBlock.getObject(rightPosition, Block.class);
for (int i = 0; i < leftRow.getPositionCount(); i++) {
checkElementNotNull(leftRow.isNull(i));
checkElementNotNull(rightRow.isNull(i));
Type fieldType = fields.get(i).getType();
if (!fieldType.equalTo(leftRow, i, rightRow, i)) {
return false;
}
}
return true;
}