Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.Output


                        final HeaderReader headerReader) {
        this.serializationList = serializationList;
        this.headerWriter = headerWriter;
        this.headerReader = headerReader;

        final Output out = new Output(32);
        try {
            this.headerWriter.write(createKryo(), out);
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
        this.versionedHeader = out.toBytes();
    }
View Full Code Here


    }

    @Override
    public void writeGraph(final OutputStream outputStream, final Graph g) throws IOException {
        final Output output = new Output(outputStream);
        this.headerWriter.write(kryo, output);

        final boolean supportsGraphMemory = g.features().graph().variables().supportsVariables();
        output.writeBoolean(supportsGraphMemory);
        if (supportsGraphMemory)
            kryo.writeObject(output, new HashMap(g.variables().asMap()));

        final Iterator<Vertex> vertices = g.V();
        final boolean hasSomeVertices = vertices.hasNext();
        output.writeBoolean(hasSomeVertices);
        while (vertices.hasNext()) {
            final Vertex v = vertices.next();
            writeVertexToOutput(output, v, Direction.OUT);
        }

        output.flush();
    }
View Full Code Here

        output.flush();
    }

    @Override
    public void writeVertex(final OutputStream outputStream, final Vertex v, final Direction direction) throws IOException {
        final Output output = new Output(outputStream);
        this.headerWriter.write(kryo, output);
        writeVertexToOutput(output, v, direction);
        output.flush();
    }
View Full Code Here

        output.flush();
    }

    @Override
    public void writeVertex(final OutputStream outputStream, final Vertex v) throws IOException {
        final Output output = new Output(outputStream);
        this.headerWriter.write(kryo, output);
        writeVertexWithNoEdgesToOutput(output, v);
        output.flush();
    }
View Full Code Here

        output.flush();
    }

    @Override
    public void writeEdge(final OutputStream outputStream, final Edge e) throws IOException {
        final Output output = new Output(outputStream);
        this.headerWriter.write(kryo, output);
        kryo.writeClassAndObject(output, DetachedEdge.detach(e));
        output.flush();
    }
View Full Code Here

        out.putLong(LIMIT_POSITION,limit);
        out.putLong(EARLIEST_POSITION,earliestTimestamp);
        out.putLong(LATEST_POSITION,latestTimestamp);
        out.position(FIRST_RECORD_POSITION);
          bostr = new ByteBufferOutputStream(out);
          output = new Output(bostr);
      } else {
        memoryMappedFile = new RandomAccessFile(file,"r");
        fileSize = (int)file.length();
        MappedByteBuffer bb = memoryMappedFile.getChannel().map(MapMode.READ_ONLY, 0, HEADER_END);
        earliestTimestamp = bb.getLong(EARLIEST_POSITION);
View Full Code Here

      memoryMappedFile = new RandomAccessFile(file, "rw");
      out = memoryMappedFile.getChannel().map(MapMode.READ_WRITE, 0, FILE_CHUNK_SIZE);
      out.position(limit);
      out.putInt(LIMIT_POSITION,FIRST_RECORD_POSITION);
        bostr = new ByteBufferOutputStream(out);
        output = new Output(bostr);
      kryo = SerializeUtil.createKryo();
     
      MonitoringData md = null;
      Output o = new Output(nullOut);
      while ((md = of.pop()) != null) {
        kryo.writeClassAndObject(o,  md);
      }
    }
View Full Code Here

    @Override
    public byte[] encodeValue(Object value) {
        Kryo kryo = null;
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            Output output = new Output(baos);
            kryo = kryoPool.get();
            kryo.writeClassAndObject(output, value);
            output.close();
            return baos.toByteArray();
        } catch (Exception e) {
            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            }
View Full Code Here

/** @author Nathan Sweet <misc@n4te.com> */
public class InputOutputTest extends KryoTestCase {
  public void testOutputStream () throws IOException {
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    Output output = new Output(buffer, 2);
    output.writeBytes(new byte[] {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26});
    output.writeBytes(new byte[] {31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46});
    output.writeBytes(new byte[] {51, 52, 53, 54, 55, 56, 57, 58});
    output.writeBytes(new byte[] {61, 62, 63, 64, 65});
    output.flush();

    assertEquals(new byte[] { //
      11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, //
        31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, //
        51, 52, 53, 54, 55, 56, 57, 58, //
View Full Code Here

    System.arraycopy(temp, 512, temp2, 0, count);
    assertEquals(bytes, temp2);
  }

  public void testWriteBytes () throws IOException {
    Output buffer = new Output(512);
    buffer.writeBytes(new byte[] {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26});
    buffer.writeBytes(new byte[] {31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46});
    buffer.writeByte(51);
    buffer.writeBytes(new byte[] {52, 53, 54, 55, 56, 57, 58});
    buffer.writeByte(61);
    buffer.writeByte(62);
    buffer.writeByte(63);
    buffer.writeByte(64);
    buffer.writeByte(65);
    buffer.flush();

    assertEquals(new byte[] { //
      11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, //
        31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, //
        51, 52, 53, 54, 55, 56, 57, 58, //
        61, 62, 63, 64, 65}, buffer.toBytes());
  }
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.io.Output

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.