本文整理了Java中com.esotericsoftware.kryo.io.Output.flush()
方法的一些代码示例,展示了Output.flush()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Output.flush()
方法的具体详情如下:
包路径:com.esotericsoftware.kryo.io.Output
类名称:Output
方法名:flush
[英]Writes the buffered bytes to the underlying OutputStream, if any.
[中]将缓冲字节写入基础OutputStream(如果有)。
代码示例来源:origin: apache/incubator-dubbo
@Override
public void flushBuffer() throws IOException {
output.flush();
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void flushBuffer() throws IOException {
output.flush();
}
代码示例来源:origin: changmingxie/tcc-transaction
public byte[] execute(Kryo kryo) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Output output = new Output(byteArrayOutputStream);
kryo.writeClassAndObject(output, object);
output.flush();
return byteArrayOutputStream.toByteArray();
}
});
代码示例来源:origin: apache/storm
@Override
public void handleDataPoints(TaskInfo taskInfo, Collection<DataPoint> dataPoints) {
try {
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
try (Output out = new Output(con.getOutputStream())) {
serializer.serializeInto(Arrays.asList(taskInfo, dataPoints, topologyId), out);
out.flush();
}
//The connection is not sent unless a response is requested
int response = con.getResponseCode();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/hive
private void safeWriteToOutput(Output output,
BaseProtocol.JobResult<?> jobResult) throws IOException {
ByteArrayOutputStream boas = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(boas);
oos.writeObject(jobResult);
oos.flush();
output.write(boas.toByteArray());
output.flush();
}
代码示例来源:origin: jersey/jersey
@Override
public void writeTo(final Object object, final Class<?> type, final Type genericType,
final Annotation[] annotations, final MediaType mediaType,
final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream)
throws IOException, WebApplicationException {
final Output output = new Output(entityStream);
kryoPool.run(new KryoCallback() {
public Object execute(Kryo kryo) {
kryo.writeObject(output, object);
return null;
}
});
output.flush();
}
代码示例来源:origin: changmingxie/tcc-transaction
public static <T> byte[] writeToByteArray(T obj) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Output output = new Output(byteArrayOutputStream);
Kryo kryo = getInstance();
kryo.writeClassAndObject(output, obj);
output.flush();
return byteArrayOutputStream.toByteArray();
}
代码示例来源:origin: changmingxie/tcc-transaction
public static <T> byte[] writeToByteArray(T obj) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Output output = new Output(byteArrayOutputStream);
Kryo kryo = getInstance();
kryo.writeClassAndObject(output, obj);
output.flush();
return byteArrayOutputStream.toByteArray();
}
代码示例来源:origin: apache/storm
private byte[] getKryoSerializedBytes (final Object obj) {
final Kryo kryo = new Kryo();
final ByteArrayOutputStream os = new ByteArrayOutputStream();
final Output output = new Output(os);
kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
kryo.writeClassAndObject(output, obj);
output.flush();
return os.toByteArray();
}
代码示例来源:origin: apache/hive
@Override
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf buf)
throws Exception {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
Output kryoOut = new Output(bytes);
kryos.get().writeClassAndObject(kryoOut, msg);
kryoOut.flush();
byte[] msgData = maybeEncrypt(bytes.toByteArray());
LOG.trace("Encoded message of type {} ({} bytes)", msg.getClass().getName(), msgData.length);
checkSize(msgData.length);
buf.ensureWritable(msgData.length + 4);
buf.writeInt(msgData.length);
buf.writeBytes(msgData);
}
代码示例来源:origin: yu199195/Raincat
@Override
public byte[] serialize(final Object obj) throws TransactionException {
byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Output output = new Output(outputStream)) {
//获取kryo对象
Kryo kryo = new Kryo();
kryo.writeObject(output, obj);
bytes = output.toBytes();
output.flush();
} catch (IOException ex) {
throw new TransactionException("kryo serialize error" + ex.getMessage());
}
return bytes;
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public ByteBuffer serialize(Object obj) {
if (obj == null)
return null;
ByteArrayOutputStream stream = null;
Output out = null;
try {
stream = new ByteArrayOutputStream(DFLT_BUFFER_SIZE);
out = new Output(stream);
kryos.get().writeClassAndObject(out, obj);
out.flush();
return ByteBuffer.wrap(stream.toByteArray());
}
catch (Throwable e) {
throw new IllegalStateException("Failed to serialize object of the class '" + obj.getClass().getName() + "'", e);
}
finally {
U.closeQuiet(out);
U.closeQuiet(stream);
}
}
代码示例来源:origin: yu199195/myth
@Override
public byte[] serialize(final Object obj) throws MythException {
byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Output output = new Output(outputStream)) {
//获取kryo对象
Kryo kryo = new Kryo();
kryo.writeObject(output, obj);
bytes = output.toBytes();
output.flush();
} catch (IOException ex) {
throw new MythException("kryo serialize error" + ex.getMessage());
}
return bytes;
}
代码示例来源:origin: yu199195/hmily
/**
* 序列化.
*
* @param obj 需要序更列化的对象
* @return 序列化后的byte 数组
* @throws HmilyException 异常
*/
@Override
public byte[] serialize(final Object obj) throws HmilyException {
byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Output output = new Output(outputStream)) {
//获取kryo对象
Kryo kryo = new Kryo();
kryo.writeObject(output, obj);
bytes = output.toBytes();
output.flush();
} catch (IOException ex) {
throw new HmilyException("kryo serialize error" + ex.getMessage());
}
return bytes;
}
代码示例来源:origin: apache/kylin
public static byte[] serialize(final Kryo kryo, final Object o) {
if (o == null) {
throw new NullPointerException("Can't serialize null");
}
final Output output = new Output(4096);
kryo.writeObject(output, o);
output.flush();
return output.getBuffer();
}
代码示例来源:origin: apache/flink
output.flush();
代码示例来源:origin: apache/hive
private ByteBuffer getSerializedSargForMetastore(boolean isOriginal) {
if (sarg == null) {
return null;
}
ByteBuffer serializedSarg = isOriginal ? sargIsOriginal : sargNotIsOriginal;
if (serializedSarg != null) {
return serializedSarg;
}
SearchArgument sarg2 = sarg;
Kryo kryo = SerializationUtilities.borrowKryo();
try {
if ((isOriginal ? sargNotIsOriginal : sargIsOriginal) == null) {
sarg2 = kryo.copy(sarg2); // In case we need it for the other case.
}
translateSargToTableColIndexes(sarg2, conf, OrcInputFormat.getRootColumn(isOriginal));
ExternalCache.Baos baos = new Baos();
Output output = new Output(baos);
kryo.writeObject(output, sarg2);
output.flush();
serializedSarg = baos.get();
if (isOriginal) {
sargIsOriginal = serializedSarg;
} else {
sargNotIsOriginal = serializedSarg;
}
} finally {
SerializationUtilities.releaseKryo(kryo);
}
return serializedSarg;
}
代码示例来源:origin: apache/tinkerpop
@Override
public void flush() {
unshadedOutput.flush();
}
}
代码示例来源:origin: apache/tinkerpop
@Override
public void writeClassAndObject(final Object object, OutputStream outputStream) {
Kryo k = null;
try {
k = KRYOS.take();
final Output kryoOutput = new Output(outputStream);
k.writeClassAndObject(kryoOutput, object);
kryoOutput.flush();
} catch (final InterruptedException e) {
throw new IllegalStateException(e);
} finally {
try {
KRYOS.put(k);
} catch (final InterruptedException e) {
throw new IllegalStateException(e);
}
}
}
代码示例来源:origin: Dromara/soul
@Override
public byte[] serialize(final Object obj) {
byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
//获取kryo对象
Kryo kryo = new Kryo();
Output output = new Output(outputStream);
kryo.writeClassAndObject(output, obj);
bytes = output.toBytes();
output.flush();
} catch (IOException ex) {
throw new SerializerException("kryo serialize error" + ex.getMessage());
}
return bytes;
}
内容来源于网络,如有侵权,请联系作者删除!