• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java FastOutput类的典型用法和代码示例

java 3次浏览

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

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

示例1: serialize

点赞 2

import com.esotericsoftware.kryo.io.FastOutput; //导入依赖的package包/类
@Override
public byte[] serialize(Object data) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Kryo kryo = kryoThreadMap.get();
    KryoObjectOutput out = new KryoObjectOutput(kryo, new FastOutput(bos));
    out.writeObject(data);
    out.flush();
    return bos.toByteArray();
}
 

开发者ID:chenxh,
项目名称:rpc,
代码行数:10,
代码来源:KryoSerialization.java

示例2: openFileForWriting

点赞 2

import com.esotericsoftware.kryo.io.FastOutput; //导入依赖的package包/类
public void openFileForWriting()
{
    try
    {
        File destinationFile = newFileStrategy.getNewFile();
        LOG.info("{} storing events to: {}", newFileStrategy.toString(), destinationFile.getAbsolutePath());
        FileOutputStream fos = new FileOutputStream(destinationFile);
        OutputStream out = storeInGzip ? new GZIPOutputStream(fos, true) : fos;
        output = new FastOutput(out);
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}
 

开发者ID:d0k1,
项目名称:jsflight,
代码行数:16,
代码来源:InternalEventRecorder.java

示例3: serialize

点赞 2

import com.esotericsoftware.kryo.io.FastOutput; //导入依赖的package包/类
public final byte[] serialize(final Object value) {
    final Kryo kryo = threadLocalKryo.get();
    final Output output = new FastOutput(16, 1024);
    kryo.writeClassAndObject(output, value);
    return output.toBytes();
}
 

开发者ID:RxBroadcast,
项目名称:RxBroadcast,
代码行数:7,
代码来源:KryoSerializer.java

示例4: prepareRequestToRecord

点赞 2

import com.esotericsoftware.kryo.io.FastOutput; //导入依赖的package包/类
public static RecordableHttpServletRequest prepareRequestToRecord(HttpServletRequest original,
        HttpRecordInformation info)
{
    // buffer is 1kb at least
    ByteArrayOutputStream stream = new ByteArrayOutputStream(1024 * 1024);

    FastOutput out = new FastOutput(stream);
    Kryo kryo = threadKryo.get();
    if (kryo == null)
    {
        kryo = new Kryo();
        kryo.register(HashMap.class, new MapSerializer());
        kryo.register(ConcurrentHashMap.class, new MapSerializer());
        threadKryo.set(kryo);
    }
    HashMap<String, String[]> item = new HashMap<>();
    if (original.getParameterMap() != null)
    {
        item.putAll(original.getParameterMap());
    }

    HashMap<String, String> headers = new HashMap<>();
    Enumeration<String> names = original.getHeaderNames();
    while (names.hasMoreElements())
    {
        String header = names.nextElement();
        headers.put(header, original.getHeader(header));
    }
    try
    {
        kryo.writeObject(out, item);

        kryo.writeObject(out, headers);

        kryo.writeObjectOrNull(out, original.getContentLength(), Integer.class);

        kryo.writeObjectOrNull(out, original.getContentType(), String.class);

        kryo.writeObjectOrNull(out, original.getRequestURI(), String.class);

        kryo.writeObjectOrNull(out, original.getMethod(), String.class);
        kryo.writeObjectOrNull(out, original.getServletContext().getContextPath(), String.class);

        HashMap<String, String> cookies = new HashMap<>();
        if (original.getCookies() != null && original.getCookies().length > 0)
        {
            for (Cookie cookie : original.getCookies())
            {
                cookies.put(cookie.getName(), cookie.getValue());
            }
        }

        kryo.writeObject(out, cookies);
        out.flush();
        out.close();

    }
    catch (Exception e)
    {
        e.printStackTrace(System.err);
        throw e;
    }

    info.params = stream.toByteArray();
    return new RecordableHttpServletRequest(original);
}
 

开发者ID:d0k1,
项目名称:jsflight,
代码行数:67,
代码来源:HttpRecorderHelper.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)