• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JsonCodec类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.airlift.json.JsonCodec的典型用法代码示例。如果您正苦于以下问题:Java JsonCodec类的具体用法?Java JsonCodec怎么用?Java JsonCodec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsonCodec类属于io.airlift.json包,在下文中一共展示了JsonCodec类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: loadTpchTableDescription

import io.airlift.json.JsonCodec; //导入依赖的package包/类
public static Map.Entry<SchemaTableName, RedisTableDescription> loadTpchTableDescription(
        JsonCodec<RedisTableDescription> tableDescriptionJsonCodec,
        SchemaTableName schemaTableName,
        String dataFormat)
        throws IOException
{
    RedisTableDescription tpchTemplate;
    try (InputStream data = RedisTestUtils.class.getResourceAsStream(format("/tpch/%s/%s.json", dataFormat, schemaTableName.getTableName()))) {
        tpchTemplate = tableDescriptionJsonCodec.fromJson(ByteStreams.toByteArray(data));
    }

    RedisTableDescription tableDescription = new RedisTableDescription(
            schemaTableName.getTableName(),
            schemaTableName.getSchemaName(),
            tpchTemplate.getKey(),
            tpchTemplate.getValue());

    return new AbstractMap.SimpleImmutableEntry<>(schemaTableName, tableDescription);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:RedisTestUtils.java


示例2: ClusterMemoryManager

import io.airlift.json.JsonCodec; //导入依赖的package包/类
@Inject
public ClusterMemoryManager(
        @ForMemoryManager HttpClient httpClient,
        NodeManager nodeManager,
        LocationFactory locationFactory,
        MBeanExporter exporter,
        JsonCodec<MemoryInfo> memoryInfoCodec,
        JsonCodec<MemoryPoolAssignmentsRequest> assignmentsRequestJsonCodec,
        QueryIdGenerator queryIdGenerator,
        ServerConfig serverConfig,
        MemoryManagerConfig config)
{
    requireNonNull(config, "config is null");
    this.nodeManager = requireNonNull(nodeManager, "nodeManager is null");
    this.locationFactory = requireNonNull(locationFactory, "locationFactory is null");
    this.httpClient = requireNonNull(httpClient, "httpClient is null");
    this.exporter = requireNonNull(exporter, "exporter is null");
    this.memoryInfoCodec = requireNonNull(memoryInfoCodec, "memoryInfoCodec is null");
    this.assignmentsRequestJsonCodec = requireNonNull(assignmentsRequestJsonCodec, "assignmentsRequestJsonCodec is null");
    this.maxQueryMemory = config.getMaxQueryMemory();
    this.coordinatorId = queryIdGenerator.getCoordinatorId();
    this.enabled = serverConfig.isCoordinator();
    this.killOnOutOfMemoryDelay = config.getKillOnOutOfMemoryDelay();
    this.killOnOutOfMemory = config.isKillOnOutOfMemory();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:ClusterMemoryManager.java


示例3: MetadataManager

import io.airlift.json.JsonCodec; //导入依赖的package包/类
@Inject
public MetadataManager(FeaturesConfig featuresConfig,
        TypeManager typeManager,
        JsonCodec<ViewDefinition> viewCodec,
        BlockEncodingSerde blockEncodingSerde,
        SessionPropertyManager sessionPropertyManager,
        TablePropertyManager tablePropertyManager,
        TransactionManager transactionManager)
{
    functions = new FunctionRegistry(typeManager, blockEncodingSerde, featuresConfig.isExperimentalSyntaxEnabled());
    procedures = new ProcedureRegistry();
    this.typeManager = requireNonNull(typeManager, "types is null");
    this.viewCodec = requireNonNull(viewCodec, "viewCodec is null");
    this.blockEncodingSerde = requireNonNull(blockEncodingSerde, "blockEncodingSerde is null");
    this.sessionPropertyManager = requireNonNull(sessionPropertyManager, "sessionPropertyManager is null");
    this.tablePropertyManager = requireNonNull(tablePropertyManager, "tablePropertyManager is null");
    this.transactionManager = requireNonNull(transactionManager, "transactionManager is null");

    verifyComparableOrderableContract();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:MetadataManager.java


示例4: getJsonCodecForType

import io.airlift.json.JsonCodec; //导入依赖的package包/类
private static <T> JsonCodec<T> getJsonCodecForType(Type type)
{
    if (VarcharType.VARCHAR.equals(type)) {
        return (JsonCodec<T>) JSON_CODEC_FACTORY.jsonCodec(String.class);
    }
    if (BooleanType.BOOLEAN.equals(type)) {
        return (JsonCodec<T>) JSON_CODEC_FACTORY.jsonCodec(Boolean.class);
    }
    if (BigintType.BIGINT.equals(type)) {
        return (JsonCodec<T>) JSON_CODEC_FACTORY.jsonCodec(Long.class);
    }
    if (DoubleType.DOUBLE.equals(type)) {
        return (JsonCodec<T>) JSON_CODEC_FACTORY.jsonCodec(Double.class);
    }
    if (type instanceof ArrayType) {
        Type elementType = ((ArrayType) type).getElementType();
        return (JsonCodec<T>) JSON_CODEC_FACTORY.listJsonCodec(getJsonCodecForType(elementType));
    }
    if (type instanceof MapType) {
        Type keyType = ((MapType) type).getKeyType();
        Type valueType = ((MapType) type).getValueType();
        return (JsonCodec<T>) JSON_CODEC_FACTORY.mapJsonCodec(getMapKeyType(keyType), getJsonCodecForType(valueType));
    }
    throw new PrestoException(INVALID_SESSION_PROPERTY, format("Session property type %s is not supported", type));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:SessionPropertyManager.java


示例5: ExecuteResource

import io.airlift.json.JsonCodec; //导入依赖的package包/类
@Inject
public ExecuteResource(
        HttpServerInfo serverInfo,
        AccessControl accessControl,
        SessionPropertyManager sessionPropertyManager,
        @ForExecute HttpClient httpClient,
        QueryIdGenerator queryIdGenerator,
        JsonCodec<QueryResults> queryResultsCodec)
{
    this.serverInfo = requireNonNull(serverInfo, "serverInfo is null");
    this.accessControl = requireNonNull(accessControl, "accessControl is null");
    this.sessionPropertyManager = requireNonNull(sessionPropertyManager, "sessionPropertyManager is null");
    this.httpClient = requireNonNull(httpClient, "httpClient is null");
    this.queryIdGenerator = requireNonNull(queryIdGenerator, "queryIdGenerator is null");
    this.queryResultsCodec = requireNonNull(queryResultsCodec, "queryResultsCodec is null");
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:ExecuteResource.java


示例6: HttpRemoteTaskFactory

import io.airlift.json.JsonCodec; //导入依赖的package包/类
@Inject
public HttpRemoteTaskFactory(QueryManagerConfig config,
        TaskManagerConfig taskConfig,
        @ForScheduler HttpClient httpClient,
        LocationFactory locationFactory,
        JsonCodec<TaskInfo> taskInfoCodec,
        JsonCodec<TaskUpdateRequest> taskUpdateRequestCodec)
{
    this.httpClient = httpClient;
    this.locationFactory = locationFactory;
    this.taskInfoCodec = taskInfoCodec;
    this.taskUpdateRequestCodec = taskUpdateRequestCodec;
    this.minErrorDuration = config.getRemoteTaskMinErrorDuration();
    this.taskInfoRefreshMaxWait = taskConfig.getInfoRefreshMaxWait();
    this.coreExecutor = newCachedThreadPool(daemonThreadsNamed("remote-task-callback-%s"));
    this.executor = new BoundedExecutor(coreExecutor, config.getRemoteTaskMaxCallbackThreads());
    this.executorMBean = new ThreadPoolExecutorMBean((ThreadPoolExecutor) coreExecutor);

    this.errorScheduledExecutor = newSingleThreadScheduledExecutor(daemonThreadsNamed("remote-task-error-delay-%s"));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:HttpRemoteTaskFactory.java


示例7: testSerialization

import io.airlift.json.JsonCodec; //导入依赖的package包/类
@Test
public void testSerialization()
        throws Exception
{
    String connectorId = "testid";
    SystemTableHandle tableHandle = new SystemTableHandle(connectorId, "xyz", "foo");
    SystemSplit expected = new SystemSplit(connectorId, tableHandle, HostAddress.fromParts("127.0.0.1", 0), TupleDomain.all());

    JsonCodec<SystemSplit> codec = jsonCodec(SystemSplit.class);
    SystemSplit actual = codec.fromJson(codec.toJson(expected));

    assertEquals(actual.getConnectorId(), expected.getConnectorId());
    assertEquals(actual.getTableHandle(), expected.getTableHandle());
    assertEquals(actual.getAddresses(), expected.getAddresses());
    assertEquals(actual.getConstraint(), expected.getConstraint());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:TestSystemSplit.java


示例8: testRoundTrip

import io.airlift.json.JsonCodec; //导入依赖的package包/类
@Test
public void testRoundTrip()
{
    ObjectMapperProvider objectMapperProvider = new ObjectMapperProvider();
    objectMapperProvider.setJsonDeserializers(ImmutableMap.<Class<?>, JsonDeserializer<?>>of(Type.class, new TypeDeserializer(new TypeRegistry())));
    JsonCodec<Signature> codec = new JsonCodecFactory(objectMapperProvider, true).jsonCodec(Signature.class);

    Signature expected = new Signature("function", SCALAR, StandardTypes.BIGINT, ImmutableList.of(StandardTypes.BOOLEAN, StandardTypes.DOUBLE, StandardTypes.VARCHAR));

    String json = codec.toJson(expected);
    Signature actual = codec.fromJson(json);

    assertEquals(actual.getName(), expected.getName());
    assertEquals(actual.getKind(), expected.getKind());
    assertEquals(actual.getReturnType(), expected.getReturnType());
    assertEquals(actual.getArgumentTypes(), expected.getArgumentTypes());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:TestSignature.java


示例9: CassandraSession

import io.airlift.json.JsonCodec; //导入依赖的package包/类
public CassandraSession(String connectorId,
        final Builder clusterBuilder,
        int fetchSizeForPartitionKeySelect,
        int limitForPartitionKeySelect,
        JsonCodec<List<ExtraColumnMetadata>> extraColumnMetadataCodec)
{
    this.connectorId = connectorId;
    this.fetchSizeForPartitionKeySelect = fetchSizeForPartitionKeySelect;
    this.limitForPartitionKeySelect = limitForPartitionKeySelect;
    this.extraColumnMetadataCodec = extraColumnMetadataCodec;

    sessionBySchema = CacheBuilder.newBuilder()
            .build(new CacheLoader<String, Session>()
            {
                @Override
                public Session load(String key)
                        throws Exception
                {
                    return clusterBuilder.build().connect();
                }
            });
}
 
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:CassandraSession.java


示例10: QueryRunner

import io.airlift.json.JsonCodec; //导入依赖的package包/类
public QueryRunner(
        ClientSession session,
        JsonCodec<QueryResults> queryResultsCodec,
        Optional<HostAndPort> socksProxy,
        Optional<String> keystorePath,
        Optional<String> keystorePassword,
        Optional<String> kerberosPrincipal,
        Optional<String> kerberosRemoteServiceName,
        boolean authenticationEnabled,
        KerberosConfig kerberosConfig)
{
    this.session = new AtomicReference<>(requireNonNull(session, "session is null"));
    this.queryResultsCodec = requireNonNull(queryResultsCodec, "queryResultsCodec is null");
    this.httpClient = new JettyHttpClient(
            getHttpClientConfig(socksProxy, keystorePath, keystorePassword, kerberosPrincipal, kerberosRemoteServiceName, authenticationEnabled),
            kerberosConfig,
            Optional.<JettyIoPool>empty(),
            ImmutableList.<HttpRequestFilter>of());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:QueryRunner.java


示例11: StatementClient

import io.airlift.json.JsonCodec; //导入依赖的package包/类
public StatementClient(HttpClient httpClient, JsonCodec<QueryResults> queryResultsCodec, ClientSession session, String query)
{
    requireNonNull(httpClient, "httpClient is null");
    requireNonNull(queryResultsCodec, "queryResultsCodec is null");
    requireNonNull(session, "session is null");
    requireNonNull(query, "query is null");

    this.httpClient = httpClient;
    this.responseHandler = createFullJsonResponseHandler(queryResultsCodec);
    this.debug = session.isDebug();
    this.timeZoneId = session.getTimeZoneId();
    this.query = query;
    this.requestTimeoutNanos = session.getClientRequestTimeout().roundTo(NANOSECONDS);

    Request request = buildQueryRequest(session, query);
    JsonResponse<QueryResults> response = httpClient.execute(request, responseHandler);

    if (response.getStatusCode() != HttpStatus.OK.code() || !response.hasValue()) {
        throw requestFailedException("starting query", request, response);
    }

    processResponse(response);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:StatementClient.java


示例12: HivePageSinkProvider

import io.airlift.json.JsonCodec; //导入依赖的package包/类
@Inject
public HivePageSinkProvider(
        HdfsEnvironment hdfsEnvironment,
        HiveMetastore metastore,
        PageIndexerFactory pageIndexerFactory,
        TypeManager typeManager,
        HiveClientConfig config,
        LocationService locationService,
        JsonCodec<PartitionUpdate> partitionUpdateCodec)
{
    this.hdfsEnvironment = requireNonNull(hdfsEnvironment, "hdfsEnvironment is null");
    this.metastore = requireNonNull(metastore, "metastore is null");
    this.pageIndexerFactory = requireNonNull(pageIndexerFactory, "pageIndexerFactory is null");
    this.typeManager = requireNonNull(typeManager, "typeManager is null");
    this.respectTableFormat = config.isRespectTableFormat();
    this.maxOpenPartitions = config.getMaxPartitionsPerWriter();
    this.immutablePartitions = config.isImmutablePartitions();
    this.locationService = requireNonNull(locationService, "locationService is null");
    this.partitionUpdateCodec = requireNonNull(partitionUpdateCodec, "partitionUpdateCodec is null");
}
 
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:HivePageSinkProvider.java


示例13: DynamicAnnouncementFilter

import io.airlift.json.JsonCodec; //导入依赖的package包/类
@Inject
DynamicAnnouncementFilter(
        JsonCodec<JsonAnnouncement> announcementCodec,
        @ForDynamicAnnouncements
                Map<String, Map<String, Supplier<String>>> propertiesMap)
{
    codec = announcementCodec;

    // Re-collect into immutable nested maps
    ImmutableMap.Builder<String, Map<String, Supplier<String>>> builder =
            ImmutableMap.builder();

    for (Entry<String, Map<String, Supplier<String>>> service
            : propertiesMap.entrySet()) {
        ImmutableMap<String, Supplier<String>> properties = service.getValue()
                .entrySet().stream()
                .collect(toImmutableMap(
                        Entry::getKey,
                        Entry::getValue,
                        (v1, v2) -> {
                            throw new IllegalArgumentException(
                                    "Service has two dynamic properties with the same name");
                        }));
        builder.put(service.getKey(), properties);
    }
    this.propertiesSuppliers = builder.build();
}
 
开发者ID:prestodb,项目名称:presto-manager,代码行数:28,代码来源:DynamicAnnouncementFilter.java


示例14: assertJsonRoundTrip

import io.airlift.json.JsonCodec; //导入依赖的package包/类
private void assertJsonRoundTrip(DataSize dataSize)
        throws IOException
{
    JsonCodec<DataSize> dataSizeCodec = JsonCodec.jsonCodec(DataSize.class);
    String json = dataSizeCodec.toJson(dataSize);
    DataSize dataSizeCopy = dataSizeCodec.fromJson(json);
    double delta = dataSize.toBytes() * 0.01;
    Assert.assertEquals(dataSize.toBytes(), dataSizeCopy.toBytes(), delta);
}
 
开发者ID:airlift,项目名称:units,代码行数:10,代码来源:TestDataSize.java


示例15: assertJsonRoundTrip

import io.airlift.json.JsonCodec; //导入依赖的package包/类
private void assertJsonRoundTrip(Duration duration)
        throws IOException
{
    JsonCodec<Duration> durationCodec = JsonCodec.jsonCodec(Duration.class);
    String json = durationCodec.toJson(duration);
    Duration durationCopy = durationCodec.fromJson(json);
    double delta = duration.getValue(MILLISECONDS) * 0.01;
    assertEquals(duration.getValue(MILLISECONDS), durationCopy.getValue(MILLISECONDS), delta);
}
 
开发者ID:airlift,项目名称:units,代码行数:10,代码来源:TestDuration.java


示例16: KafkaTableDescriptionSupplier

import io.airlift.json.JsonCodec; //导入依赖的package包/类
@Inject
KafkaTableDescriptionSupplier(KafkaConnectorConfig kafkaConnectorConfig,
        JsonCodec<KafkaTopicDescription> topicDescriptionCodec)
{
    this.topicDescriptionCodec = requireNonNull(topicDescriptionCodec, "topicDescriptionCodec is null");

    requireNonNull(kafkaConnectorConfig, "kafkaConfig is null");
    this.tableDescriptionDir = kafkaConnectorConfig.getTableDescriptionDir();
    this.defaultSchema = kafkaConnectorConfig.getDefaultSchema();
    this.tableNames = ImmutableSet.copyOf(kafkaConnectorConfig.getTableNames());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:12,代码来源:KafkaTableDescriptionSupplier.java


示例17: createTpchTopicDescriptions

import io.airlift.json.JsonCodec; //导入依赖的package包/类
private static Map<SchemaTableName, KafkaTopicDescription> createTpchTopicDescriptions(Metadata metadata, Iterable<TpchTable<?>> tables)
        throws Exception
{
    JsonCodec<KafkaTopicDescription> topicDescriptionJsonCodec = new CodecSupplier<>(KafkaTopicDescription.class, metadata).get();

    ImmutableMap.Builder<SchemaTableName, KafkaTopicDescription> topicDescriptions = ImmutableMap.builder();
    for (TpchTable<?> table : tables) {
        String tableName = table.getTableName();
        SchemaTableName tpchTable = new SchemaTableName(TPCH_SCHEMA, tableName);

        topicDescriptions.put(loadTpchTopicDescription(topicDescriptionJsonCodec, tpchTable.toString(), tpchTable));
    }
    return topicDescriptions.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:15,代码来源:KafkaQueryRunner.java


示例18: loadTpchTopicDescription

import io.airlift.json.JsonCodec; //导入依赖的package包/类
public static Map.Entry<SchemaTableName, KafkaTopicDescription> loadTpchTopicDescription(JsonCodec<KafkaTopicDescription> topicDescriptionJsonCodec, String topicName, SchemaTableName schemaTableName)
        throws IOException
{
    KafkaTopicDescription tpchTemplate = topicDescriptionJsonCodec.fromJson(ByteStreams.toByteArray(TestUtils.class.getResourceAsStream(format("/tpch/%s.json", schemaTableName.getTableName()))));

    return new AbstractMap.SimpleImmutableEntry<>(
            schemaTableName,
            new KafkaTopicDescription(schemaTableName.getTableName(), schemaTableName.getSchemaName(), topicName, tpchTemplate.getKey(), tpchTemplate.getMessage()));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:TestUtils.java


示例19: ExampleClient

import io.airlift.json.JsonCodec; //导入依赖的package包/类
@Inject
public ExampleClient(ExampleConfig config, JsonCodec<Map<String, List<ExampleTable>>> catalogCodec)
        throws IOException
{
    requireNonNull(config, "config is null");
    requireNonNull(catalogCodec, "catalogCodec is null");

    schemas = Suppliers.memoize(schemasSupplier(catalogCodec, config.getMetadata()));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:ExampleClient.java


示例20: schemasSupplier

import io.airlift.json.JsonCodec; //导入依赖的package包/类
private static Supplier<Map<String, Map<String, ExampleTable>>> schemasSupplier(final JsonCodec<Map<String, List<ExampleTable>>> catalogCodec, final URI metadataUri)
{
    return () -> {
        try {
            return lookupSchemas(metadataUri, catalogCodec);
        }
        catch (IOException e) {
            throw Throwables.propagate(e);
        }
    };
}
 
开发者ID:y-lan,项目名称:presto,代码行数:12,代码来源:ExampleClient.java



注:本文中的io.airlift.json.JsonCodec类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CountRequest类代码示例发布时间:2022-05-23
下一篇:
Java Process类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap