com.facebook.presto.spi.type.TypeManager Java Examples

The following examples show how to use com.facebook.presto.spi.type.TypeManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParaflowModule.java    From paraflow with Apache License 2.0 6 votes vote down vote up
/**
 * Contributes bindings and other configurations for this module to {@code binder}.
 *
 * @param binder binder
 */
@Override
public void configure(Binder binder)
{
    binder.bind(ParaflowConnectorId.class).toInstance(new ParaflowConnectorId(connectorId));
    binder.bind(TypeManager.class).toInstance(typeManager);

    configBinder(binder).bindConfig(ParaflowPrestoConfig.class);

    binder.bind(ParaflowMetadataFactory.class).in(Scopes.SINGLETON);
    binder.bind(ParaflowMetadata.class).in(Scopes.SINGLETON);
    binder.bind(ParaflowMetaDataReader.class).in(Scopes.SINGLETON);
    binder.bind(FSFactory.class).in(Scopes.SINGLETON);
    binder.bind(ParaflowConnector.class).in(Scopes.SINGLETON);
    binder.bind(ParaflowSplitManager.class).in(Scopes.SINGLETON);
    binder.bind(ParaflowPageSourceProvider.class).in(Scopes.SINGLETON);
    binder.bind(ClassLoader.class).toInstance(ParaflowPlugin.getClassLoader());

    jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
}
 
Example #2
Source File: KuduModule.java    From presto-kudu with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    bind(TypeManager.class).toInstance(typeManager);

    bind(KuduConnector.class).in(Scopes.SINGLETON);
    bind(KuduConnectorId.class).toInstance(new KuduConnectorId(connectorId));
    bind(KuduMetadata.class).in(Scopes.SINGLETON);
    bind(KuduTableProperties.class).in(Scopes.SINGLETON);
    bind(ConnectorSplitManager.class).to(KuduSplitManager.class).in(Scopes.SINGLETON);
    bind(ConnectorRecordSetProvider.class).to(KuduRecordSetProvider.class)
            .in(Scopes.SINGLETON);
    bind(ConnectorPageSourceProvider.class).to(KuduPageSourceProvider.class)
            .in(Scopes.SINGLETON);
    bind(ConnectorPageSinkProvider.class).to(KuduPageSinkProvider.class).in(Scopes.SINGLETON);
    bind(KuduHandleResolver.class).in(Scopes.SINGLETON);
    bind(KuduRecordSetProvider.class).in(Scopes.SINGLETON);
    configBinder(binder()).bindConfig(KuduClientConfig.class);

    bind(RangePartitionProcedures.class).in(Scopes.SINGLETON);
    Multibinder.newSetBinder(binder(), Procedure.class);
}
 
Example #3
Source File: HbaseConnectorFactory.java    From presto-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(connectorId, "connectorId is null");
    requireNonNull(config, "requiredConfig is null");
    requireNonNull(context, "context is null");

    try {
        Bootstrap app = new Bootstrap(
                new HbaseModule(),
                binder -> {
                    binder.bind(HbaseConnectorId.class).toInstance(new HbaseConnectorId(connectorId));
                    binder.bind(TypeManager.class).toInstance(context.getTypeManager());
                    binder.bind(NodeManager.class).toInstance(context.getNodeManager());
                });

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(config)
                .initialize();

        return injector.getInstance(HbaseConnector.class);
    }
    catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
 
Example #4
Source File: ParquetReader.java    From paraflow with Apache License 2.0 5 votes vote down vote up
public ParquetReader(MessageType fileSchema,
                     MessageType requestedSchema,
                     List<BlockMetaData> blocks,
                     ParquetDataSource dataSource,
                     TypeManager typeManager)
{
    this.fileSchema = fileSchema;
    this.requestedSchema = requestedSchema;
    this.blocks = blocks;
    this.dataSource = dataSource;
    this.typeManager = typeManager;
    initializeColumnReaders();
}
 
Example #5
Source File: ParaflowPageSource.java    From paraflow with Apache License 2.0 5 votes vote down vote up
public ParaflowPageSource(
        ParquetReader parquetReader,
        ParquetDataSource dataSource,
        MessageType fileSchema,
        MessageType requestedSchema,
        long totalBytes,
        List<ParaflowColumnHandle> columns,
        TypeManager typeManager)
{
    checkArgument(totalBytes >= 0, "totalBytes is negative");

    this.parquetReader = requireNonNull(parquetReader, "parquetReader is null");
    this.dataSource = requireNonNull(dataSource, "dataSource is null");
    this.fileSchema = requireNonNull(fileSchema, "fileSchema is null");
    this.requestedSchema = requireNonNull(requestedSchema, "requestedSchema is null");
    this.totalBytes = totalBytes;

    this.columnSize = columns.size();
    this.constantBlocks = new Block[columnSize];
    ImmutableList.Builder<String> namesBuilder = ImmutableList.builder();
    ImmutableList.Builder<Type> typesBuilder = ImmutableList.builder();
    for (int columnIndex = 0; columnIndex < columnSize; columnIndex++) {
        ParaflowColumnHandle column = columns.get(columnIndex);
        String name = column.getName();
        Type type = typeManager.getType(column.getType().getTypeSignature());

        namesBuilder.add(name);
        typesBuilder.add(type);

        if (getParquetType(column, fileSchema) == null) {
            constantBlocks[columnIndex] = RunLengthEncodedBlock.create(type, null, MAX_VECTOR_LENGTH);
        }
    }
    columnNames = namesBuilder.build();
    types = typesBuilder.build();
}
 
Example #6
Source File: ElasticsearchConnectorFactory.java    From presto-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(connectorId, "connectorId is null");
    requireNonNull(config, "requiredConfig is null");
    requireNonNull(context, "context is null");

    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        final Bootstrap app = new Bootstrap(
                new ElasticsearchModule(), module,
                binder -> {
                    binder.bind(ElasticsearchConnectorId.class).toInstance(new ElasticsearchConnectorId(connectorId));
                    binder.bind(TypeManager.class).toInstance(context.getTypeManager());
                    binder.bind(NodeManager.class).toInstance(context.getNodeManager());
                });

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(config)
                .initialize();

        return injector.getInstance(ElasticsearchConnector.class);
    }
    catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
 
Example #7
Source File: EthereumConnectorFactory.java    From presto-ethereum with Apache License 2.0 5 votes vote down vote up
@Override
    public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
        requireNonNull(connectorId, "connectorId is null");
        requireNonNull(config, "config is null");

        try {
            Bootstrap app = new Bootstrap(
//                    new JsonModule(),
                    new EthereumConnectorModule(),
                    binder -> {
                        binder.bind(EthereumConnectorId.class).toInstance(new EthereumConnectorId(connectorId));
                        binder.bind(TypeManager.class).toInstance(context.getTypeManager());
                        binder.bind(NodeManager.class).toInstance(context.getNodeManager());
                    }
            );

            Injector injector = app.strictConfig()
                    .doNotInitializeLogging()
                    .setRequiredConfigurationProperties(config)
                    .initialize();

            return injector.getInstance(EthereumConnector.class);
        }
        catch (Exception e) {
            throw Throwables.propagate(e);
        }
    }
 
Example #8
Source File: ParaflowModule.java    From paraflow with Apache License 2.0 4 votes vote down vote up
@Inject
public TypeDeserializer(TypeManager typeManager)
{
    super(Type.class);
    this.typeManager = requireNonNull(typeManager, "typeManager is null");
}
 
Example #9
Source File: KinesisConnectorModule.java    From presto-kinesis with Apache License 2.0 4 votes vote down vote up
@Inject
public TypeDeserializer(TypeManager typeManager)
{
    super(Type.class);
    this.typeManager = requireNonNull(typeManager, "typeManager is null");
}
 
Example #10
Source File: KinesisConnectorFactory.java    From presto-kinesis with Apache License 2.0 4 votes vote down vote up
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context)
{
    log.info("In connector factory create method.  Connector id: " + connectorId);
    requireNonNull(connectorId, "connectorId is null");
    requireNonNull(config, "config is null");

    try {
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new KinesisConnectorModule(),
                binder -> {
                    binder.bindConstant().annotatedWith(Names.named("connectorId")).to(connectorId);
                    binder.bind(ConnectorId.class).toInstance(new ConnectorId(connectorId));
                    binder.bind(TypeManager.class).toInstance(context.getTypeManager());
                    binder.bind(NodeManager.class).toInstance(context.getNodeManager());
                    // Note: moved creation from KinesisConnectorModule because connector manager accesses it earlier!
                    binder.bind(KinesisHandleResolver.class).toInstance(new KinesisHandleResolver(connectorName));

                    // Moved creation here from KinesisConnectorModule to make it easier to parameterize
                    if (altProviderClass.isPresent()) {
                        binder.bind(KinesisClientProvider.class).to(altProviderClass.get()).in(Scopes.SINGLETON);
                    }
                    else {
                        binder.bind(KinesisClientProvider.class).to(KinesisClientManager.class).in(Scopes.SINGLETON);
                    }

                    if (tableDescriptionSupplier.isPresent()) {
                        binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KinesisStreamDescription>>>() {}).toInstance(tableDescriptionSupplier.get());
                    }
                    else {
                        binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KinesisStreamDescription>>>() {}).to(KinesisTableDescriptionSupplier.class).in(Scopes.SINGLETON);
                    }
                }
        );

        this.injector = app.strictConfig()
                    .doNotInitializeLogging()
                    .setRequiredConfigurationProperties(config)
                    .setOptionalConfigurationProperties(optionalConfig)
                    .initialize();

        KinesisConnector connector = this.injector.getInstance(KinesisConnector.class);

        // Register objects for shutdown, at the moment only KinesisTableDescriptionSupplier
        if (!tableDescriptionSupplier.isPresent()) {
            // This will shutdown related dependent objects as well:
            KinesisTableDescriptionSupplier supp = getTableDescSupplier(this.injector);
            connector.registerShutdownObject(supp);
        }

        log.info("Done with injector.  Returning the connector itself.");
        return connector;
    }
    catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
 
Example #11
Source File: BloomFilterParametricType.java    From presto-bloomfilter with Apache License 2.0 4 votes vote down vote up
@Override
public Type createType(TypeManager typeManager, List<TypeParameter> types)
{
    return new BloomFilterType();
}
 
Example #12
Source File: BloomFilterPlugin.java    From presto-bloomfilter with Apache License 2.0 4 votes vote down vote up
@Inject
public void setTypeManager(TypeManager typeManager)
{
    Objects.requireNonNull(typeManager, "typeManager is null");
    log.info("Received type manager");
}
 
Example #13
Source File: KuduModule.java    From presto-kudu with Apache License 2.0 4 votes vote down vote up
public KuduModule(String connectorId, TypeManager typeManager) {
    this.connectorId = requireNonNull(connectorId, "connector id is null");
    this.typeManager = requireNonNull(typeManager, "typeManager is null");
}
 
Example #14
Source File: EthereumConnectorModule.java    From presto-ethereum with Apache License 2.0 4 votes vote down vote up
@Inject
public TypeDeserializer(TypeManager typeManager) {
    super(Type.class);
    this.typeManager = requireNonNull(typeManager, "typeManager is null");
}
 
Example #15
Source File: ParaflowModule.java    From paraflow with Apache License 2.0 4 votes vote down vote up
public ParaflowModule(String connectorId, TypeManager typeManager)
{
    this.connectorId = requireNonNull(connectorId, "connector id is null");
    this.typeManager = requireNonNull(typeManager, "typeManager is null");
}
 
Example #16
Source File: ParaflowPageSourceProvider.java    From paraflow with Apache License 2.0 4 votes vote down vote up
@Inject
public ParaflowPageSourceProvider(TypeManager typeManager, FSFactory fsFactory)
{
    this.typeManager = requireNonNull(typeManager, "typeManager is null");
    this.fsFactory = requireNonNull(fsFactory, "fsFactory is null");
}
 
Example #17
Source File: HbaseModule.java    From presto-connectors with Apache License 2.0 4 votes vote down vote up
@Inject
public TypeDeserializer(TypeManager typeManager)
{
    super(Type.class);
    this.typeManager = requireNonNull(typeManager, "typeManager is null");
}
 
Example #18
Source File: EsTypeManager.java    From presto-connectors with Apache License 2.0 4 votes vote down vote up
@Inject
private EsTypeManager(final TypeManager typeManager)
{
    this.typeManager = requireNonNull(typeManager, "typeManager is null");
}