Package com.google.common.io

Examples of com.google.common.io.ByteArrayDataOutput


    for (int row = 0; row < numRecords; row++) {
      BytesRefArrayWritable dataWrite = new BytesRefArrayWritable(maxColumns);
      dataWrite.resetValid(maxColumns);
      for (int column = 0; column < maxColumns; column++) {
        Text sampleText = new Text("ROW-NUM:" + row + ", COLUMN-NUM:" + column);
        ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
        sampleText.write(dataOutput);
        dataWrite.set(column, new BytesRefWritable(dataOutput.toByteArray()));
      }
      rcFileWriter.append(dataWrite);
    }
    rcFileWriter.close();
  }
View Full Code Here


    for (int row = 0; row < numRecords; row++) {
      BytesRefArrayWritable dataWrite = new BytesRefArrayWritable(maxColumns);
      dataWrite.resetValid(maxColumns);
      for (int column = 0; column < maxColumns; column++) {
        Text sampleText = new Text("ROW-NUM:" + row + ", COLUMN-NUM:" + column);
        ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
        sampleText.write(dataOutput);
        dataWrite.set(column, new BytesRefWritable(dataOutput.toByteArray()));
      }
      rcFileWriter.append(dataWrite);
    }
    rcFileWriter.close();
  }
View Full Code Here

        for (TreeRange range : mt.invalids())
            range.addAll(new HIterator(range.right));

        byte[] initialhash = mt.hash(full);

        ByteArrayDataOutput out = ByteStreams.newDataOutput();
        MerkleTree.serializer.serialize(mt, out, MessagingService.current_version);
        byte[] serialized = out.toByteArray();

        ByteArrayDataInput in = ByteStreams.newDataInput(serialized);
        MerkleTree restored = MerkleTree.serializer.deserialize(in, MessagingService.current_version);

        assertHashEquals(initialhash, restored.hash(full));
View Full Code Here

      mappings.get(i % count).add(inputSplits.get(i));
    }
  }

  public static String serializeInputSplit(InputSplit split) throws IOException {
    ByteArrayDataOutput byteArrayOutputStream =  ByteStreams.newDataOutput();
    split.write(byteArrayOutputStream);
    String encoded = Base64.encodeBase64String(byteArrayOutputStream.toByteArray());
    logger.debug("Encoded split string for split {} : {}", split, encoded);
    return encoded;
  }
View Full Code Here

      mappings.get(i % count).add(inputSplits.get(i));
    }
  }

  public static String serializeInputSplit(InputSplit split) throws IOException {
    ByteArrayDataOutput byteArrayOutputStream =  ByteStreams.newDataOutput();
    split.write(byteArrayOutputStream);
    String encoded = Base64.encodeBase64String(byteArrayOutputStream.toByteArray());
    logger.debug("Encoded split string for split {} : {}", split, encoded);
    return encoded;
  }
View Full Code Here

      mappings.get(i % count).add(inputSplits.get(i));
    }
  }

  public static String serializeInputSplit(InputSplit split) throws IOException {
    ByteArrayDataOutput byteArrayOutputStream =  ByteStreams.newDataOutput();
    split.write(byteArrayOutputStream);
    String encoded = Base64.encodeBase64String(byteArrayOutputStream.toByteArray());
    logger.debug("Encoded split string for split {} : {}", split, encoded);
    return encoded;
  }
View Full Code Here

  public static byte[] getQueueRowPrefix(Scan scan) {
    return scan.getAttribute(ATTR_QUEUE_ROW_PREFIX);
  }

  private static byte[] toBytes(ConsumerConfig consumerConfig) throws IOException {
    ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
    write(dataOutput, consumerConfig);
    return dataOutput.toByteArray();
  }
View Full Code Here

    return new ConsumerConfig(groupId, instanceId, groupSize, strategy, hashKey);
  }

  private static byte[] toBytes(Transaction tx) throws IOException {
    ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
    write(dataOutput, tx);
    return dataOutput.toByteArray();
  }
View Full Code Here

        }

        private void responseSocks4(DataOutputStream output, int status, int port, int address)
                throws IOException
        {
            ByteArrayDataOutput sourceOutput = ByteStreams.newDataOutput();

            // field 1: null byte
            sourceOutput.write(0);

            // field 2: status, 1 byte:
            sourceOutput.write(status);

            // field 3: network byte order port number, 2 bytes
            sourceOutput.writeShort(port);

            // field 4: network byte order IP address, 4 bytes
            sourceOutput.writeInt(address);

            // write all at once to avoid Jetty bug
            // TODO: remove this when fixed in Jetty
            output.write(sourceOutput.toByteArray());
        }
View Full Code Here

        }

        private void responseSocks4(DataOutputStream output, int status, int port, int address)
                throws IOException
        {
            ByteArrayDataOutput sourceOutput = ByteStreams.newDataOutput();

            // field 1: null byte
            sourceOutput.write(0);

            // field 2: status, 1 byte:
            sourceOutput.write(status);

            // field 3: network byte order port number, 2 bytes
            sourceOutput.writeShort(port);

            // field 4: network byte order IP address, 4 bytes
            sourceOutput.writeInt(address);

            // write all at once to avoid Jetty bug
            // TODO: remove this when fixed in Jetty
            output.write(sourceOutput.toByteArray());
        }
View Full Code Here

TOP

Related Classes of com.google.common.io.ByteArrayDataOutput

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.