Examples of DataOutput


Examples of java.io.DataOutput

        map.put(new Long(3L), new String("all"));
        t1.set(0, map);

        File file = File.createTempFile("Tuple", "put");
        FileOutputStream fos = new FileOutputStream(file);
        DataOutput out = new DataOutputStream(fos);
        t1.write(out);
        fos.close();

        FileInputStream fis = new FileInputStream(file);
        DataInput in = new DataInputStream(fis);
View Full Code Here

Examples of java.io.DataOutput

   
    if (isWriteMethod) {
      // If every output handler has been removed - ignore everything
      if (!information.marker.getOutputHandlers().isEmpty()) {
        try {
          DataOutput output = (DataOutput) args[0];

          // First - we need the initial buffer
          ByteArrayOutputStream outputBufferStream = new ByteArrayOutputStream();
          proxy.invoke(information.proxyObject, new Object[] { new DataOutputStream(outputBufferStream) });
         
          // Let each handler prepare the actual output
          byte[] outputBuffer = processor.processOutput(information.event, information.marker,
              outputBufferStream.toByteArray());
         
          // Write that output to the network stream
          output.write(outputBuffer);

          // We're done
          processor.invokePostEvent(information.event, information.marker);
          return null;
         
View Full Code Here

Examples of java.io.DataOutput

    compound.put("age", 42);
   
    compound.put(NbtFactory.ofList("nicknames", "a", "b", "c"));

    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    DataOutput test = new DataOutputStream(buffer);
    compound.write(test);

    ByteArrayInputStream source = new ByteArrayInputStream(buffer.toByteArray());
    DataInput input = new DataInputStream(source);
   
View Full Code Here

Examples of java.io.DataOutput

            try {
                socket = new Socket(address, syncPort);
                LOG.info("sync connected to " + socket.getInetAddress().getHostAddress() + " port " + socket.getLocalPort());

                final CRC32 crc32 = new CRC32();
                final DataOutput output = new DataOutputStream(new CheckedOutputStream(socket.getOutputStream(), crc32));
                final DataInput input = new DataInputStream(socket.getInputStream());
                output.writeByte(INIT);
                long logId = input.readLong();
                do {
                    final long nextLogId = logId + 1;
                    final File file = Util.logFile(nextLogId);
                    if (file.exists() && server.getLogger().isWritten(nextLogId)) {
                        logId++;

                        output.writeByte(RECOVERY_LOG);
                        crc32.reset();
                        output.writeLong(logId);

                        LOG.info("sending recovery file: " + file.getName());
                        final BufferedInputStream fileInput = new BufferedInputStream(new FileInputStream(file));

                        final byte[] buffer = new byte[8092];
                        int read;
                        while ((read = fileInput.read(buffer)) > 0) {
                            output.writeInt(read);
                            output.write(buffer, 0, read);
                        }
                        output.writeInt(0);

                        output.writeLong(crc32.getValue());
                    }
                    try {
                        Thread.sleep(300);
                    } catch (final InterruptedException ignore) {
                    }
View Full Code Here

Examples of java.io.DataOutput

    }

    private void syncConnection(final Socket connection, final int readTimeout) {
        try {
            final CRC32 crc32 = new CRC32();
            final DataOutput output = new DataOutputStream(connection.getOutputStream());
            final DataInput input = new DataInputStream(new CheckedInputStream(connection.getInputStream(), crc32));

            if (input.readByte() != INIT) {
                return;
            }

            final LogRange logFileRange = Util.logFileRange();
            final long lastId = logFileRange.noLogFile() ? -1 : logFileRange.getLast();
            output.writeLong(lastId);
            do {
                if (input.readByte() != RECOVERY_LOG) {
                    return;
                }
                crc32.reset();
View Full Code Here

Examples of java.io.DataOutput

                dataOut.writeByte(type);
                bs.marshal(dataOut);
                dsm.tightMarshal2(this, c, dataOut, bs);

            } else {
                DataOutput looseOut = dataOut;

                if (!sizePrefixDisabled) {
                    bytesOut.restart();
                    looseOut = bytesOut;
                }

                looseOut.writeByte(type);
                dsm.looseMarshal(this, c, looseOut);

                if (!sizePrefixDisabled) {
                    ByteSequence sequence = bytesOut.toByteSequence();
                    dataOut.writeInt(sequence.getLength());
View Full Code Here

Examples of org.apache.lucene.store.DataOutput

 
  protected void writeDictionary(String filename) throws IOException {
    new File(filename).getParentFile().mkdirs();
    final FileOutputStream os = new FileOutputStream(filename);
    try {
      final DataOutput out = new OutputStreamDataOutput(os);
      CodecUtil.writeHeader(out, BinaryDictionary.DICT_HEADER, BinaryDictionary.VERSION);
      out.writeVInt(buffer.position());
      final WritableByteChannel channel = Channels.newChannel(os);
      // Write Buffer
      buffer.flip()// set position to 0, set limit to current position
      channel.write(buffer);
      assert buffer.remaining() == 0L;
View Full Code Here

Examples of org.apache.lucene.store.DataOutput

  protected void writeTargetMap(String filename) throws IOException {
    new File(filename).getParentFile().mkdirs();
    OutputStream os = new FileOutputStream(filename);
    try {
      os = new BufferedOutputStream(os);
      final DataOutput out = new OutputStreamDataOutput(os);
      CodecUtil.writeHeader(out, BinaryDictionary.TARGETMAP_HEADER, BinaryDictionary.VERSION);
     
      final int numSourceIds = lastSourceId + 1;
      out.writeVInt(targetMapEndOffset); // <-- size of main array
      out.writeVInt(numSourceIds + 1); // <-- size of offset array (+ 1 more entry)
      int prev = 0, sourceId = 0;
      for (int ofs = 0; ofs < targetMapEndOffset; ofs++) {
        final int val = targetMap[ofs], delta = val - prev;
        assert delta >= 0;
        if (ofs == targetMapOffsets[sourceId]) {
          out.writeVInt((delta << 1) | 0x01);
          sourceId++;
        } else {
          out.writeVInt((delta << 1));
        }
        prev += delta;
      }
      assert sourceId == numSourceIds : "sourceId:"+sourceId+" != numSourceIds:"+numSourceIds;
    } finally {
View Full Code Here

Examples of org.apache.lucene.store.DataOutput

  protected void writePosDict(String filename) throws IOException {
    new File(filename).getParentFile().mkdirs();
    OutputStream os = new FileOutputStream(filename);
    try {
      os = new BufferedOutputStream(os);
      final DataOutput out = new OutputStreamDataOutput(os);
      CodecUtil.writeHeader(out, BinaryDictionary.POSDICT_HEADER, BinaryDictionary.VERSION);
      out.writeVInt(posDict.size());
      for (String s : posDict) {
        if (s == null) {
          out.writeByte((byte)0);
          out.writeByte((byte)0);
          out.writeByte((byte)0);
        } else {
          String data[] = CSVUtil.parse(s);
          assert data.length == 3 : "malformed pos/inflection: " + s;
          out.writeString(data[0]);
          out.writeString(data[1]);
          out.writeString(data[2]);
        }
      }
    } finally {
      os.close();
    }
View Full Code Here

Examples of org.apache.lucene.store.DataOutput

    }
  }

  @Override
  public boolean store(OutputStream output) throws IOException {
    DataOutput out = new OutputStreamDataOutput(output);
    CodecUtil.writeHeader(out, CODEC_NAME, VERSION_CURRENT);
    out.writeByte(separator);
    out.writeVInt(grams);
    out.writeVLong(totTokens);
    fst.save(out);
    return true;
  }
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.