org.apache.hadoop.hive.serde2.columnar
Class BytesRefArrayWritable

java.lang.Object
  extended by org.apache.hadoop.hive.serde2.columnar.BytesRefArrayWritable
All Implemented Interfaces:
Comparable<BytesRefArrayWritable>, org.apache.hadoop.io.Writable

public class BytesRefArrayWritable
extends Object
implements org.apache.hadoop.io.Writable, Comparable<BytesRefArrayWritable>

BytesRefArrayWritable holds an array reference to BytesRefWritable, and is able to resize without recreating new array if not necessary.

Each BytesRefArrayWritable holds instance has a valid field, which is the desired valid number of BytesRefWritable it holds. resetValid can reset the valid, but it will not care the underlying BytesRefWritable.


Constructor Summary
BytesRefArrayWritable()
          Constructs an empty array with a capacity of ten.
BytesRefArrayWritable(int capacity)
          Constructs an empty array with the specified capacity.
 
Method Summary
 void clear()
          Removes all elements.
 int compareTo(BytesRefArrayWritable other)
          
 boolean contains(BytesRefWritable bytesRefWritable)
          Returns true if this instance contains one or more the specified BytesRefWritable.
protected  void ensureCapacity(int newCapacity)
           
 boolean equals(Object o)
          
 BytesRefWritable get(int index)
          Gets the BytesRefWritable at the specified position.
 void readFields(DataInput in)
          
 void resetValid(int newValidCapacity)
          enlarge the capacity if necessary, to ensure that it can hold the number of elements specified by newValidCapacity argument.
 void set(int index, BytesRefWritable bytesRefWritable)
          Set the BytesRefWritable at the specified position with the specified BytesRefWritable.
 int size()
          Returns the number of valid elements.
 BytesRefWritable unCheckedGet(int index)
          Gets the BytesRefWritable at the specified position without checking.
 void write(DataOutput out)
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BytesRefArrayWritable

public BytesRefArrayWritable(int capacity)
Constructs an empty array with the specified capacity.

Parameters:
capacity - initial capacity
Throws:
IllegalArgumentException - if the specified initial capacity is negative

BytesRefArrayWritable

public BytesRefArrayWritable()
Constructs an empty array with a capacity of ten.

Method Detail

size

public int size()
Returns the number of valid elements.

Returns:
the number of valid elements

get

public BytesRefWritable get(int index)
Gets the BytesRefWritable at the specified position. Make sure the position is valid by first call resetValid.

Parameters:
index - the position index, starting from zero
Throws:
IndexOutOfBoundsException

unCheckedGet

public BytesRefWritable unCheckedGet(int index)
Gets the BytesRefWritable at the specified position without checking.

Parameters:
index - the position index, starting from zero
Throws:
IndexOutOfBoundsException

set

public void set(int index,
                BytesRefWritable bytesRefWritable)
Set the BytesRefWritable at the specified position with the specified BytesRefWritable.

Parameters:
index - index position
bytesRefWritable - the new element
Throws:
IllegalArgumentException - if the specified new element is null

compareTo

public int compareTo(BytesRefArrayWritable other)

Specified by:
compareTo in interface Comparable<BytesRefArrayWritable>

contains

public boolean contains(BytesRefWritable bytesRefWritable)
Returns true if this instance contains one or more the specified BytesRefWritable.

Parameters:
bytesRefWritable - BytesRefWritable element to be tested
Returns:
true if contains the specified element
Throws:
IllegalArgumentException - if the specified element is null

equals

public boolean equals(Object o)

Overrides:
equals in class Object

clear

public void clear()
Removes all elements.


resetValid

public void resetValid(int newValidCapacity)
enlarge the capacity if necessary, to ensure that it can hold the number of elements specified by newValidCapacity argument. It will also narrow the valid capacity when needed. Notice: it only enlarge or narrow the valid capacity with no care of the already stored invalid BytesRefWritable.

Parameters:
newValidCapacity - the desired capacity

ensureCapacity

protected void ensureCapacity(int newCapacity)

readFields

public void readFields(DataInput in)
                throws IOException

Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException

Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException


Copyright © 2013 The Apache Software Foundation