Java Code Examples for org.apache.hadoop.io.BytesWritable#get()

The following examples show how to use org.apache.hadoop.io.BytesWritable#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BCFile.java    From RDFS with Apache License 2.0 6 votes vote down vote up
/**
 * @param compressionAlgo
 *          The compression algorithm to be used to for compression.
 * @throws IOException
 */
public WBlockState(Algorithm compressionAlgo, FSDataOutputStream fsOut,
    BytesWritable fsOutputBuffer, Configuration conf) throws IOException {
  this.compressAlgo = compressionAlgo;
  this.fsOut = fsOut;
  this.posStart = fsOut.getPos();

  fsOutputBuffer.setCapacity(TFile.getFSOutputBufferSize(conf));

  this.fsBufferedOutput =
      new SimpleBufferedOutputStream(this.fsOut, fsOutputBuffer.get());
  this.compressor = compressAlgo.getCompressor();

  try {
    this.out =
        compressionAlgo.createCompressionStream(fsBufferedOutput,
            compressor, 0);
  } catch (IOException e) {
    compressAlgo.returnCompressor(compressor);
    throw e;
  }
}
 
Example 2
Source File: AlignmentRecord.java    From emr-sample-apps with Apache License 2.0 6 votes vote down vote up
public void fromBytes(BytesWritable t)
{
	byte [] raw = t.get();
	
	m_isRC   = raw[0] == 1;
	
	m_refID = (raw[1] & 0xFF) << 24 
	        | (raw[2] & 0xFF) << 16
	        | (raw[3] & 0xFF) << 8
	        | (raw[4] & 0xFF);
	
	m_refStart = (raw[5] & 0xFF) << 24 
	           | (raw[6] & 0xFF) << 16
	           | (raw[7] & 0xFF) << 8
	           | (raw[8] & 0xFF);
	
	m_refEnd = (raw[9] & 0xFF) << 24 
	         | (raw[10] & 0xFF) << 16
	         | (raw[11] & 0xFF) << 8
	         | (raw[12] & 0xFF);
	
	m_differences = (raw[13] & 0xFF) << 24 
	              | (raw[14] & 0xFF) << 16
	              | (raw[15] & 0xFF) << 8
	              | (raw[16] & 0xFF);
}
 
Example 3
Source File: BCFile.java    From hadoop-gpu with Apache License 2.0 6 votes vote down vote up
/**
 * @param compressionAlgo
 *          The compression algorithm to be used to for compression.
 * @throws IOException
 */
public WBlockState(Algorithm compressionAlgo, FSDataOutputStream fsOut,
    BytesWritable fsOutputBuffer, Configuration conf) throws IOException {
  this.compressAlgo = compressionAlgo;
  this.fsOut = fsOut;
  this.posStart = fsOut.getPos();

  fsOutputBuffer.setCapacity(TFile.getFSOutputBufferSize(conf));

  this.fsBufferedOutput =
      new SimpleBufferedOutputStream(this.fsOut, fsOutputBuffer.get());
  this.compressor = compressAlgo.getCompressor();

  try {
    this.out =
        compressionAlgo.createCompressionStream(fsBufferedOutput,
            compressor, 0);
  } catch (IOException e) {
    compressAlgo.returnCompressor(compressor);
    throw e;
  }
}
 
Example 4
Source File: KeySampler.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public void next(BytesWritable key) {
  key.setSize(Math.max(MIN_KEY_LEN, keyLenRNG.nextInt()));
  random.nextBytes(key.get());
  int n = random.nextInt(max - min) + min;
  byte[] b = key.get();
  b[0] = (byte) (n >> 24);
  b[1] = (byte) (n >> 16);
  b[2] = (byte) (n >> 8);
  b[3] = (byte) n;
}
 
Example 5
Source File: KeySampler.java    From big-c with Apache License 2.0 5 votes vote down vote up
public void next(BytesWritable key) {
  key.setSize(Math.max(MIN_KEY_LEN, keyLenRNG.nextInt()));
  random.nextBytes(key.get());
  int n = random.nextInt(max - min) + min;
  byte[] b = key.get();
  b[0] = (byte) (n >> 24);
  b[1] = (byte) (n >> 16);
  b[2] = (byte) (n >> 8);
  b[3] = (byte) n;
}
 
Example 6
Source File: KeySampler.java    From hbase with Apache License 2.0 5 votes vote down vote up
public void next(BytesWritable key) {
  key.setSize(Math.max(MIN_KEY_LEN, keyLenRNG.nextInt()));
  random.nextBytes(key.get());
  int rnd = 0;
  if (max != min) {
    rnd = random.nextInt(max - min);
  }
  int n = rnd + min;
  byte[] b = key.get();
  b[0] = (byte) (n >> 24);
  b[1] = (byte) (n >> 16);
  b[2] = (byte) (n >> 8);
  b[3] = (byte) n;
}
 
Example 7
Source File: KeySampler.java    From RDFS with Apache License 2.0 5 votes vote down vote up
public void next(BytesWritable key) {
  key.setSize(Math.max(MIN_KEY_LEN, keyLenRNG.nextInt()));
  random.nextBytes(key.get());
  int n = random.nextInt(max - min) + min;
  byte[] b = key.get();
  b[0] = (byte) (n >> 24);
  b[1] = (byte) (n >> 16);
  b[2] = (byte) (n >> 8);
  b[3] = (byte) n;
}
 
Example 8
Source File: MerRecord.java    From emr-sample-apps with Apache License 2.0 5 votes vote down vote up
public void fromBytes(BytesWritable t)
{
	byte [] raw = t.get();
	int rawlen = t.getSize();
	
	//sbuffer[0] = (byte) ((isReference ? 0x01 : 0x00) | (isRC ? 0x10 : 0x00));
	
	isReference = (raw[0] & 0x01) == 0x01;
	isRC        = (raw[0] & 0x10) == 0x10;
	
	offset = (raw[1] & 0xFF) << 24 
	       | (raw[2] & 0xFF) << 16
	       | (raw[3] & 0xFF) << 8
	       | (raw[4] & 0xFF);
	
	id = (raw[5] & 0xFF) << 24 
          | (raw[6] & 0xFF) << 16
          | (raw[7] & 0xFF) << 8
          | (raw[8] & 0xFF);

	int fieldstart = 9;
	
	for (int i = fieldstart; i < rawlen; i++)
	{
		if (raw[i] == DNAString.hardstop)
		{
			//leftFlank = DNAString.dnaToArr(raw, fieldstart, i-fieldstart);
			leftFlank = new byte[i-fieldstart];
			System.arraycopy(raw, fieldstart, leftFlank, 0, i-fieldstart);
			
			fieldstart = i+1; // skip the hardstop
			break;
		}
	}
	
	rightFlank = new byte[rawlen - fieldstart];
	System.arraycopy(raw, fieldstart, rightFlank, 0, rawlen-fieldstart);
	//rightFlank = DNAString.dnaToArr(raw, fieldstart, rawlen-fieldstart);
}
 
Example 9
Source File: FastaRecord.java    From emr-sample-apps with Apache License 2.0 5 votes vote down vote up
public void fromBytes(BytesWritable t)
{
	byte [] raw = t.get();
	int rawlen = t.getSize();
	
	m_lastChunk   = raw[0] == 1;
	
	m_offset =   (raw[1] & 0xFF) << 24 
	           | (raw[2] & 0xFF) << 16
	           | (raw[3] & 0xFF) << 8
	           | (raw[4] & 0xFF);
	
	int sl = rawlen - 5;
	m_sequence = DNAString.dnaToArr(raw, 5, sl);
}
 
Example 10
Source File: KeySampler.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
public void next(BytesWritable key) {
  key.setSize(Math.max(MIN_KEY_LEN, keyLenRNG.nextInt()));
  random.nextBytes(key.get());
  int n = random.nextInt(max - min) + min;
  byte[] b = key.get();
  b[0] = (byte) (n >> 24);
  b[1] = (byte) (n >> 16);
  b[2] = (byte) (n >> 8);
  b[3] = (byte) n;
}
 
Example 11
Source File: ByteArray.java    From RDFS with Apache License 2.0 2 votes vote down vote up
/**
 * Constructing a ByteArray from a {@link BytesWritable}.
 * 
 * @param other
 */
public ByteArray(BytesWritable other) {
  this(other.get(), 0, other.getSize());
}
 
Example 12
Source File: ByteArray.java    From hadoop-gpu with Apache License 2.0 2 votes vote down vote up
/**
 * Constructing a ByteArray from a {@link BytesWritable}.
 * 
 * @param other
 */
public ByteArray(BytesWritable other) {
  this(other.get(), 0, other.getSize());
}