當前位置: 首頁>>代碼示例>>Java>>正文


Java Output.flush方法代碼示例

本文整理匯總了Java中com.esotericsoftware.kryo.io.Output.flush方法的典型用法代碼示例。如果您正苦於以下問題:Java Output.flush方法的具體用法?Java Output.flush怎麽用?Java Output.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.esotericsoftware.kryo.io.Output的用法示例。


在下文中一共展示了Output.flush方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
/**
 * 序列化
 *
 * @param obj 需要序更列化的對象
 * @return 序列化後的byte 數組
 * @throws TransactionException
 */
@Override
public byte[] serialize(Object obj) throws TransactionException {
    byte[] bytes;
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try {
        //獲取kryo對象
        Kryo kryo = new Kryo();
        Output output = new Output(outputStream);
        kryo.writeObject(output, obj);
        bytes = output.toBytes();
        output.flush();
    } catch (Exception ex) {
        throw new TransactionException("kryo serialize error" + ex.getMessage());
    } finally {
        try {
            outputStream.flush();
            outputStream.close();
        } catch (IOException e) {

        }
    }
    return bytes;
}
 
開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:31,代碼來源:KryoSerializer.java

示例2: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
@Override
public byte[] serialize(Object obj) throws SerializerException {
    byte[] bytes;
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try {
        //獲取kryo對象
        Kryo kryo = new Kryo();
        Output output = new Output(outputStream);
        kryo.writeObject(output, obj);
        bytes = output.toBytes();
        output.flush();
    } catch (Exception ex) {
        throw new SerializerException("kryo serialize error" + ex.getMessage());
    } finally {
        try {
            outputStream.flush();
            outputStream.close();
        } catch (IOException e) {

        }
    }
    return bytes;
}
 
開發者ID:1991wangliang,項目名稱:tx-lcn,代碼行數:24,代碼來源:KryoSerializer.java

示例3: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
/**
 * 序列化
 *
 * @param obj 需要序更列化的對象
 * @return 序列化後的byte 數組
 * @throws TccException
 */
@Override
public byte[] serialize(Object obj) throws TccException {
    byte[] bytes;
    try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
        //獲取kryo對象
        Kryo kryo = new Kryo();
        Output output = new Output(outputStream);
        kryo.writeObject(output, obj);
        bytes = output.toBytes();
        output.flush();
    } catch (Exception ex) {
        throw new TccException("kryo serialize error" + ex.getMessage());
    }
    return bytes;
}
 
開發者ID:yu199195,項目名稱:happylifeplat-tcc,代碼行數:23,代碼來源:KryoSerializer.java

示例4: encode

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
protected void encode(ChannelHandlerContext channelHandlerContext, Object o, ByteBuf byteBuf) throws Exception {
    if(clazz.isInstance(o)){
        Kryo kryo = null;
        try{
        	kryo = pool.borrow();
        	ByteArrayOutputStream baos = new ByteArrayOutputStream();  
            Output output = new Output(baos);  
            kryo.writeObject(output, o);  
            output.flush();  
            output.close();  
           
            byte[] data = baos.toByteArray(); 
            byteBuf.writeInt(data.length);
            byteBuf.writeBytes(data);
            baos.close();
        }catch(Exception e){
        	LOG.warn("MessageEncoder happen exception.", e);
        }finally{
        	if(kryo != null){
        		 pool.release(kryo);
        	}
        }
        
    }

}
 
開發者ID:islittlechen,項目名稱:lionrpc,代碼行數:27,代碼來源:MessageEncoder.java

示例5: writeTable

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
private <E> void writeTable(String key, RakTable<E> paperTable, File originalFile, File backupFile) {
    try {
        FileOutputStream file = new FileOutputStream(originalFile);
        final Output kryoOutput = new Output(file);
        getKryo().writeObject(kryoOutput, paperTable);
        kryoOutput.flush();
        file.flush();
        sync(file);
        kryoOutput.close();
        backupFile.delete();
    } catch (IOException e) {
        if (originalFile.exists()) {
            if (!originalFile.delete()) {
                throw new RuntimeException("cant deleted");
            }
        }
        throw new RuntimeException("cant save to table " + key, e);
    }
}
 
開發者ID:isfaaghyth,項目名稱:Rak,代碼行數:20,代碼來源:PlainData.java

示例6: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
/**
 * 序列化
 *
 * @param obj 需要序更列化的對象
 * @return 序列化後的byte 數組
 * @throws MythException 異常
 */
@Override
public byte[] serialize(Object obj) throws MythException {
    byte[] bytes;
    try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
        //獲取kryo對象
        Kryo kryo = new Kryo();
        Output output = new Output(outputStream);
        kryo.writeObject(output, obj);
        bytes = output.toBytes();
        output.flush();
    } catch (Exception ex) {
        throw new MythException("kryo serialize error" + ex.getMessage());
    }
    return bytes;
}
 
開發者ID:yu199195,項目名稱:myth,代碼行數:23,代碼來源:KryoSerializer.java

示例7: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
public byte[] serialize(Object object) {
    Kryo kryo = new Kryo();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Output output = new Output(baos);
    kryo.writeObject(output, object);
    output.flush();
    output.close();
    byte[] bytes = baos.toByteArray();
    try {
        baos.flush();
        baos.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return bytes;
}
 
開發者ID:tinylcy,項目名稱:buddha,代碼行數:17,代碼來源:KryoSerializer.java

示例8: serializationObject

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
private byte[] serializationObject(Kryo kryo, byte[] obj) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Output output = new Output(baos);
    kryo.writeClassAndObject(output, obj);
    output.flush();
    output.close();

    byte[] b = baos.toByteArray();
    try {
        baos.flush();
        baos.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return b;
}
 
開發者ID:PAA-NCIC,項目名稱:SparkSeq,代碼行數:18,代碼來源:TestKryo.java

示例9: serializationObject

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
private <T extends Serializable> byte[] serializationObject(T obj) {
    Kryo kryo = new Kryo();
    kryo.setReferences(false);
    kryo.register(obj.getClass(), new JavaSerializer());

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Output output = new Output(baos);
    kryo.writeClassAndObject(output, obj);
    output.flush();
    output.close();

    byte[] b = baos.toByteArray();
    try {
        baos.flush();
        baos.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return b;
}
 
開發者ID:PAA-NCIC,項目名稱:SparkSeq,代碼行數:22,代碼來源:TestMapDataSerialization.java

示例10: serializeAlgoMetric

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
public static byte[] serializeAlgoMetric(Metric value) {
  Kryo kryo = getKryo();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  Output output = new Output(baos);
  kryo.writeClassAndObject(output, value);
  output.flush();
  output.close();
  return baos.toByteArray();
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:10,代碼來源:KryoUtils.java

示例11: encode

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
@Override
public CachedData encode(final Object obj) {
    final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    final Output output = new Output(byteStream);
    kryo.writeClassAndObject(output, obj);
    output.flush();
    IOUtils.closeQuietly(output);
    final byte[] bytes = byteStream.toByteArray();
    return new CachedData(0, bytes, bytes.length);
}
 
開發者ID:luotuo,項目名稱:cas4.0.x-server-wechat,代碼行數:11,代碼來源:KryoTranscoder.java

示例12: clone

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
private <T> T  clone(T obj){
	Kryo kryo = kryoFactory.getKryo();
	try {
		Output output = new Output(1024, 1024 * 500);
		kryo.writeClassAndObject(output, obj);
		output.flush();
		Input input = new Input(output.toBytes());
		T t = (T) kryo.readClassAndObject(input);
		return t;
	} finally {
		kryoFactory.returnKryo(kryo);;
	}
}
 
開發者ID:yaoakeji,項目名稱:hibatis,代碼行數:14,代碼來源:CacheContext.java

示例13: treeNode

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
@Test
public void treeNode() {
    final Result<DecisionTreeRuleSet> result = (new CommisionRuleSetSupplier()).get();
    EhSupport.ensure(result.isSuccess(), "Could not create decision tree");
    final DecisionTreeRuleSet ruleSet = result.getData();

    final TreeNode node = DecisionTreeFactory.constructDecisionTree(ruleSet, DecisionTreeType.SINGLE);

    final Kryo kryo = new Kryo();
    // no default no-arg constructors
    kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());

    final InstantiatorStrategy defaultInstantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
    kryo.getRegistration(ArrayList.class)
            .setInstantiator(defaultInstantiatorStrategy.newInstantiatorOf(ArrayList.class));
    kryo.getRegistration(HashSet.class)
            .setInstantiator(defaultInstantiatorStrategy.newInstantiatorOf(HashSet.class));
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);

    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final Output output = new Output(out);
    kryo.writeObject(output, node);
    output.flush();
    output.close();

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray());
    final Input kryoInput = new Input(inputStream);
    final TreeNode tree = kryo.readObject(kryoInput, BaseTreeNode.class);

    final SingleDecisionTreeFactoryTest test = new SingleDecisionTreeFactoryTest();
    test.checkTreeNode(tree, ruleSet);

    assertEquals(node, tree);
}
 
開發者ID:jpmorganchase,項目名稱:swblocks-decisiontree,代碼行數:35,代碼來源:TreeSerializationTest.java

示例14: send

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
@Override
public void send(Output output) throws IOException {
    output.writeInt(srcRank);
    output.writeInt(destRank);
    output.writeInt(step);
    output.writeInt(sum);
    output.writeInt(segNum);
    for (int i = 0; i < segNum; i++) {
        output.writeInt(ranks.get(i));
        output.writeInt(dataNums.get(i));
    }
    output.flush();
}
 
開發者ID:yuantiku,項目名稱:ytk-mp4j,代碼行數:14,代碼來源:MapMetaData.java

示例15: send

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
@Override
public void send(Output output) throws IOException {
    output.writeInt(srcRank);
    output.writeInt(destRank);
    output.writeInt(step);
    output.writeInt(sum);
    output.writeInt(segNum);
    for (int i = 0; i < segNum; i++) {
        output.writeInt(ranks.get(i));
        output.writeInt(segFroms.get(i));
        output.writeInt(segTos.get(i));
    }
    output.flush();
}
 
開發者ID:yuantiku,項目名稱:ytk-mp4j,代碼行數:15,代碼來源:ArrayMetaData.java


注:本文中的com.esotericsoftware.kryo.io.Output.flush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。