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


Java ByteBufferInput类代码示例

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


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

示例1: deserialize

import com.esotericsoftware.kryo.io.ByteBufferInput; //导入依赖的package包/类
@Override
public Measurement deserialize(String topic, byte[] bytes) {
	// System.out.println("topic" + topic);
	// System.out.println("bytes" + bytes);
	// System.out.println("bytes" + bytes.length);
	// System.out.println("bytse: " + Arrays.toString(bytes));
	// System.out.println("kryos: " + kryos.get());

	// if ((topic.equals("proteus-realtime") ||
	// (topic.equals("proteus-flatness")) && bytes.length > 40)) {
	// System.out.println("Escape");
	// return null;
	// }

	if (topic.equals(ProteusData.get("kafka.topicName")) && bytes.length < 40) {
		return kryos.get().readObject(new ByteBufferInput(bytes), SensorMeasurement.class);
	} else if (topic.equals(ProteusData.get("kafka.flatnessTopicName")) && bytes.length < 40) {
		return kryos.get().readObject(new ByteBufferInput(bytes), SensorMeasurement.class);
	} else if (topic.equals(ProteusData.get("kafka.hsmTopicName"))) {
		return kryos.get().readObject(new ByteBufferInput(bytes), HSMMeasurement.class);
	} else {
		throw new IllegalArgumentException("Illegal argument: " + topic);
	}
}
 
开发者ID:proteus-h2020,项目名称:proteus-consumer-couchbase,代码行数:25,代码来源:ProteusSerializer.java

示例2: deserialize

import com.esotericsoftware.kryo.io.ByteBufferInput; //导入依赖的package包/类
/**
 * Deserializes given byte buffer to Object using Kryo instance in pool.
 *
 * @param buffer input with serialized bytes
 * @param <T> deserialized Object type
 * @return deserialized Object
 */
public <T> T deserialize(final ByteBuffer buffer) {
    ByteBufferInput in = new ByteBufferInput(buffer);
    Kryo kryo = borrow();
    try {
        @SuppressWarnings("unchecked")
        T obj = (T) kryo.readClassAndObject(in);
        return obj;
    } finally {
        release(kryo);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:KryoNamespace.java

示例3: deserialize

import com.esotericsoftware.kryo.io.ByteBufferInput; //导入依赖的package包/类
@Override
public SensorReading deserialize(String s, byte[] bytes) {
    try {
        return kryos.get().readObject(new ByteBufferInput(bytes), SensorReading.class);
    }
    catch(Exception e) {
        throw new IllegalArgumentException("Error reading bytes",e);
    }
}
 
开发者ID:nielsutrecht,项目名称:kafka-serializer-example,代码行数:10,代码来源:KryoReadingSerializer.java

示例4: getStringFromBytes

import com.esotericsoftware.kryo.io.ByteBufferInput; //导入依赖的package包/类
public static String getStringFromBytes(final byte [] bytes){

        Kryo kryo = KryoPool.getInstance().getKryo();
        ByteBufferInput in = new ByteBufferInput(bytes.length+5);
        in.setBuffer(bytes);
        String str = kryo.readObject(in,String.class);
        in.close();
        KryoPool.getInstance().returnToPool(kryo);
        return str;
    }
 
开发者ID:sumanthn,项目名称:hashaggregator,代码行数:11,代码来源:GenericGroupByKey.java

示例5: KryoSerialization

import com.esotericsoftware.kryo.io.ByteBufferInput; //导入依赖的package包/类
public KryoSerialization (Kryo kryo) {
	this.kryo = kryo;

	kryo.register(RegisterTCP.class);
	kryo.register(RegisterUDP.class);
	kryo.register(KeepAlive.class);
	kryo.register(DiscoverHost.class);
	kryo.register(Ping.class);

	input = new ByteBufferInput();
	output = new ByteBufferOutput();
}
 
开发者ID:abejfehr,项目名称:magic-realm,代码行数:13,代码来源:KryoSerialization.java

示例6: deserialize

import com.esotericsoftware.kryo.io.ByteBufferInput; //导入依赖的package包/类
/**
 * Deserializes given byte buffer to Object using Kryo instance in pool.
 *
 * @param buffer input with serialized bytes
 * @param <T>    deserialized Object type
 * @return deserialized Object
 */
public <T> T deserialize(final ByteBuffer buffer) {
  ByteBufferInput in = new ByteBufferInput(buffer);
  Kryo kryo = borrow();
  try {
    @SuppressWarnings("unchecked")
    T obj = (T) kryo.readClassAndObject(in);
    return obj;
  } finally {
    release(kryo);
  }
}
 
开发者ID:atomix,项目名称:atomix,代码行数:19,代码来源:KryoNamespace.java

示例7: KryoSerialization

import com.esotericsoftware.kryo.io.ByteBufferInput; //导入依赖的package包/类
public KryoSerialization(Kryo kryo) {
	this.kryo = kryo;

	kryo.register(RegisterTCP.class);
	kryo.register(RegisterUDP.class);
	kryo.register(KeepAlive.class);
	kryo.register(DiscoverHost.class);
	kryo.register(Ping.class);

	input = new ByteBufferInput();
	output = new ByteBufferOutput();
}
 
开发者ID:MosaicOwl,项目名称:the-erder,代码行数:13,代码来源:KryoSerialization.java

示例8: main

import com.esotericsoftware.kryo.io.ByteBufferInput; //导入依赖的package包/类
public static void main(String [] args){
    String str = "India,Search,Asia";

    System.out.println("string is " + str.getBytes());
    Kryo kryo =KryoPool.getInstance().getKryo();
    ByteBufferOutput bufferOutput = new ByteBufferOutput(20);
    kryo.writeObject(bufferOutput, str);

    byte[] msgBytes = bufferOutput.toBytes();


    System.out.println(msgBytes.length);

    ByteBufferInput input = new ByteBufferInput(msgBytes.length);
    input.setBuffer(msgBytes);
    String str2 =  kryo.readObject(input,String.class);
    System.out.println(str2);
    KryoPool.getInstance().returnToPool(kryo);


}
 
开发者ID:sumanthn,项目名称:hashaggregator,代码行数:22,代码来源:GenericGroupByKeyTest.java

示例9: load

import com.esotericsoftware.kryo.io.ByteBufferInput; //导入依赖的package包/类
public static <T> T load (Class<T> type) {
	Input input = new ByteBufferInput(output.getBuffer());
	return kryo.readObjectOrNull(input, type);
}
 
开发者ID:libgdx,项目名称:gdx-ai,代码行数:5,代码来源:KryoUtils.java


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