com.esotericsoftware.kryo.io.Output.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中com.esotericsoftware.kryo.io.Output.<init>()方法的一些代码示例,展示了Output.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Output.<init>()方法的具体详情如下:
包路径:com.esotericsoftware.kryo.io.Output
类名称:Output
方法名:<init>

Output.<init>介绍

[英]Creates an uninitialized Output. #setBuffer(byte[],int) must be called before the Output is used.
[中]创建未初始化的输出#在使用输出之前,必须调用setBuffer(字节[],int)。

代码示例

代码示例来源:origin: apache/storm

@Override
  protected Output initialValue() {
    return new Output(2000, 2000000000);
  }
};

代码示例来源:origin: apache/incubator-dubbo

public KryoObjectOutput(OutputStream outputStream) {
  output = new Output(outputStream);
  this.kryo = KryoUtils.get();
}

代码示例来源:origin: apache/incubator-dubbo

public KryoObjectOutput(OutputStream outputStream) {
  output = new Output(outputStream);
  this.kryo = KryoUtils.get();
}

代码示例来源:origin: alibaba/jstorm

/**
 * Constructs a {@link DefaultStateSerializer} instance with the given list
 * of classes registered in kryo.
 *
 * @param classesToRegister the classes to register.
 */
public DefaultStateSerializer(List<Class<?>> classesToRegister) {
  kryo = new Kryo();
  output = new Output(2000, 2000000000);
  for (Class<?> klazz : classesToRegister) {
    kryo.register(klazz);
  }
}

代码示例来源: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: 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

public KryoValuesSerializer(Map<String, Object> conf) {
  _kryo = SerializationFactory.getKryo(conf);
  _delegate = new ListDelegate();
  _kryoOut = new Output(2000, 2000000000);
}

代码示例来源:origin: alibaba/jstorm

public KryoValuesSerializer(Map conf) {
  _kryo = SerializationFactory.getKryo(conf);
  _delegate = new ListDelegate();
  _kryoOut = new Output(2000, 2000000000);
}

代码示例来源: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: 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: 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: alibaba/jstorm

public KryoSerializer() {
  kryo = new Kryo();
  kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
  output = new Output(200, 2000000000);
  input = new Input(1);
}

代码示例来源:origin: alibaba/jstorm

public KryoTupleSerializer(final Map conf, final StormTopology topology) {
  _kryo = new KryoValuesSerializer(conf);
  _kryoOut = new Output(2000, 2000000000);
  _ackerNum = JStormUtils.parseInt(conf.get(Config.TOPOLOGY_ACKER_EXECUTORS), 0);
  _ids = new SerializationFactory.IdDictionary(topology);
  _isTransactionTuple = JStormUtils.parseBoolean(conf.get(ConfigExtension.TRANSACTION_TOPOLOGY), false);
}

代码示例来源:origin: apache/hive

private static byte[] serializeObjectToKryo(Serializable object) {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 Output output = new Output(baos);
 Kryo kryo = borrowKryo();
 try {
  kryo.writeObject(output, object);
 } finally {
  releaseKryo(kryo);
 }
 output.close();
 return baos.toByteArray();
}

代码示例来源:origin: apache/hive

public static byte[] serialize(Object object) {
 ByteArrayOutputStream stream = new ByteArrayOutputStream();
 Output output = new Output(stream);
 Kryo kryo = SerializationUtilities.borrowKryo();
 kryo.setClassLoader(Thread.currentThread().getContextClassLoader());
 try {
  kryo.writeObject(output, object);
 } finally {
  SerializationUtilities.releaseKryo(kryo);
 }
 output.close(); // close() also calls flush()
 return stream.toByteArray();
}

代码示例来源:origin: apache/storm

public KryoTupleSerializer(final Map<String, Object> conf, final GeneralTopologyContext context) {
  _kryo = new KryoValuesSerializer(conf);
  _kryoOut = new Output(2000, 2000000000);
  _ids = new SerializationFactory.IdDictionary(context.getRawTopology());
}

代码示例来源:origin: apache/hive

/**
 * @param plan Usually of type MapredWork, MapredLocalWork etc.
 * @param out stream in which serialized plan is written into
 */
private static void serializeObjectByKryo(Kryo kryo, Object plan, OutputStream out) {
 Output output = new Output(out);
 kryo.setClassLoader(Utilities.getSessionSpecifiedClassLoader());
 kryo.writeObject(output, plan);
 output.close();
}

代码示例来源:origin: apache/ignite

@Override public void apply(TestObject obj) {
    out.reset();
    Output kryoOut = null;
    try {
      kryoOut = new Output(out);
      kryo.writeObject(kryoOut, obj);
    }
    finally {
      U.close(kryoOut, log);
    }
  }
};

代码示例来源:origin: apache/hive

public static String toKryo(SearchArgument sarg) {
 Output out = new Output(4 * 1024, 10 * 1024 * 1024);
 new Kryo().writeObject(out, sarg);
 out.close();
 return Base64.encodeBase64String(out.toBytes());
}

相关文章