Examples of ExposedByteArrayOutputStream


Examples of net.sf.cram.io.ExposedByteArrayOutputStream

  public static int writeContainer(Container c, OutputStream os)
      throws IOException {

    long time1 = System.nanoTime();
    ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream();

    Block block = new CompressionHeaderBLock(c.h);
    block.write(baos);
    c.blockCount = 1;

    List<Integer> landmarks = new ArrayList<Integer>();
    SliceIO sio = new SliceIO();
    for (int i = 0; i < c.slices.length; i++) {
      Slice s = c.slices[i];
      landmarks.add(baos.size());
      sio.write(s, baos);
      c.blockCount++ ;
      c.blockCount++;
      if (s.embeddedRefBlock != null)
        c.blockCount++;
      c.blockCount += s.external.size();
    }
    c.landmarks = new int[landmarks.size()];
    for (int i = 0; i < c.landmarks.length; i++)
      c.landmarks[i] = landmarks.get(i);

    c.containerByteSize = baos.size();
    calculateSliceOffsetsAndSizes(c);

    ContainerHeaderIO chio = new ContainerHeaderIO();
    int len = chio.writeContainerHeader(c, os);
    os.write(baos.getBuffer(), 0, baos.size());
    len += baos.size();

    long time2 = System.nanoTime();

    log.debug("CONTAINER WRITTEN: " + c.toString());
    c.writeTime = time2 - time1;
View Full Code Here

Examples of net.sourceforge.js3tream.StdinOperation.ExposedByteArrayOutputStream

   
   
    /* Setup the temp buffer */
    if (!this.useFile_)
    {
      this.memoryBuffer_ = new ExposedByteArrayOutputStream(DEFAULT_BUCKET_OBJECT_BYTES);
    }
    else
    {
      this.tempFile_ = File.createTempFile("s3stream", "io");
      this.tempFile_.deleteOnExit();
View Full Code Here

Examples of org.infinispan.commons.io.ExposedByteArrayOutputStream

   private Object objectFromInputStreamInReentrantMode(InputStream is) throws IOException, ClassNotFoundException, InterruptedException {
      int len = is.available();
      Object o = null;
      if (len != 0) {
         ExposedByteArrayOutputStream bytes = new ExposedByteArrayOutputStream(len);
         byte[] buf = new byte[Math.min(len, 1024)];
         int bytesRead;
         while ((bytesRead = is.read(buf, 0, buf.length)) != -1) {
            bytes.write(buf, 0, bytesRead);
         }
         is = new ByteArrayInputStream(bytes.getRawBuffer(), 0, bytes.size());
         ObjectInput unmarshaller = marshaller.startObjectInput(is, false);
         try {
            o = marshaller.objectFromObjectStream(unmarshaller);
         } finally {
            marshaller.finishObjectInput(unmarshaller);
View Full Code Here

Examples of org.infinispan.commons.io.ExposedByteArrayOutputStream

      out.writeObject(obj);
   }

   @Override
   final protected ByteBuffer objectToBuffer(final Object o, final int estimatedSize) throws IOException {
      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(estimatedSize);
      ObjectOutput marshaller = startObjectOutput(baos, false, estimatedSize);
      try {
         objectToObjectStream(o, marshaller);
      } finally {
         finishObjectOutput(marshaller);
      }
      return new ByteBufferImpl(baos.getRawBuffer(), 0, baos.size());
   }
View Full Code Here

Examples of org.infinispan.commons.io.ExposedByteArrayOutputStream

      StreamingMarshaller marshaller = getCacheMarshaller(cacheName);

      // Take the cache marshaller and generate the payload for the rest of
      // the command using that cache marshaller and the write the bytes in
      // the original payload.
      ExposedByteArrayOutputStream os = marshallParameters(command, marshaller);
      UnsignedNumeric.writeUnsignedInt(output, os.size());
      // Do not rely on the raw buffer's length which is likely to be much longer!
      output.write(os.getRawBuffer(), 0, os.size());
      if (command instanceof TopologyAffectedCommand) {
         output.writeInt(((TopologyAffectedCommand) command).getTopologyId());
      }
   }
View Full Code Here

Examples of org.infinispan.commons.io.ExposedByteArrayOutputStream

   private ExposedByteArrayOutputStream marshallParameters(
         CacheRpcCommand cmd, StreamingMarshaller marshaller) throws IOException {
      BufferSizePredictor sizePredictor = marshaller.getBufferSizePredictor(cmd);
      int estimatedSize = sizePredictor.nextSize(cmd);
      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(estimatedSize);
      ObjectOutput output = marshaller.startObjectOutput(baos, true, estimatedSize);
      try {
         cmdExt.writeCommandParameters(output, cmd);
      } finally {
         marshaller.finishObjectOutput(output);
View Full Code Here

Examples of org.infinispan.io.ExposedByteArrayOutputStream

      if (trace) log.trace("Unmarshalled object " + retValue);
      return retValue;
   }

   public ByteBuffer objectToBuffer(Object o) throws IOException {
      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
      ObjectOutput out = new ObjectOutputStream(baos);

      //now marshall the contents of the object
      objectToObjectStream(o, out);
      out.close();
      // and return bytes.
      return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
   }
View Full Code Here

Examples of org.infinispan.io.ExposedByteArrayOutputStream

   protected int getCustomMarshallerVersionInt() {
      return CUSTOM_MARSHALLER;
   }

   public ByteBuffer objectToBuffer(Object obj) throws IOException {
      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
      ObjectOutputStream out = new ObjectOutputStream(baos);

      out.writeShort(VERSION_400);
      log.trace("Wrote version {0}", VERSION_400);

      //now marshall the contents of the object
      defaultMarshaller.objectToObjectStream(obj, out);
      out.close();

      // and return bytes.
      return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
   }
View Full Code Here

Examples of org.infinispan.io.ExposedByteArrayOutputStream

      System.arraycopy(b.getBuf(), b.getOffset(), bytes, 0, b.getLength());
      return bytes;
   }

   public ByteBuffer objectToBuffer(Object o) throws IOException {
      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
      ObjectOutput marshaller = startObjectOutput(baos);
      objectToObjectStream(o, marshaller);
      finishObjectOutput(marshaller);
      return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
   }
View Full Code Here

Examples of org.infinispan.io.ExposedByteArrayOutputStream

      StreamingMarshaller marshaller = registry.getComponent(
            StreamingMarshaller.class, KnownComponentNames.CACHE_MARSHALLER);
      // Take the cache marshaller and generate the payload for the rest of
      // the command using that cache marshaller and the write the bytes in
      // the original payload.
      ExposedByteArrayOutputStream os = marshallParameters(command, marshaller);
      UnsignedNumeric.writeUnsignedInt(output, os.size());
      // Do not rely on the raw buffer's lenght which is likely to be much longer!
      output.write(os.getRawBuffer(), 0, os.size());
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.