use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class DeltaConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context) {
requireNonNull(requiredConfig, "requiredConfig is null");
try {
Bootstrap app = new Bootstrap(new JsonModule(), new DeltaModule(catalogName, context.getTypeManager()), new HiveS3Module(catalogName), new HiveGcsModule(), new HiveAuthenticationModule(), new HiveMetastoreModule(catalogName, Optional.empty()), binder -> {
binder.bind(RowExpressionService.class).toInstance(context.getRowExpressionService());
});
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(requiredConfig).initialize();
return injector.getInstance(DeltaConnector.class);
} catch (Exception exception) {
throwIfUnchecked(exception);
throw new RuntimeException(exception);
}
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class TestDeltaTableHandle method getJsonCodec.
private JsonCodec<DeltaTableHandle> getJsonCodec() {
Module module = binder -> {
binder.install(new JsonModule());
binder.install(new HandleJsonModule());
configBinder(binder).bindConfig(FeaturesConfig.class);
FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
binder.bind(TypeManager.class).toInstance(functionAndTypeManager);
jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
newSetBinder(binder, Type.class);
binder.bind(BlockEncodingSerde.class).to(BlockEncodingManager.class).in(Scopes.SINGLETON);
newSetBinder(binder, BlockEncoding.class);
jsonBinder(binder).addSerializerBinding(Block.class).to(BlockJsonSerde.Serializer.class);
jsonBinder(binder).addDeserializerBinding(Block.class).to(BlockJsonSerde.Deserializer.class);
jsonCodecBinder(binder).bindJsonCodec(DeltaTableHandle.class);
jsonCodecBinder(binder).bindJsonCodec(DeltaTable.class);
jsonCodecBinder(binder).bindJsonCodec(DeltaColumnHandle.class);
};
Bootstrap app = new Bootstrap(ImmutableList.of(module));
Injector injector = app.doNotInitializeLogging().quiet().initialize();
HandleResolver handleResolver = injector.getInstance(HandleResolver.class);
handleResolver.addConnectorName("delta", new DeltaConnectionHandleResolver());
return injector.getInstance(new Key<JsonCodec<DeltaTableHandle>>() {
});
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class TestInformationSchemaTableHandle method startUp.
@BeforeMethod
public void startUp() {
Injector injector = Guice.createInjector(new JsonModule(), new HandleJsonModule());
objectMapper = injector.getInstance(ObjectMapper.class);
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class TestStatisticsWriterNode method getJsonCodec.
private JsonCodec<StatisticsWriterNode> getJsonCodec() throws Exception {
Module module = binder -> {
SqlParser sqlParser = new SqlParser();
FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
binder.install(new JsonModule());
binder.install(new HandleJsonModule());
binder.bind(SqlParser.class).toInstance(sqlParser);
binder.bind(TypeManager.class).toInstance(functionAndTypeManager);
newSetBinder(binder, Type.class);
jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
jsonCodecBinder(binder).bindJsonCodec(StatisticsWriterNode.class);
};
Bootstrap app = new Bootstrap(ImmutableList.of(module));
Injector injector = app.doNotInitializeLogging().quiet().initialize();
HandleResolver handleResolver = injector.getInstance(HandleResolver.class);
handleResolver.addConnectorName("test", new TestingHandleResolver());
return injector.getInstance(new Key<JsonCodec<StatisticsWriterNode>>() {
});
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class PrometheusConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
requireNonNull(config, "requiredConfig is null");
try {
// A plugin is not required to use Guice; it is just very convenient
Bootstrap app = new Bootstrap(new JsonModule(), new PrometheusModule(context.getTypeManager()));
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(PrometheusConnector.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
Aggregations