Search in sources :

Example 1 with PageSorter

use of io.trino.spi.PageSorter in project trino by trinodb.

the class ServerMainModule method setup.

@Override
protected void setup(Binder binder) {
    ServerConfig serverConfig = buildConfigObject(ServerConfig.class);
    if (serverConfig.isCoordinator()) {
        install(new CoordinatorModule());
    } else {
        install(new WorkerModule());
    }
    binder.bind(StartupStatus.class).in(Scopes.SINGLETON);
    configBinder(binder).bindConfigDefaults(HttpServerConfig.class, httpServerConfig -> {
        httpServerConfig.setAdminEnabled(false);
    });
    binder.bind(PreparedStatementEncoder.class).in(Scopes.SINGLETON);
    binder.bind(HttpRequestSessionContextFactory.class).in(Scopes.SINGLETON);
    install(new InternalCommunicationModule());
    configBinder(binder).bindConfig(FeaturesConfig.class);
    configBinder(binder).bindConfig(OptimizerConfig.class);
    configBinder(binder).bindConfig(ProtocolConfig.class);
    binder.bind(SqlParser.class).in(Scopes.SINGLETON);
    jaxrsBinder(binder).bind(ThrowableMapper.class);
    configBinder(binder).bindConfig(QueryManagerConfig.class);
    configBinder(binder).bindConfig(SqlEnvironmentConfig.class);
    newOptionalBinder(binder, ExplainAnalyzeContext.class);
    binder.bind(StatementAnalyzerFactory.class).in(Scopes.SINGLETON);
    // GC Monitor
    binder.bind(GcMonitor.class).to(JmxGcMonitor.class).in(Scopes.SINGLETON);
    newExporter(binder).export(GcMonitor.class).withGeneratedName();
    // session properties
    newSetBinder(binder, SystemSessionPropertiesProvider.class).addBinding().to(SystemSessionProperties.class);
    binder.bind(SessionPropertyManager.class).in(Scopes.SINGLETON);
    binder.bind(SystemSessionProperties.class).in(Scopes.SINGLETON);
    binder.bind(SessionPropertyDefaults.class).in(Scopes.SINGLETON);
    // schema properties
    binder.bind(SchemaPropertyManager.class).in(Scopes.SINGLETON);
    // table properties
    binder.bind(TablePropertyManager.class).in(Scopes.SINGLETON);
    // materialized view properties
    binder.bind(MaterializedViewPropertyManager.class).in(Scopes.SINGLETON);
    // column properties
    binder.bind(ColumnPropertyManager.class).in(Scopes.SINGLETON);
    // analyze properties
    binder.bind(AnalyzePropertyManager.class).in(Scopes.SINGLETON);
    // table procedures properties
    binder.bind(TableProceduresPropertyManager.class).in(Scopes.SINGLETON);
    // node manager
    discoveryBinder(binder).bindSelector("trino");
    binder.bind(DiscoveryNodeManager.class).in(Scopes.SINGLETON);
    binder.bind(InternalNodeManager.class).to(DiscoveryNodeManager.class).in(Scopes.SINGLETON);
    newExporter(binder).export(DiscoveryNodeManager.class).withGeneratedName();
    httpClientBinder(binder).bindHttpClient("node-manager", ForNodeManager.class).withTracing().withConfigDefaults(config -> {
        config.setIdleTimeout(new Duration(30, SECONDS));
        config.setRequestTimeout(new Duration(10, SECONDS));
    });
    // node scheduler
    // TODO: remove from NodePartitioningManager and move to CoordinatorModule
    configBinder(binder).bindConfig(NodeSchedulerConfig.class);
    binder.bind(NodeScheduler.class).in(Scopes.SINGLETON);
    binder.bind(NodeTaskMap.class).in(Scopes.SINGLETON);
    newExporter(binder).export(NodeScheduler.class).withGeneratedName();
    // network topology
    // TODO: move to CoordinatorModule when NodeScheduler is moved
    install(conditionalModule(NodeSchedulerConfig.class, config -> UNIFORM == config.getNodeSchedulerPolicy(), new UniformNodeSelectorModule()));
    install(conditionalModule(NodeSchedulerConfig.class, config -> TOPOLOGY == config.getNodeSchedulerPolicy(), new TopologyAwareNodeSelectorModule()));
    // task execution
    configBinder(binder).bindConfig(FailureInjectionConfig.class);
    binder.bind(FailureInjector.class).in(Scopes.SINGLETON);
    jaxrsBinder(binder).bind(TaskResource.class);
    newExporter(binder).export(TaskResource.class).withGeneratedName();
    jaxrsBinder(binder).bind(TaskExecutorResource.class);
    newExporter(binder).export(TaskExecutorResource.class).withGeneratedName();
    binder.bind(TaskManagementExecutor.class).in(Scopes.SINGLETON);
    binder.bind(SqlTaskManager.class).in(Scopes.SINGLETON);
    binder.bind(TableExecuteContextManager.class).in(Scopes.SINGLETON);
    // memory revoking scheduler
    binder.bind(MemoryRevokingScheduler.class).in(Scopes.SINGLETON);
    // Add monitoring for JVM pauses
    binder.bind(PauseMeter.class).in(Scopes.SINGLETON);
    newExporter(binder).export(PauseMeter.class).withGeneratedName();
    configBinder(binder).bindConfig(MemoryManagerConfig.class);
    configBinder(binder).bindConfig(NodeMemoryConfig.class);
    binder.bind(LocalMemoryManager.class).in(Scopes.SINGLETON);
    binder.bind(LocalMemoryManagerExporter.class).in(Scopes.SINGLETON);
    newOptionalBinder(binder, VersionEmbedder.class).setDefault().to(EmbedVersion.class).in(Scopes.SINGLETON);
    newExporter(binder).export(SqlTaskManager.class).withGeneratedName();
    binder.bind(TaskExecutor.class).in(Scopes.SINGLETON);
    newExporter(binder).export(TaskExecutor.class).withGeneratedName();
    binder.bind(MultilevelSplitQueue.class).in(Scopes.SINGLETON);
    newExporter(binder).export(MultilevelSplitQueue.class).withGeneratedName();
    binder.bind(LocalExecutionPlanner.class).in(Scopes.SINGLETON);
    configBinder(binder).bindConfig(CompilerConfig.class);
    binder.bind(ExpressionCompiler.class).in(Scopes.SINGLETON);
    newExporter(binder).export(ExpressionCompiler.class).withGeneratedName();
    binder.bind(PageFunctionCompiler.class).in(Scopes.SINGLETON);
    newExporter(binder).export(PageFunctionCompiler.class).withGeneratedName();
    configBinder(binder).bindConfig(TaskManagerConfig.class);
    binder.bind(IndexJoinLookupStats.class).in(Scopes.SINGLETON);
    newExporter(binder).export(IndexJoinLookupStats.class).withGeneratedName();
    binder.bind(AsyncHttpExecutionMBean.class).in(Scopes.SINGLETON);
    newExporter(binder).export(AsyncHttpExecutionMBean.class).withGeneratedName();
    binder.bind(JoinFilterFunctionCompiler.class).in(Scopes.SINGLETON);
    newExporter(binder).export(JoinFilterFunctionCompiler.class).withGeneratedName();
    binder.bind(JoinCompiler.class).in(Scopes.SINGLETON);
    newExporter(binder).export(JoinCompiler.class).withGeneratedName();
    binder.bind(OrderingCompiler.class).in(Scopes.SINGLETON);
    newExporter(binder).export(OrderingCompiler.class).withGeneratedName();
    binder.bind(PagesIndex.Factory.class).to(PagesIndex.DefaultFactory.class);
    newOptionalBinder(binder, OperatorFactories.class).setDefault().to(TrinoOperatorFactories.class).in(Scopes.SINGLETON);
    jaxrsBinder(binder).bind(PagesResponseWriter.class);
    // exchange client
    binder.bind(DirectExchangeClientSupplier.class).to(DirectExchangeClientFactory.class).in(Scopes.SINGLETON);
    httpClientBinder(binder).bindHttpClient("exchange", ForExchange.class).withTracing().withFilter(GenerateTraceTokenRequestFilter.class).withConfigDefaults(config -> {
        config.setIdleTimeout(new Duration(30, SECONDS));
        config.setRequestTimeout(new Duration(10, SECONDS));
        config.setMaxConnectionsPerServer(250);
        config.setMaxContentLength(DataSize.of(32, MEGABYTE));
    });
    configBinder(binder).bindConfig(DirectExchangeClientConfig.class);
    binder.bind(ExchangeExecutionMBean.class).in(Scopes.SINGLETON);
    newExporter(binder).export(ExchangeExecutionMBean.class).withGeneratedName();
    // execution
    binder.bind(LocationFactory.class).to(HttpLocationFactory.class).in(Scopes.SINGLETON);
    // memory manager
    jaxrsBinder(binder).bind(MemoryResource.class);
    jsonCodecBinder(binder).bindJsonCodec(MemoryInfo.class);
    // transaction manager
    configBinder(binder).bindConfig(TransactionManagerConfig.class);
    // data stream provider
    binder.bind(PageSourceManager.class).in(Scopes.SINGLETON);
    binder.bind(PageSourceProvider.class).to(PageSourceManager.class).in(Scopes.SINGLETON);
    // page sink provider
    binder.bind(PageSinkManager.class).in(Scopes.SINGLETON);
    binder.bind(PageSinkProvider.class).to(PageSinkManager.class).in(Scopes.SINGLETON);
    // metadata
    binder.bind(StaticCatalogStore.class).in(Scopes.SINGLETON);
    configBinder(binder).bindConfig(StaticCatalogStoreConfig.class);
    binder.bind(MetadataManager.class).in(Scopes.SINGLETON);
    binder.bind(Metadata.class).to(MetadataManager.class).in(Scopes.SINGLETON);
    newOptionalBinder(binder, SystemSecurityMetadata.class).setDefault().to(DisabledSystemSecurityMetadata.class).in(Scopes.SINGLETON);
    binder.bind(GlobalFunctionCatalog.class).in(Scopes.SINGLETON);
    binder.bind(TypeOperatorsCache.class).in(Scopes.SINGLETON);
    newExporter(binder).export(TypeOperatorsCache.class).as(factory -> factory.generatedNameOf(TypeOperators.class));
    binder.bind(BlockTypeOperators.class).in(Scopes.SINGLETON);
    newExporter(binder).export(TypeOperatorsCache.class).withGeneratedName();
    binder.bind(ProcedureRegistry.class).in(Scopes.SINGLETON);
    binder.bind(TableProceduresRegistry.class).in(Scopes.SINGLETON);
    binder.bind(PlannerContext.class).in(Scopes.SINGLETON);
    // function
    binder.bind(FunctionManager.class).in(Scopes.SINGLETON);
    newSetBinder(binder, FunctionBundle.class);
    binder.bind(RegisterFunctionBundles.class).asEagerSingleton();
    // type
    binder.bind(TypeAnalyzer.class).in(Scopes.SINGLETON);
    jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
    jsonBinder(binder).addDeserializerBinding(TypeSignature.class).to(TypeSignatureDeserializer.class);
    jsonBinder(binder).addKeyDeserializerBinding(TypeSignature.class).to(TypeSignatureKeyDeserializer.class);
    binder.bind(TypeRegistry.class).in(Scopes.SINGLETON);
    binder.bind(TypeManager.class).to(InternalTypeManager.class).in(Scopes.SINGLETON);
    newSetBinder(binder, Type.class);
    // split manager
    binder.bind(SplitManager.class).in(Scopes.SINGLETON);
    // node partitioning manager
    binder.bind(NodePartitioningManager.class).in(Scopes.SINGLETON);
    // index manager
    binder.bind(IndexManager.class).in(Scopes.SINGLETON);
    // handle resolver
    binder.install(new HandleJsonModule());
    // connector
    binder.bind(ConnectorManager.class).in(Scopes.SINGLETON);
    // system connector
    binder.install(new SystemConnectorModule());
    // slice
    jsonBinder(binder).addSerializerBinding(Slice.class).to(SliceSerializer.class);
    jsonBinder(binder).addDeserializerBinding(Slice.class).to(SliceDeserializer.class);
    // expression
    jsonBinder(binder).addSerializerBinding(Expression.class).to(ExpressionSerializer.class);
    jsonBinder(binder).addDeserializerBinding(Expression.class).to(ExpressionDeserializer.class);
    // split monitor
    binder.bind(SplitMonitor.class).in(Scopes.SINGLETON);
    // version and announcement
    binder.bind(NodeVersion.class).toInstance(new NodeVersion(nodeVersion));
    discoveryBinder(binder).bindHttpAnnouncement("trino").addProperty("node_version", nodeVersion).addProperty("coordinator", String.valueOf(serverConfig.isCoordinator()));
    // server info resource
    jaxrsBinder(binder).bind(ServerInfoResource.class);
    // node status resource
    jaxrsBinder(binder).bind(StatusResource.class);
    // plugin manager
    binder.bind(PluginManager.class).in(Scopes.SINGLETON);
    newOptionalBinder(binder, PluginsProvider.class).setDefault().to(ServerPluginsProvider.class).in(Scopes.SINGLETON);
    configBinder(binder).bindConfig(ServerPluginsProviderConfig.class);
    binder.bind(CatalogManager.class).in(Scopes.SINGLETON);
    // block encodings
    binder.bind(BlockEncodingManager.class).in(Scopes.SINGLETON);
    jsonBinder(binder).addSerializerBinding(Block.class).to(BlockJsonSerde.Serializer.class);
    jsonBinder(binder).addDeserializerBinding(Block.class).to(BlockJsonSerde.Deserializer.class);
    binder.bind(BlockEncodingSerde.class).to(InternalBlockEncodingSerde.class).in(Scopes.SINGLETON);
    // thread visualizer
    jaxrsBinder(binder).bind(ThreadResource.class);
    // PageSorter
    binder.bind(PageSorter.class).to(PagesIndexPageSorter.class).in(Scopes.SINGLETON);
    // PageIndexer
    binder.bind(PageIndexerFactory.class).to(GroupByHashPageIndexerFactory.class).in(Scopes.SINGLETON);
    // Finalizer
    binder.bind(FinalizerService.class).in(Scopes.SINGLETON);
    // Spiller
    binder.bind(SpillerFactory.class).to(GenericSpillerFactory.class).in(Scopes.SINGLETON);
    binder.bind(SingleStreamSpillerFactory.class).to(FileSingleStreamSpillerFactory.class).in(Scopes.SINGLETON);
    binder.bind(PartitioningSpillerFactory.class).to(GenericPartitioningSpillerFactory.class).in(Scopes.SINGLETON);
    binder.bind(SpillerStats.class).in(Scopes.SINGLETON);
    newExporter(binder).export(SpillerFactory.class).withGeneratedName();
    binder.bind(LocalSpillManager.class).in(Scopes.SINGLETON);
    configBinder(binder).bindConfig(NodeSpillConfig.class);
    // Dynamic Filtering
    configBinder(binder).bindConfig(DynamicFilterConfig.class);
    // dispatcher
    // TODO remove dispatcher fromm ServerMainModule, and bind dependent components only on coordinators
    newOptionalBinder(binder, DispatchManager.class);
    // Added for RuleStatsSystemTable
    // TODO: remove this when system tables are bound separately for coordinator and worker
    newOptionalBinder(binder, RuleStatsRecorder.class);
    // cleanup
    binder.bind(ExecutorCleanup.class).in(Scopes.SINGLETON);
}
Also used : TableProceduresPropertyManager(io.trino.metadata.TableProceduresPropertyManager) ConnectorManager(io.trino.connector.ConnectorManager) PagesIndexPageSorter(io.trino.operator.PagesIndexPageSorter) TopologyAwareNodeSelectorModule(io.trino.execution.scheduler.TopologyAwareNodeSelectorModule) ExpressionSerializer(io.trino.server.ExpressionSerialization.ExpressionSerializer) TypeOperators(io.trino.spi.type.TypeOperators) HttpServerConfig(io.airlift.http.server.HttpServerConfig) PauseMeter(io.airlift.stats.PauseMeter) MemoryRevokingScheduler(io.trino.execution.MemoryRevokingScheduler) TransactionManagerConfig(io.trino.transaction.TransactionManagerConfig) LocalSpillManager(io.trino.spiller.LocalSpillManager) NodeScheduler(io.trino.execution.scheduler.NodeScheduler) FinalizerService(io.trino.util.FinalizerService) BoundedExecutor(io.airlift.concurrent.BoundedExecutor) Executors.newScheduledThreadPool(java.util.concurrent.Executors.newScheduledThreadPool) Multibinder.newSetBinder(com.google.inject.multibindings.Multibinder.newSetBinder) MetadataManager(io.trino.metadata.MetadataManager) FailureInjectionConfig(io.trino.execution.FailureInjectionConfig) StaticCatalogStore(io.trino.metadata.StaticCatalogStore) JsonCodecBinder.jsonCodecBinder(io.airlift.json.JsonCodecBinder.jsonCodecBinder) JmxGcMonitor(io.airlift.stats.JmxGcMonitor) LocalMemoryManagerExporter(io.trino.memory.LocalMemoryManagerExporter) NodeSchedulerConfig(io.trino.execution.scheduler.NodeSchedulerConfig) PageSinkManager(io.trino.split.PageSinkManager) Set(java.util.Set) TrinoOperatorFactories(io.trino.operator.TrinoOperatorFactories) SystemSessionPropertiesProvider(io.trino.SystemSessionPropertiesProvider) PreparedStatementEncoder(io.trino.server.protocol.PreparedStatementEncoder) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) SystemConnectorModule(io.trino.connector.system.SystemConnectorModule) IndexJoinLookupStats(io.trino.operator.index.IndexJoinLookupStats) HttpClientBinder.httpClientBinder(io.airlift.http.client.HttpClientBinder.httpClientBinder) TaskManagerConfig(io.trino.execution.TaskManagerConfig) InternalBlockEncodingSerde(io.trino.metadata.InternalBlockEncodingSerde) DiscoveryBinder.discoveryBinder(io.airlift.discovery.client.DiscoveryBinder.discoveryBinder) VersionEmbedder(io.trino.spi.VersionEmbedder) EmbedVersion(io.trino.version.EmbedVersion) SpillerFactory(io.trino.spiller.SpillerFactory) ConfigBinder.configBinder(io.airlift.configuration.ConfigBinder.configBinder) ExplainAnalyzeContext(io.trino.execution.ExplainAnalyzeContext) InternalNodeManager(io.trino.metadata.InternalNodeManager) Slice(io.airlift.slice.Slice) SqlTaskManager(io.trino.execution.SqlTaskManager) MEGABYTE(io.airlift.units.DataSize.Unit.MEGABYTE) PluginsProvider(io.trino.server.PluginManager.PluginsProvider) NodePartitioningManager(io.trino.sql.planner.NodePartitioningManager) JoinCompiler(io.trino.sql.gen.JoinCompiler) MemoryInfo(io.trino.memory.MemoryInfo) MemoryResource(io.trino.memory.MemoryResource) MultilevelSplitQueue(io.trino.execution.executor.MultilevelSplitQueue) GroupByHashPageIndexerFactory(io.trino.operator.GroupByHashPageIndexerFactory) TypeRegistry(io.trino.metadata.TypeRegistry) RuleStatsRecorder(io.trino.sql.planner.RuleStatsRecorder) SliceDeserializer(io.trino.server.SliceSerialization.SliceDeserializer) Binder(com.google.inject.Binder) BlockJsonSerde(io.trino.block.BlockJsonSerde) SystemFunctionBundle(io.trino.metadata.SystemFunctionBundle) PageIndexerFactory(io.trino.spi.PageIndexerFactory) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) NodeVersion(io.trino.client.NodeVersion) TaskExecutor(io.trino.execution.executor.TaskExecutor) SqlEnvironmentConfig(io.trino.sql.SqlEnvironmentConfig) BlockTypeOperators(io.trino.type.BlockTypeOperators) Executor(java.util.concurrent.Executor) PageSinkProvider(io.trino.split.PageSinkProvider) SpillerStats(io.trino.spiller.SpillerStats) DirectExchangeClientConfig(io.trino.operator.DirectExchangeClientConfig) HttpLocationFactory(io.trino.server.remotetask.HttpLocationFactory) LocalExecutionPlanner(io.trino.sql.planner.LocalExecutionPlanner) FunctionBundle(io.trino.metadata.FunctionBundle) TypeSignatureKeyDeserializer(io.trino.type.TypeSignatureKeyDeserializer) TypeAnalyzer(io.trino.sql.planner.TypeAnalyzer) InternalFunctionBundle(io.trino.metadata.InternalFunctionBundle) StatementAnalyzerFactory(io.trino.sql.analyzer.StatementAnalyzerFactory) TablePropertyManager(io.trino.metadata.TablePropertyManager) ExpressionDeserializer(io.trino.server.ExpressionSerialization.ExpressionDeserializer) MaterializedViewPropertyManager(io.trino.metadata.MaterializedViewPropertyManager) UNIFORM(io.trino.execution.scheduler.NodeSchedulerConfig.NodeSchedulerPolicy.UNIFORM) GcMonitor(io.airlift.stats.GcMonitor) OptimizerConfig(io.trino.sql.planner.OptimizerConfig) NodeMemoryConfig(io.trino.memory.NodeMemoryConfig) SystemSecurityMetadata(io.trino.metadata.SystemSecurityMetadata) NodeTaskMap(io.trino.execution.NodeTaskMap) JoinFilterFunctionCompiler(io.trino.sql.gen.JoinFilterFunctionCompiler) InternalTypeManager(io.trino.type.InternalTypeManager) SplitManager(io.trino.split.SplitManager) NodeSpillConfig(io.trino.spiller.NodeSpillConfig) JsonBinder.jsonBinder(io.airlift.json.JsonBinder.jsonBinder) Duration(io.airlift.units.Duration) PreDestroy(javax.annotation.PreDestroy) DisabledSystemSecurityMetadata(io.trino.metadata.DisabledSystemSecurityMetadata) Block(io.trino.spi.block.Block) ConditionalModule.conditionalModule(io.airlift.configuration.ConditionalModule.conditionalModule) PageSorter(io.trino.spi.PageSorter) ExportBinder.newExporter(org.weakref.jmx.guice.ExportBinder.newExporter) LiteralFunction(io.trino.metadata.LiteralFunction) SqlParser(io.trino.sql.parser.SqlParser) FailureInjector(io.trino.execution.FailureInjector) OptionalBinder.newOptionalBinder(com.google.inject.multibindings.OptionalBinder.newOptionalBinder) TaskManagementExecutor(io.trino.execution.TaskManagementExecutor) TypeSignature(io.trino.spi.type.TypeSignature) ProvidesIntoSet(com.google.inject.multibindings.ProvidesIntoSet) PageFunctionCompiler(io.trino.sql.gen.PageFunctionCompiler) SliceSerializer(io.trino.server.SliceSerialization.SliceSerializer) DirectExchangeClientSupplier(io.trino.operator.DirectExchangeClientSupplier) SplitMonitor(io.trino.event.SplitMonitor) SessionPropertyManager(io.trino.metadata.SessionPropertyManager) DataSize(io.airlift.units.DataSize) QueryManagerConfig(io.trino.execution.QueryManagerConfig) List(java.util.List) LocationFactory(io.trino.execution.LocationFactory) DirectExchangeClientFactory(io.trino.operator.DirectExchangeClientFactory) JaxrsBinder.jaxrsBinder(io.airlift.jaxrs.JaxrsBinder.jaxrsBinder) Expression(io.trino.sql.tree.Expression) ColumnPropertyManager(io.trino.metadata.ColumnPropertyManager) PageSourceProvider(io.trino.split.PageSourceProvider) TypeSignatureDeserializer(io.trino.type.TypeSignatureDeserializer) PlannerContext(io.trino.sql.PlannerContext) GlobalFunctionCatalog(io.trino.metadata.GlobalFunctionCatalog) StaticCatalogStoreConfig(io.trino.metadata.StaticCatalogStoreConfig) OperatorFactories(io.trino.operator.OperatorFactories) FileSingleStreamSpillerFactory(io.trino.spiller.FileSingleStreamSpillerFactory) OrderingCompiler(io.trino.sql.gen.OrderingCompiler) Type(io.trino.spi.type.Type) Singleton(javax.inject.Singleton) MemoryManagerConfig(io.trino.memory.MemoryManagerConfig) ExpressionCompiler(io.trino.sql.gen.ExpressionCompiler) Inject(javax.inject.Inject) AbstractConfigurationAwareModule(io.airlift.configuration.AbstractConfigurationAwareModule) BlockEncodingManager(io.trino.metadata.BlockEncodingManager) ImmutableList(com.google.common.collect.ImmutableList) Threads.daemonThreadsNamed(io.airlift.concurrent.Threads.daemonThreadsNamed) Objects.requireNonNull(java.util.Objects.requireNonNull) SystemSessionProperties(io.trino.SystemSessionProperties) ForExchange(io.trino.operator.ForExchange) GenericPartitioningSpillerFactory(io.trino.spiller.GenericPartitioningSpillerFactory) DynamicFilterConfig(io.trino.execution.DynamicFilterConfig) TableProceduresRegistry(io.trino.metadata.TableProceduresRegistry) IndexManager(io.trino.index.IndexManager) TypeOperatorsCache(io.trino.type.TypeOperatorsCache) ExecutorService(java.util.concurrent.ExecutorService) PagesIndex(io.trino.operator.PagesIndex) SchemaPropertyManager(io.trino.metadata.SchemaPropertyManager) DispatchManager(io.trino.dispatcher.DispatchManager) TableExecuteContextManager(io.trino.execution.TableExecuteContextManager) UniformNodeSelectorModule(io.trino.execution.scheduler.UniformNodeSelectorModule) ForNodeManager(io.trino.metadata.ForNodeManager) HandleJsonModule(io.trino.metadata.HandleJsonModule) SingleStreamSpillerFactory(io.trino.spiller.SingleStreamSpillerFactory) DiscoveryNodeManager(io.trino.metadata.DiscoveryNodeManager) TOPOLOGY(io.trino.execution.scheduler.NodeSchedulerConfig.NodeSchedulerPolicy.TOPOLOGY) GenericSpillerFactory(io.trino.spiller.GenericSpillerFactory) PageSourceManager(io.trino.split.PageSourceManager) Scopes(com.google.inject.Scopes) FunctionManager(io.trino.metadata.FunctionManager) CompilerConfig(io.trino.sql.planner.CompilerConfig) PartitioningSpillerFactory(io.trino.spiller.PartitioningSpillerFactory) Provides(com.google.inject.Provides) FeaturesConfig(io.trino.FeaturesConfig) Executors.newCachedThreadPool(java.util.concurrent.Executors.newCachedThreadPool) CatalogManager(io.trino.metadata.CatalogManager) ProcedureRegistry(io.trino.metadata.ProcedureRegistry) Metadata(io.trino.metadata.Metadata) BlockEncodingSerde(io.trino.spi.block.BlockEncodingSerde) TypeManager(io.trino.spi.type.TypeManager) TypeDeserializer(io.trino.type.TypeDeserializer) AnalyzePropertyManager(io.trino.metadata.AnalyzePropertyManager) SECONDS(java.util.concurrent.TimeUnit.SECONDS) LocalMemoryManager(io.trino.memory.LocalMemoryManager) PluginsProvider(io.trino.server.PluginManager.PluginsProvider) TrinoOperatorFactories(io.trino.operator.TrinoOperatorFactories) FailureInjector(io.trino.execution.FailureInjector) NodeVersion(io.trino.client.NodeVersion) TypeSignature(io.trino.spi.type.TypeSignature) TableExecuteContextManager(io.trino.execution.TableExecuteContextManager) InternalTypeManager(io.trino.type.InternalTypeManager) FunctionManager(io.trino.metadata.FunctionManager) JoinCompiler(io.trino.sql.gen.JoinCompiler) GenericPartitioningSpillerFactory(io.trino.spiller.GenericPartitioningSpillerFactory) TopologyAwareNodeSelectorModule(io.trino.execution.scheduler.TopologyAwareNodeSelectorModule) TrinoOperatorFactories(io.trino.operator.TrinoOperatorFactories) OperatorFactories(io.trino.operator.OperatorFactories) StatementAnalyzerFactory(io.trino.sql.analyzer.StatementAnalyzerFactory) BlockJsonSerde(io.trino.block.BlockJsonSerde) MultilevelSplitQueue(io.trino.execution.executor.MultilevelSplitQueue) TypeOperatorsCache(io.trino.type.TypeOperatorsCache) JmxGcMonitor(io.airlift.stats.JmxGcMonitor) GcMonitor(io.airlift.stats.GcMonitor) NodeSchedulerConfig(io.trino.execution.scheduler.NodeSchedulerConfig) PagesIndex(io.trino.operator.PagesIndex) BlockTypeOperators(io.trino.type.BlockTypeOperators) LocalMemoryManager(io.trino.memory.LocalMemoryManager) SystemConnectorModule(io.trino.connector.system.SystemConnectorModule) EmbedVersion(io.trino.version.EmbedVersion) PageSinkManager(io.trino.split.PageSinkManager) JoinFilterFunctionCompiler(io.trino.sql.gen.JoinFilterFunctionCompiler) VersionEmbedder(io.trino.spi.VersionEmbedder) ConnectorManager(io.trino.connector.ConnectorManager) TypeAnalyzer(io.trino.sql.planner.TypeAnalyzer) CatalogManager(io.trino.metadata.CatalogManager) UniformNodeSelectorModule(io.trino.execution.scheduler.UniformNodeSelectorModule) Type(io.trino.spi.type.Type) PlannerContext(io.trino.sql.PlannerContext) Expression(io.trino.sql.tree.Expression) FinalizerService(io.trino.util.FinalizerService) TaskManagementExecutor(io.trino.execution.TaskManagementExecutor) MemoryRevokingScheduler(io.trino.execution.MemoryRevokingScheduler) SystemSecurityMetadata(io.trino.metadata.SystemSecurityMetadata) DisabledSystemSecurityMetadata(io.trino.metadata.DisabledSystemSecurityMetadata) InternalBlockEncodingSerde(io.trino.metadata.InternalBlockEncodingSerde) TablePropertyManager(io.trino.metadata.TablePropertyManager) TypeRegistry(io.trino.metadata.TypeRegistry) PageSourceManager(io.trino.split.PageSourceManager) HttpServerConfig(io.airlift.http.server.HttpServerConfig) PagesIndexPageSorter(io.trino.operator.PagesIndexPageSorter) FileSingleStreamSpillerFactory(io.trino.spiller.FileSingleStreamSpillerFactory) SessionPropertyManager(io.trino.metadata.SessionPropertyManager) OrderingCompiler(io.trino.sql.gen.OrderingCompiler) NodeScheduler(io.trino.execution.scheduler.NodeScheduler) TypeOperators(io.trino.spi.type.TypeOperators) BlockTypeOperators(io.trino.type.BlockTypeOperators) ForExchange(io.trino.operator.ForExchange) IndexJoinLookupStats(io.trino.operator.index.IndexJoinLookupStats) StaticCatalogStore(io.trino.metadata.StaticCatalogStore) NodeTaskMap(io.trino.execution.NodeTaskMap) SplitMonitor(io.trino.event.SplitMonitor) HttpLocationFactory(io.trino.server.remotetask.HttpLocationFactory) SqlParser(io.trino.sql.parser.SqlParser) Duration(io.airlift.units.Duration) PauseMeter(io.airlift.stats.PauseMeter) SpillerStats(io.trino.spiller.SpillerStats) IndexManager(io.trino.index.IndexManager) LocalSpillManager(io.trino.spiller.LocalSpillManager) SqlTaskManager(io.trino.execution.SqlTaskManager) TaskExecutor(io.trino.execution.executor.TaskExecutor) BlockEncodingManager(io.trino.metadata.BlockEncodingManager) Slice(io.airlift.slice.Slice) Block(io.trino.spi.block.Block) ExpressionCompiler(io.trino.sql.gen.ExpressionCompiler) GroupByHashPageIndexerFactory(io.trino.operator.GroupByHashPageIndexerFactory) ColumnPropertyManager(io.trino.metadata.ColumnPropertyManager) PageFunctionCompiler(io.trino.sql.gen.PageFunctionCompiler) MaterializedViewPropertyManager(io.trino.metadata.MaterializedViewPropertyManager) SpillerFactory(io.trino.spiller.SpillerFactory) GroupByHashPageIndexerFactory(io.trino.operator.GroupByHashPageIndexerFactory) PageIndexerFactory(io.trino.spi.PageIndexerFactory) HttpLocationFactory(io.trino.server.remotetask.HttpLocationFactory) StatementAnalyzerFactory(io.trino.sql.analyzer.StatementAnalyzerFactory) LocationFactory(io.trino.execution.LocationFactory) DirectExchangeClientFactory(io.trino.operator.DirectExchangeClientFactory) FileSingleStreamSpillerFactory(io.trino.spiller.FileSingleStreamSpillerFactory) GenericPartitioningSpillerFactory(io.trino.spiller.GenericPartitioningSpillerFactory) SingleStreamSpillerFactory(io.trino.spiller.SingleStreamSpillerFactory) GenericSpillerFactory(io.trino.spiller.GenericSpillerFactory) PartitioningSpillerFactory(io.trino.spiller.PartitioningSpillerFactory) DisabledSystemSecurityMetadata(io.trino.metadata.DisabledSystemSecurityMetadata) LocalMemoryManagerExporter(io.trino.memory.LocalMemoryManagerExporter) NodePartitioningManager(io.trino.sql.planner.NodePartitioningManager) TableProceduresRegistry(io.trino.metadata.TableProceduresRegistry) HandleJsonModule(io.trino.metadata.HandleJsonModule) SchemaPropertyManager(io.trino.metadata.SchemaPropertyManager) GenericSpillerFactory(io.trino.spiller.GenericSpillerFactory) AnalyzePropertyManager(io.trino.metadata.AnalyzePropertyManager) LocalExecutionPlanner(io.trino.sql.planner.LocalExecutionPlanner) ProcedureRegistry(io.trino.metadata.ProcedureRegistry) DirectExchangeClientFactory(io.trino.operator.DirectExchangeClientFactory) SpillerFactory(io.trino.spiller.SpillerFactory) FileSingleStreamSpillerFactory(io.trino.spiller.FileSingleStreamSpillerFactory) GenericPartitioningSpillerFactory(io.trino.spiller.GenericPartitioningSpillerFactory) SingleStreamSpillerFactory(io.trino.spiller.SingleStreamSpillerFactory) GenericSpillerFactory(io.trino.spiller.GenericSpillerFactory) PartitioningSpillerFactory(io.trino.spiller.PartitioningSpillerFactory) GlobalFunctionCatalog(io.trino.metadata.GlobalFunctionCatalog) SplitManager(io.trino.split.SplitManager) PreparedStatementEncoder(io.trino.server.protocol.PreparedStatementEncoder) MetadataManager(io.trino.metadata.MetadataManager) JmxGcMonitor(io.airlift.stats.JmxGcMonitor) DiscoveryNodeManager(io.trino.metadata.DiscoveryNodeManager) SystemSessionProperties(io.trino.SystemSessionProperties) TableProceduresPropertyManager(io.trino.metadata.TableProceduresPropertyManager)

Example 2 with PageSorter

use of io.trino.spi.PageSorter in project trino by trinodb.

the class BenchmarkPagesIndexPageSorter method runBenchmark.

@Benchmark
public int runBenchmark(BenchmarkData data) {
    PageSorter pageSorter = new PagesIndexPageSorter(new PagesIndex.TestingFactory(false));
    long[] addresses = pageSorter.sort(data.types, data.pages, data.sortChannels, nCopies(data.sortChannels.size(), ASC_NULLS_FIRST), 10_000);
    return addresses.length;
}
Also used : PagesIndexPageSorter(io.trino.operator.PagesIndexPageSorter) PagesIndexPageSorter(io.trino.operator.PagesIndexPageSorter) PageSorter(io.trino.spi.PageSorter) PagesIndex(io.trino.operator.PagesIndex) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 3 with PageSorter

use of io.trino.spi.PageSorter in project trino by trinodb.

the class HiveWriterFactory method createWriter.

public HiveWriter createWriter(Page partitionColumns, int position, OptionalInt bucketNumber) {
    if (bucketCount.isPresent()) {
        checkArgument(bucketNumber.isPresent(), "Bucket not provided for bucketed table");
        checkArgument(bucketNumber.getAsInt() < bucketCount.getAsInt(), "Bucket number %s must be less than bucket count %s", bucketNumber, bucketCount);
    } else {
        checkArgument(bucketNumber.isEmpty(), "Bucket number provided by for table that is not bucketed");
    }
    List<String> partitionValues = createPartitionValues(partitionColumnTypes, partitionColumns, position);
    Optional<String> partitionName;
    if (!partitionColumnNames.isEmpty()) {
        partitionName = Optional.of(FileUtils.makePartName(partitionColumnNames, partitionValues));
    } else {
        partitionName = Optional.empty();
    }
    // attempt to get the existing partition (if this is an existing partitioned table)
    Optional<Partition> partition = Optional.empty();
    if (!partitionValues.isEmpty() && table != null) {
        partition = pageSinkMetadataProvider.getPartition(partitionValues);
    }
    UpdateMode updateMode;
    Properties schema;
    WriteInfo writeInfo;
    StorageFormat outputStorageFormat;
    if (partition.isEmpty()) {
        if (table == null) {
            // Write to: a new partition in a new partitioned table,
            // or a new unpartitioned table.
            updateMode = UpdateMode.NEW;
            schema = new Properties();
            schema.setProperty(IOConstants.COLUMNS, dataColumns.stream().map(DataColumn::getName).collect(joining(",")));
            schema.setProperty(IOConstants.COLUMNS_TYPES, dataColumns.stream().map(DataColumn::getHiveType).map(HiveType::getHiveTypeName).map(HiveTypeName::toString).collect(joining(":")));
            if (partitionName.isEmpty()) {
                // new unpartitioned table
                writeInfo = locationService.getTableWriteInfo(locationHandle, false);
            } else {
                // a new partition in a new partitioned table
                writeInfo = locationService.getPartitionWriteInfo(locationHandle, partition, partitionName.get());
                if (!writeInfo.getWriteMode().isWritePathSameAsTargetPath()) {
                    // verify that the target directory for the partition does not already exist
                    if (HiveWriteUtils.pathExists(new HdfsContext(session), hdfsEnvironment, writeInfo.getTargetPath())) {
                        throw new TrinoException(HIVE_PATH_ALREADY_EXISTS, format("Target directory for new partition '%s' of table '%s.%s' already exists: %s", partitionName, schemaName, tableName, writeInfo.getTargetPath()));
                    }
                }
            }
        } else {
            // or an existing unpartitioned table
            if (partitionName.isPresent()) {
                // a new partition in an existing partitioned table
                updateMode = UpdateMode.NEW;
                writeInfo = locationService.getPartitionWriteInfo(locationHandle, partition, partitionName.get());
            } else {
                switch(insertExistingPartitionsBehavior) {
                    case APPEND:
                        updateMode = UpdateMode.APPEND;
                        writeInfo = locationService.getTableWriteInfo(locationHandle, false);
                        break;
                    case OVERWRITE:
                        updateMode = UpdateMode.OVERWRITE;
                        writeInfo = locationService.getTableWriteInfo(locationHandle, true);
                        break;
                    case ERROR:
                        throw new TrinoException(HIVE_TABLE_READ_ONLY, "Unpartitioned Hive tables are immutable");
                    default:
                        throw new IllegalArgumentException("Unsupported insert existing table behavior: " + insertExistingPartitionsBehavior);
                }
            }
            schema = getHiveSchema(table);
        }
        if (partitionName.isPresent()) {
            // Write to a new partition
            outputStorageFormat = fromHiveStorageFormat(partitionStorageFormat);
        } else {
            // Write to a new/existing unpartitioned table
            outputStorageFormat = fromHiveStorageFormat(tableStorageFormat);
        }
    } else {
        switch(insertExistingPartitionsBehavior) {
            // Write to: an existing partition in an existing partitioned table
            case APPEND:
                // Append to an existing partition
                updateMode = UpdateMode.APPEND;
                // Check the column types in partition schema match the column types in table schema
                List<Column> tableColumns = table.getDataColumns();
                List<Column> existingPartitionColumns = partition.get().getColumns();
                for (int i = 0; i < min(existingPartitionColumns.size(), tableColumns.size()); i++) {
                    HiveType tableType = tableColumns.get(i).getType();
                    HiveType partitionType = existingPartitionColumns.get(i).getType();
                    if (!tableType.equals(partitionType)) {
                        throw new TrinoException(HIVE_PARTITION_SCHEMA_MISMATCH, format("" + "You are trying to write into an existing partition in a table. " + "The table schema has changed since the creation of the partition. " + "Inserting rows into such partition is not supported. " + "The column '%s' in table '%s' is declared as type '%s', " + "but partition '%s' declared column '%s' as type '%s'.", tableColumns.get(i).getName(), tableName, tableType, partitionName, existingPartitionColumns.get(i).getName(), partitionType));
                    }
                }
                HiveWriteUtils.checkPartitionIsWritable(partitionName.get(), partition.get());
                outputStorageFormat = partition.get().getStorage().getStorageFormat();
                schema = getHiveSchema(partition.get(), table);
                writeInfo = locationService.getPartitionWriteInfo(locationHandle, partition, partitionName.get());
                break;
            case OVERWRITE:
                // Overwrite an existing partition
                // 
                // The behavior of overwrite considered as if first dropping the partition and inserting a new partition, thus:
                // * No partition writable check is required.
                // * Table schema and storage format is used for the new partition (instead of existing partition schema and storage format).
                updateMode = UpdateMode.OVERWRITE;
                outputStorageFormat = fromHiveStorageFormat(partitionStorageFormat);
                schema = getHiveSchema(table);
                writeInfo = locationService.getPartitionWriteInfo(locationHandle, Optional.empty(), partitionName.get());
                break;
            case ERROR:
                throw new TrinoException(HIVE_PARTITION_READ_ONLY, "Cannot insert into an existing partition of Hive table: " + partitionName.get());
            default:
                throw new IllegalArgumentException(format("Unsupported insert existing partitions behavior: %s", insertExistingPartitionsBehavior));
        }
    }
    additionalTableParameters.forEach(schema::setProperty);
    validateSchema(partitionName, schema);
    int bucketToUse = bucketNumber.isEmpty() ? 0 : bucketNumber.getAsInt();
    Path path;
    String fileNameWithExtension;
    if (transaction.isAcidTransactionRunning()) {
        String subdir = computeAcidSubdir(transaction);
        Path subdirPath = new Path(writeInfo.getWritePath(), subdir);
        path = createHiveBucketPath(subdirPath, bucketToUse, table.getParameters());
        fileNameWithExtension = path.getName();
    } else {
        String fileName = computeFileName(bucketNumber);
        fileNameWithExtension = fileName + getFileExtension(conf, outputStorageFormat);
        path = new Path(writeInfo.getWritePath(), fileNameWithExtension);
    }
    boolean useAcidSchema = isCreateTransactionalTable || (table != null && isFullAcidTable(table.getParameters()));
    FileWriter hiveFileWriter = null;
    for (HiveFileWriterFactory fileWriterFactory : fileWriterFactories) {
        Optional<FileWriter> fileWriter = fileWriterFactory.createFileWriter(path, dataColumns.stream().map(DataColumn::getName).collect(toList()), outputStorageFormat, schema, conf, session, bucketNumber, transaction, useAcidSchema, WriterKind.INSERT);
        if (fileWriter.isPresent()) {
            hiveFileWriter = fileWriter.get();
            break;
        }
    }
    if (hiveFileWriter == null) {
        hiveFileWriter = new RecordFileWriter(path, dataColumns.stream().map(DataColumn::getName).collect(toList()), outputStorageFormat, schema, partitionStorageFormat.getEstimatedWriterMemoryUsage(), conf, typeManager, parquetTimeZone, session);
    }
    String writerImplementation = hiveFileWriter.getClass().getName();
    Consumer<HiveWriter> onCommit = hiveWriter -> {
        Optional<Long> size;
        try {
            size = Optional.of(hiveWriter.getWrittenBytes());
        } catch (RuntimeException e) {
            // Do not fail the query if file system is not available
            size = Optional.empty();
        }
        eventClient.post(new WriteCompletedEvent(session.getQueryId(), path.toString(), schemaName, tableName, partitionName.orElse(null), outputStorageFormat.getOutputFormat(), writerImplementation, nodeManager.getCurrentNode().getVersion(), nodeManager.getCurrentNode().getHost(), session.getIdentity().getPrincipal().map(Principal::getName).orElse(null), nodeManager.getEnvironment(), sessionProperties, size.orElse(null), hiveWriter.getRowCount()));
    };
    if (!sortedBy.isEmpty()) {
        FileSystem fileSystem;
        Path tempFilePath;
        if (sortedWritingTempStagingPathEnabled) {
            String tempPrefix = sortedWritingTempStagingPath.replace("${USER}", new HdfsContext(session).getIdentity().getUser());
            tempFilePath = new Path(tempPrefix, ".tmp-sort." + path.getParent().getName() + "." + path.getName());
        } else {
            tempFilePath = new Path(path.getParent(), ".tmp-sort." + path.getName());
        }
        try {
            Configuration configuration = new Configuration(conf);
            // Explicitly set the default FS to local file system to avoid getting HDFS when sortedWritingTempStagingPath specifies no scheme
            configuration.set(FS_DEFAULT_NAME_KEY, "file:///");
            fileSystem = hdfsEnvironment.getFileSystem(session.getIdentity(), tempFilePath, configuration);
        } catch (IOException e) {
            throw new TrinoException(HIVE_WRITER_OPEN_ERROR, e);
        }
        List<Type> types = dataColumns.stream().map(column -> column.getHiveType().getType(typeManager, getTimestampPrecision(session))).collect(toImmutableList());
        Map<String, Integer> columnIndexes = new HashMap<>();
        for (int i = 0; i < dataColumns.size(); i++) {
            columnIndexes.put(dataColumns.get(i).getName(), i);
        }
        List<Integer> sortFields = new ArrayList<>();
        List<SortOrder> sortOrders = new ArrayList<>();
        for (SortingColumn column : sortedBy) {
            Integer index = columnIndexes.get(column.getColumnName());
            if (index == null) {
                throw new TrinoException(HIVE_INVALID_METADATA, format("Sorting column '%s' does exist in table '%s.%s'", column.getColumnName(), schemaName, tableName));
            }
            sortFields.add(index);
            sortOrders.add(column.getOrder().getSortOrder());
        }
        hiveFileWriter = new SortingFileWriter(fileSystem, tempFilePath, hiveFileWriter, sortBufferSize, maxOpenSortFiles, types, sortFields, sortOrders, pageSorter, typeManager.getTypeOperators(), OrcFileWriterFactory::createOrcDataSink);
    }
    return new HiveWriter(hiveFileWriter, partitionName, updateMode, fileNameWithExtension, writeInfo.getWritePath().toString(), writeInfo.getTargetPath().toString(), onCommit, hiveWriterStats);
}
Also used : DateTimeZone(org.joda.time.DateTimeZone) InsertExistingPartitionsBehavior(io.trino.plugin.hive.HiveSessionProperties.InsertExistingPartitionsBehavior) OrcFileWriterFactory(io.trino.plugin.hive.orc.OrcFileWriterFactory) FileSystem(org.apache.hadoop.fs.FileSystem) NodeManager(io.trino.spi.NodeManager) CompressionConfigUtil.configureCompression(io.trino.plugin.hive.util.CompressionConfigUtil.configureCompression) DIRECT_TO_TARGET_EXISTING_DIRECTORY(io.trino.plugin.hive.LocationHandle.WriteMode.DIRECT_TO_TARGET_EXISTING_DIRECTORY) AcidUtils.isInsertOnlyTable(org.apache.hadoop.hive.ql.io.AcidUtils.isInsertOnlyTable) HiveUtil.getColumnNames(io.trino.plugin.hive.util.HiveUtil.getColumnNames) CompressionCodec(org.apache.hadoop.io.compress.CompressionCodec) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Matcher(java.util.regex.Matcher) Column(io.trino.plugin.hive.metastore.Column) HiveIgnoreKeyTextOutputFormat(org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat) Collectors.toMap(java.util.stream.Collectors.toMap) HIVE_PARTITION_SCHEMA_MISMATCH(io.trino.plugin.hive.HiveErrorCode.HIVE_PARTITION_SCHEMA_MISMATCH) Maps.immutableEntry(com.google.common.collect.Maps.immutableEntry) PageSorter(io.trino.spi.PageSorter) Configuration(org.apache.hadoop.conf.Configuration) Map(java.util.Map) Path(org.apache.hadoop.fs.Path) HIVE_FILESYSTEM_ERROR(io.trino.plugin.hive.HiveErrorCode.HIVE_FILESYSTEM_ERROR) StorageFormat(io.trino.plugin.hive.metastore.StorageFormat) AcidTransaction(io.trino.plugin.hive.acid.AcidTransaction) ImmutableSet(com.google.common.collect.ImmutableSet) Table(io.trino.plugin.hive.metastore.Table) ImmutableMap(com.google.common.collect.ImmutableMap) AcidUtils.isFullAcidTable(org.apache.hadoop.hive.ql.io.AcidUtils.isFullAcidTable) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) HiveSessionProperties.getTemporaryStagingDirectoryPath(io.trino.plugin.hive.HiveSessionProperties.getTemporaryStagingDirectoryPath) EventClient(io.airlift.event.client.EventClient) DefaultCodec(org.apache.hadoop.io.compress.DefaultCodec) Set(java.util.Set) TrinoException(io.trino.spi.TrinoException) UUID(java.util.UUID) Math.min(java.lang.Math.min) HIVE_PATH_ALREADY_EXISTS(io.trino.plugin.hive.HiveErrorCode.HIVE_PATH_ALREADY_EXISTS) MetastoreUtil.getHiveSchema(io.trino.plugin.hive.metastore.MetastoreUtil.getHiveSchema) AcidUtils.deleteDeltaSubdir(org.apache.hadoop.hive.ql.io.AcidUtils.deleteDeltaSubdir) Sets(com.google.common.collect.Sets) String.format(java.lang.String.format) Collectors.joining(java.util.stream.Collectors.joining) ReflectionUtil(org.apache.hive.common.util.ReflectionUtil) DataSize(io.airlift.units.DataSize) HdfsContext(io.trino.plugin.hive.HdfsEnvironment.HdfsContext) List(java.util.List) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) Principal(java.security.Principal) AcidUtils.deltaSubdir(org.apache.hadoop.hive.ql.io.AcidUtils.deltaSubdir) HivePageSinkMetadataProvider(io.trino.plugin.hive.metastore.HivePageSinkMetadataProvider) Entry(java.util.Map.Entry) Function.identity(java.util.function.Function.identity) FileUtils(org.apache.hadoop.hive.common.FileUtils) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) Partition(io.trino.plugin.hive.metastore.Partition) Type(io.trino.spi.type.Type) ConfigurationUtils.toJobConf(io.trino.plugin.hive.util.ConfigurationUtils.toJobConf) Page(io.trino.spi.Page) HashMap(java.util.HashMap) HiveWriteUtils.createPartitionValues(io.trino.plugin.hive.util.HiveWriteUtils.createPartitionValues) IOConstants(org.apache.hadoop.hive.ql.io.IOConstants) StorageFormat.fromHiveStorageFormat(io.trino.plugin.hive.metastore.StorageFormat.fromHiveStorageFormat) OptionalInt(java.util.OptionalInt) HIVE_PARTITION_READ_ONLY(io.trino.plugin.hive.HiveErrorCode.HIVE_PARTITION_READ_ONLY) ArrayList(java.util.ArrayList) HiveSessionProperties.getCompressionCodec(io.trino.plugin.hive.HiveSessionProperties.getCompressionCodec) HashSet(java.util.HashSet) Strings(com.google.common.base.Strings) HIVE_INVALID_METADATA(io.trino.plugin.hive.HiveErrorCode.HIVE_INVALID_METADATA) ImmutableList(com.google.common.collect.ImmutableList) COMPRESSRESULT(org.apache.hadoop.hive.conf.HiveConf.ConfVars.COMPRESSRESULT) Objects.requireNonNull(java.util.Objects.requireNonNull) HiveWriteUtils(io.trino.plugin.hive.util.HiveWriteUtils) HiveSessionProperties.isTemporaryStagingDirectoryEnabled(io.trino.plugin.hive.HiveSessionProperties.isTemporaryStagingDirectoryEnabled) HIVE_WRITER_OPEN_ERROR(io.trino.plugin.hive.HiveErrorCode.HIVE_WRITER_OPEN_ERROR) HiveSessionProperties.getInsertExistingPartitionsBehavior(io.trino.plugin.hive.HiveSessionProperties.getInsertExistingPartitionsBehavior) HiveUtil.getColumnTypes(io.trino.plugin.hive.util.HiveUtil.getColumnTypes) Properties(java.util.Properties) HiveConf(org.apache.hadoop.hive.conf.HiveConf) HIVE_UNSUPPORTED_FORMAT(io.trino.plugin.hive.HiveErrorCode.HIVE_UNSUPPORTED_FORMAT) HiveSessionProperties.getTimestampPrecision(io.trino.plugin.hive.HiveSessionProperties.getTimestampPrecision) IOException(java.io.IOException) ConnectorSession(io.trino.spi.connector.ConnectorSession) SortOrder(io.trino.spi.connector.SortOrder) JobConf(org.apache.hadoop.mapred.JobConf) Consumer(java.util.function.Consumer) UUID.randomUUID(java.util.UUID.randomUUID) Collectors.toList(java.util.stream.Collectors.toList) FS_DEFAULT_NAME_KEY(org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY) SortingColumn(io.trino.plugin.hive.metastore.SortingColumn) HIVE_TABLE_READ_ONLY(io.trino.plugin.hive.HiveErrorCode.HIVE_TABLE_READ_ONLY) UpdateMode(io.trino.plugin.hive.PartitionUpdate.UpdateMode) WriteInfo(io.trino.plugin.hive.LocationService.WriteInfo) TypeManager(io.trino.spi.type.TypeManager) Configuration(org.apache.hadoop.conf.Configuration) HashMap(java.util.HashMap) UpdateMode(io.trino.plugin.hive.PartitionUpdate.UpdateMode) ArrayList(java.util.ArrayList) StorageFormat(io.trino.plugin.hive.metastore.StorageFormat) StorageFormat.fromHiveStorageFormat(io.trino.plugin.hive.metastore.StorageFormat.fromHiveStorageFormat) Properties(java.util.Properties) Column(io.trino.plugin.hive.metastore.Column) SortingColumn(io.trino.plugin.hive.metastore.SortingColumn) WriteInfo(io.trino.plugin.hive.LocationService.WriteInfo) FileSystem(org.apache.hadoop.fs.FileSystem) HdfsContext(io.trino.plugin.hive.HdfsEnvironment.HdfsContext) Path(org.apache.hadoop.fs.Path) HiveSessionProperties.getTemporaryStagingDirectoryPath(io.trino.plugin.hive.HiveSessionProperties.getTemporaryStagingDirectoryPath) Partition(io.trino.plugin.hive.metastore.Partition) SortingColumn(io.trino.plugin.hive.metastore.SortingColumn) Optional(java.util.Optional) SortOrder(io.trino.spi.connector.SortOrder) IOException(java.io.IOException) Type(io.trino.spi.type.Type) TrinoException(io.trino.spi.TrinoException) Principal(java.security.Principal)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)2 DataSize (io.airlift.units.DataSize)2 PageSorter (io.trino.spi.PageSorter)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Strings (com.google.common.base.Strings)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Maps.immutableEntry (com.google.common.collect.Maps.immutableEntry)1 Sets (com.google.common.collect.Sets)1 MoreExecutors.directExecutor (com.google.common.util.concurrent.MoreExecutors.directExecutor)1 Binder (com.google.inject.Binder)1 Provides (com.google.inject.Provides)1 Scopes (com.google.inject.Scopes)1 Multibinder.newSetBinder (com.google.inject.multibindings.Multibinder.newSetBinder)1 OptionalBinder.newOptionalBinder (com.google.inject.multibindings.OptionalBinder.newOptionalBinder)1 ProvidesIntoSet (com.google.inject.multibindings.ProvidesIntoSet)1 BoundedExecutor (io.airlift.concurrent.BoundedExecutor)1 Threads.daemonThreadsNamed (io.airlift.concurrent.Threads.daemonThreadsNamed)1