当前位置: 首页>>代码示例>>Java>>正文


Java Input类代码示例

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


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

示例1: deserializeRequest

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Override
public RequestMessage deserializeRequest(final ByteBuf msg) throws SerializationException {
    try {
        final Kryo kryo = kryoThreadLocal.get();
        final byte[] payload = new byte[msg.readableBytes()];
        msg.readBytes(payload);
        try (final Input input = new Input(payload)) {
            // by the time the message gets here, the mime length/type have been already read, so this part just
            // needs to process the payload.
            final UUID id = kryo.readObject(input, UUID.class);
            final String processor = input.readString();
            final String op = input.readString();

            final RequestMessage.Builder builder = RequestMessage.build(op)
                    .overrideRequestId(id)
                    .processor(processor);

            final Map<String, Object> args = kryo.readObject(input, HashMap.class);
            args.forEach(builder::addArg);
            return builder.create();
        }
    } catch (Exception ex) {
        logger.warn("Request [{}] could not be deserialized by {}.", msg, GryoMessageSerializerV1d0.class.getName());
        throw new SerializationException(ex);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:AbstractGryoMessageSerializerV1d0.java

示例2: readClass

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Override
public Registration readClass(final Input input) {
    final int classID = input.readVarInt(true);
    switch (classID) {
        case Kryo.NULL:
            return null;
        case NAME + 2: // Offset for NAME and NULL.
            return readName(input);
    }

    if (classID == memoizedClassId) return memoizedClassIdValue;
    final Registration registration = idToRegistration.get(classID - 2);
    if (registration == null) throw new KryoException("Encountered unregistered class ID: " + (classID - 2));
    memoizedClassId = classID;
    memoizedClassIdValue = registration;
    return registration;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:GryoClassResolver.java

示例3: readName

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
protected Registration readName(final Input input) {
    final int nameId = input.readVarInt(true);
    if (nameIdToClass == null) nameIdToClass = new IntMap<>();
    Class type = nameIdToClass.get(nameId);
    if (type == null) {
        // Only read the class name the first time encountered in object graph.
        final String className = input.readString();
        type = getTypeByName(className);
        if (type == null) {
            try {
                type = Class.forName(className, false, kryo.getClassLoader());
            } catch (ClassNotFoundException ex) {
                throw new KryoException("Unable to find class: " + className, ex);
            }
            if (nameToClass == null) nameToClass = new ObjectMap<>();
            nameToClass.put(className, type);
        }
        nameIdToClass.put(nameId, type);
    }
    return kryo.getRegistration(type);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:22,代码来源:GryoClassResolver.java

示例4: shouldSerializeDeserialize

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Test
public void shouldSerializeDeserialize() throws Exception {
    final GryoMapper mapper = GryoMapper.build().create();
    final Kryo kryo = mapper.createMapper();
    try (final OutputStream stream = new ByteArrayOutputStream()) {
        final Output out = new Output(stream);

        final Map<String,Object> props = new HashMap<>();
        final List<Map<String, Object>> propertyNames = new ArrayList<>(1);
        final Map<String,Object> propertyName = new HashMap<>();
        propertyName.put(GraphSONTokens.ID, "x");
        propertyName.put(GraphSONTokens.KEY, "x");
        propertyName.put(GraphSONTokens.VALUE, "no-way-this-will-ever-work");
        propertyNames.add(propertyName);
        props.put("x", propertyNames);
        final DetachedVertex v = new DetachedVertex(100, Vertex.DEFAULT_LABEL, props);

        kryo.writeClassAndObject(out, v);

        try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
            final Input input = new Input(inputStream);
            final DetachedVertex readX = (DetachedVertex) kryo.readClassAndObject(input);
            assertEquals("no-way-this-will-ever-work", readX.value("x"));
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:GryoMapperTest.java

示例5: shouldSerializeWithCustomClassResolverToDetachedVertex

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Test
public void shouldSerializeWithCustomClassResolverToDetachedVertex() throws Exception {
    final Supplier<ClassResolver> classResolver = new CustomClassResolverSupplier();
    final GryoMapper mapper = GryoMapper.build().classResolver(classResolver).create();
    final Kryo kryo = mapper.createMapper();
    try (final OutputStream stream = new ByteArrayOutputStream()) {
        final Output out = new Output(stream);
        final IoX x = new IoX("no-way-this-will-ever-work");

        kryo.writeClassAndObject(out, x);

        final GryoMapper mapperWithoutKnowledgeOfIox = GryoMapper.build().create();
        final Kryo kryoWithoutKnowledgeOfIox = mapperWithoutKnowledgeOfIox.createMapper();
        try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
            final Input input = new Input(inputStream);
            final DetachedVertex readX = (DetachedVertex) kryoWithoutKnowledgeOfIox.readClassAndObject(input);
            assertEquals("no-way-this-will-ever-work", readX.value("x"));
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:GryoMapperTest.java

示例6: shouldSerializeWithCustomClassResolverToHashMap

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Test
public void shouldSerializeWithCustomClassResolverToHashMap() throws Exception {
    final Supplier<ClassResolver> classResolver = new CustomClassResolverSupplier();
    final GryoMapper mapper = GryoMapper.build().classResolver(classResolver).create();
    final Kryo kryo = mapper.createMapper();
    try (final OutputStream stream = new ByteArrayOutputStream()) {
        final Output out = new Output(stream);
        final IoY y = new IoY(100, 200);

        kryo.writeClassAndObject(out, y);

        final GryoMapper mapperWithoutKnowledgeOfIoy = GryoMapper.build().create();
        final Kryo kryoWithoutKnowledgeOfIox = mapperWithoutKnowledgeOfIoy.createMapper();
        try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
            final Input input = new Input(inputStream);
            final Map readY = (HashMap) kryoWithoutKnowledgeOfIox.readClassAndObject(input);
            assertEquals("100-200", readY.get("y"));
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:GryoMapperTest.java

示例7: shouldSerializeWithoutRegistration

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Test
public void shouldSerializeWithoutRegistration() throws Exception {
    final GryoMapper mapper = GryoMapper.build().registrationRequired(false).create();
    final Kryo kryo = mapper.createMapper();
    try (final OutputStream stream = new ByteArrayOutputStream()) {
        final Output out = new Output(stream);
        final IoX x = new IoX("x");
        final IoY y = new IoY(100, 200);
        kryo.writeClassAndObject(out, x);
        kryo.writeClassAndObject(out, y);

        try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
            final Input input = new Input(inputStream);
            final IoX readX = (IoX) kryo.readClassAndObject(input);
            final IoY readY = (IoY) kryo.readClassAndObject(input);
            assertEquals(x, readX);
            assertEquals(y, readY);
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:GryoMapperTest.java

示例8: shouldRegisterMultipleIoRegistryToSerialize

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Test
public void shouldRegisterMultipleIoRegistryToSerialize() throws Exception {
    final GryoMapper mapper = GryoMapper.build()
            .addRegistry(IoXIoRegistry.InstanceBased.getInstance())
            .addRegistry(IoYIoRegistry.InstanceBased.getInstance()).create();
    final Kryo kryo = mapper.createMapper();
    try (final OutputStream stream = new ByteArrayOutputStream()) {
        final Output out = new Output(stream);
        final IoX x = new IoX("x");
        final IoY y = new IoY(100, 200);
        kryo.writeClassAndObject(out, x);
        kryo.writeClassAndObject(out, y);

        try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
            final Input input = new Input(inputStream);
            final IoX readX = (IoX) kryo.readClassAndObject(input);
            final IoY readY = (IoY) kryo.readClassAndObject(input);
            assertEquals(x, readX);
            assertEquals(y, readY);
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:GryoMapperTest.java

示例9: deserializeRequest

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Override
public RequestMessage deserializeRequest(final ByteBuf msg) throws SerializationException {
    try {
        final Kryo kryo = kryoThreadLocal.get();
        final byte[] payload = new byte[msg.readableBytes()];
        msg.readBytes(payload);
        try (final Input input = new Input(payload)) {
            // by the time the message gets here, the mime length/type have been already read, so this part just
            // needs to process the payload.
            return kryo.readObject(input, RequestMessage.class);
        }
    } catch (Exception ex) {
        logger.warn("Request [{}] could not be deserialized by {}.", msg, GryoMessageSerializerV3d0.class.getName());
        throw new SerializationException(ex);
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:17,代码来源:AbstractGryoMessageSerializerV3d0.java

示例10: shouldSerializeDeserialize

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Test
public void shouldSerializeDeserialize() throws Exception {
    final GryoMapper mapper = builder.get().create();
    final Kryo kryo = mapper.createMapper();
    try (final OutputStream stream = new ByteArrayOutputStream()) {
        final Output out = new Output(stream);

        final Map<String,Object> props = new HashMap<>();
        final List<Map<String, Object>> propertyNames = new ArrayList<>(1);
        final Map<String,Object> propertyName = new HashMap<>();
        propertyName.put(GraphSONTokens.ID, "x");
        propertyName.put(GraphSONTokens.KEY, "x");
        propertyName.put(GraphSONTokens.VALUE, "no-way-this-will-ever-work");
        propertyNames.add(propertyName);
        props.put("x", propertyNames);
        final DetachedVertex v = new DetachedVertex(100, Vertex.DEFAULT_LABEL, props);

        kryo.writeClassAndObject(out, v);

        try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
            final Input input = new Input(inputStream);
            final DetachedVertex readX = (DetachedVertex) kryo.readClassAndObject(input);
            assertEquals("no-way-this-will-ever-work", readX.value("x"));
        }
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:27,代码来源:GryoMapperTest.java

示例11: shouldSerializeWithCustomClassResolverToDetachedVertex

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Test
public void shouldSerializeWithCustomClassResolverToDetachedVertex() throws Exception {
    final Supplier<ClassResolver> classResolver = new CustomClassResolverSupplier();
    final GryoMapper mapper = builder.get().classResolver(classResolver).create();
    final Kryo kryo = mapper.createMapper();
    try (final OutputStream stream = new ByteArrayOutputStream()) {
        final Output out = new Output(stream);
        final IoX x = new IoX("no-way-this-will-ever-work");

        kryo.writeClassAndObject(out, x);

        final GryoMapper mapperWithoutKnowledgeOfIox = builder.get().create();
        final Kryo kryoWithoutKnowledgeOfIox = mapperWithoutKnowledgeOfIox.createMapper();
        try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
            final Input input = new Input(inputStream);
            final DetachedVertex readX = (DetachedVertex) kryoWithoutKnowledgeOfIox.readClassAndObject(input);
            assertEquals("no-way-this-will-ever-work", readX.value("x"));
        }
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:21,代码来源:GryoMapperTest.java

示例12: shouldSerializeWithCustomClassResolverToHashMap

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Test
public void shouldSerializeWithCustomClassResolverToHashMap() throws Exception {
    final Supplier<ClassResolver> classResolver = new CustomClassResolverSupplier();
    final GryoMapper mapper = builder.get().classResolver(classResolver).create();
    final Kryo kryo = mapper.createMapper();
    try (final OutputStream stream = new ByteArrayOutputStream()) {
        final Output out = new Output(stream);
        final IoY y = new IoY(100, 200);

        kryo.writeClassAndObject(out, y);

        final GryoMapper mapperWithoutKnowledgeOfIoy = builder.get().create();
        final Kryo kryoWithoutKnowledgeOfIox = mapperWithoutKnowledgeOfIoy.createMapper();
        try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
            final Input input = new Input(inputStream);
            final Map readY = (HashMap) kryoWithoutKnowledgeOfIox.readClassAndObject(input);
            assertEquals("100-200", readY.get("y"));
        }
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:21,代码来源:GryoMapperTest.java

示例13: shouldSerializeWithoutRegistration

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Test
public void shouldSerializeWithoutRegistration() throws Exception {
    final GryoMapper mapper = builder.get().registrationRequired(false).create();
    final Kryo kryo = mapper.createMapper();
    try (final OutputStream stream = new ByteArrayOutputStream()) {
        final Output out = new Output(stream);
        final IoX x = new IoX("x");
        final IoY y = new IoY(100, 200);
        kryo.writeClassAndObject(out, x);
        kryo.writeClassAndObject(out, y);

        try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
            final Input input = new Input(inputStream);
            final IoX readX = (IoX) kryo.readClassAndObject(input);
            final IoY readY = (IoY) kryo.readClassAndObject(input);
            assertEquals(x, readX);
            assertEquals(y, readY);
        }
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:21,代码来源:GryoMapperTest.java

示例14: shouldRegisterMultipleIoRegistryToSerialize

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Test
public void shouldRegisterMultipleIoRegistryToSerialize() throws Exception {
    final GryoMapper mapper = builder.get().addRegistry(IoXIoRegistry.InstanceBased.instance())
            .addRegistry(IoYIoRegistry.InstanceBased.instance()).create();
    final Kryo kryo = mapper.createMapper();
    try (final OutputStream stream = new ByteArrayOutputStream()) {
        final Output out = new Output(stream);
        final IoX x = new IoX("x");
        final IoY y = new IoY(100, 200);
        kryo.writeClassAndObject(out, x);
        kryo.writeClassAndObject(out, y);

        try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
            final Input input = new Input(inputStream);
            final IoX readX = (IoX) kryo.readClassAndObject(input);
            final IoY readY = (IoY) kryo.readClassAndObject(input);
            assertEquals(x, readX);
            assertEquals(y, readY);
        }
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:22,代码来源:GryoMapperTest.java

示例15: read

import org.apache.tinkerpop.shaded.kryo.io.Input; //导入依赖的package包/类
@Override
public TinkerGraph read(final Kryo kryo, final Input input, final Class<TinkerGraph> tinkerGraphClass) {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
    final TinkerGraph graph = TinkerGraph.open(conf);
    final int len = input.readInt();
    final byte[] bytes = input.readBytes(len);
    try (final ByteArrayInputStream stream = new ByteArrayInputStream(bytes)) {
        GryoReader.build().mapper(() -> kryo).create().readGraph(stream, graph);
    } catch (Exception io) {
        throw new RuntimeException(io);
    }

    return graph;
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:16,代码来源:TinkerIoRegistryV1d0.java


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