org.apache.hadoop.hbase
Class HColumnDescriptor

java.lang.Object
  extended by org.apache.hadoop.hbase.HColumnDescriptor
All Implemented Interfaces:
Comparable, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable
Direct Known Subclasses:
UnmodifyableHColumnDescriptor

public class HColumnDescriptor
extends Object
implements org.apache.hadoop.io.WritableComparable

An HColumnDescriptor contains information about a column family such as the number of versions, compression settings, etc. It is used as input when creating a table or adding a column. Once set, the parameters that specify a column cannot be changed without deleting the column and recreating it. If there is data stored in the column, it will be deleted when the column is deleted.


Nested Class Summary
static class HColumnDescriptor.CompressionType
          The type of compression.
 
Field Summary
static String BLOCKCACHE
           
static String BLOOMFILTER
           
static String COMPRESSION
           
static boolean DEFAULT_BLOCKCACHE
          Default setting for whether to use a block cache or not.
static boolean DEFAULT_BLOOMFILTER
          Default setting for whether or not to use bloomfilters.
static HColumnDescriptor.CompressionType DEFAULT_COMPRESSION
          Default compression type.
static boolean DEFAULT_IN_MEMORY
          Default setting for whether to serve from memory or not.
static int DEFAULT_LENGTH
          Default maximum cell length.
static int DEFAULT_MAPFILE_INDEX_INTERVAL
          Default mapfile index interval.
static int DEFAULT_TTL
          Default time to live of cell contents.
static int DEFAULT_VERSIONS
          Default number of versions of a record to keep.
static String FOREVER
           
static String LENGTH
           
static String MAPFILE_INDEX_INTERVAL
           
static String TTL
           
protected  Map<ImmutableBytesWritable,ImmutableBytesWritable> values
           
 
Constructor Summary
HColumnDescriptor()
          Default constructor.
HColumnDescriptor(byte[] columnName)
          Construct a column descriptor specifying only the family name The other attributes are defaulted.
HColumnDescriptor(byte[] columnName, int maxVersions, HColumnDescriptor.CompressionType compression, boolean inMemory, boolean blockCacheEnabled, int maxValueLength, int timeToLive, boolean bloomFilter)
          Constructor
HColumnDescriptor(HColumnDescriptor desc)
          Constructor.
HColumnDescriptor(String columnName)
          Construct a column descriptor specifying only the family name The other attributes are defaulted.
HColumnDescriptor(org.apache.hadoop.io.Text columnName)
          Construct a column descriptor specifying only the family name The other attributes are defaulted.
 
Method Summary
 int compareTo(Object o)
          
 boolean equals(Object obj)
          
 HColumnDescriptor.CompressionType getCompression()
           
 HColumnDescriptor.CompressionType getCompressionType()
           
 int getMapFileIndexInterval()
           
 int getMaxValueLength()
           
 int getMaxVersions()
           
 byte[] getName()
           
 String getNameAsString()
           
 byte[] getNameWithColon()
           
 int getTimeToLive()
           
 byte[] getValue(byte[] key)
           
 String getValue(String key)
           
 int hashCode()
          
 boolean isBlockCacheEnabled()
           
 boolean isBloomfilter()
           
 boolean isInMemory()
           
static byte[] isLegalFamilyName(byte[] b)
           
 void readFields(DataInput in)
          
 void setBlockCacheEnabled(boolean blockCacheEnabled)
           
 void setBloomfilter(boolean onOff)
           
 void setCompressionType(HColumnDescriptor.CompressionType type)
           
 void setInMemory(boolean inMemory)
           
 void setMapFileIndexInterval(int interval)
           
 void setMaxValueLength(int maxLength)
           
 void setMaxVersions(int maxVersions)
           
 void setTimeToLive(int timeToLive)
           
 void setValue(byte[] key, byte[] value)
           
 void setValue(String key, String value)
           
 String toString()
          
 void write(DataOutput out)
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPRESSION

public static final String COMPRESSION
See Also:
Constant Field Values

BLOCKCACHE

public static final String BLOCKCACHE
See Also:
Constant Field Values

LENGTH

public static final String LENGTH
See Also:
Constant Field Values

TTL

public static final String TTL
See Also:
Constant Field Values

BLOOMFILTER

public static final String BLOOMFILTER
See Also:
Constant Field Values

FOREVER

public static final String FOREVER
See Also:
Constant Field Values

MAPFILE_INDEX_INTERVAL

public static final String MAPFILE_INDEX_INTERVAL
See Also:
Constant Field Values

DEFAULT_COMPRESSION

public static final HColumnDescriptor.CompressionType DEFAULT_COMPRESSION
Default compression type.


DEFAULT_VERSIONS

public static final int DEFAULT_VERSIONS
Default number of versions of a record to keep.

See Also:
Constant Field Values

DEFAULT_LENGTH

public static final int DEFAULT_LENGTH
Default maximum cell length.

See Also:
Constant Field Values

DEFAULT_IN_MEMORY

public static final boolean DEFAULT_IN_MEMORY
Default setting for whether to serve from memory or not.

See Also:
Constant Field Values

DEFAULT_BLOCKCACHE

public static final boolean DEFAULT_BLOCKCACHE
Default setting for whether to use a block cache or not.

See Also:
Constant Field Values

DEFAULT_BLOOMFILTER

public static final boolean DEFAULT_BLOOMFILTER
Default setting for whether or not to use bloomfilters.

See Also:
Constant Field Values

DEFAULT_TTL

public static final int DEFAULT_TTL
Default time to live of cell contents.

See Also:
Constant Field Values

DEFAULT_MAPFILE_INDEX_INTERVAL

public static final int DEFAULT_MAPFILE_INDEX_INTERVAL
Default mapfile index interval.

See Also:
Constant Field Values

values

protected Map<ImmutableBytesWritable,ImmutableBytesWritable> values
Constructor Detail

HColumnDescriptor

public HColumnDescriptor()
Default constructor. Must be present for Writable.


HColumnDescriptor

public HColumnDescriptor(String columnName)
Construct a column descriptor specifying only the family name The other attributes are defaulted.

Parameters:
columnName - - column family name

HColumnDescriptor

public HColumnDescriptor(org.apache.hadoop.io.Text columnName)
Construct a column descriptor specifying only the family name The other attributes are defaulted.

Parameters:
columnName - - column family name

HColumnDescriptor

public HColumnDescriptor(byte[] columnName)
Construct a column descriptor specifying only the family name The other attributes are defaulted.

Parameters:
columnName - Column family name. Must have the ':' ending.

HColumnDescriptor

public HColumnDescriptor(HColumnDescriptor desc)
Constructor. Makes a deep copy of the supplied descriptor. Can make a modifiable descriptor from an UnmodifyableHColumnDescriptor.

Parameters:
desc - The descriptor.

HColumnDescriptor

public HColumnDescriptor(byte[] columnName,
                         int maxVersions,
                         HColumnDescriptor.CompressionType compression,
                         boolean inMemory,
                         boolean blockCacheEnabled,
                         int maxValueLength,
                         int timeToLive,
                         boolean bloomFilter)
Constructor

Parameters:
columnName - Column family name. Must have the ':' ending.
maxVersions - Maximum number of versions to keep
compression - Compression type
inMemory - If true, column data should be kept in an HRegionServer's cache
blockCacheEnabled - If true, MapFile blocks should be cached
maxValueLength - Restrict values to <= this value
timeToLive - Time-to-live of cell contents, in seconds from last timestamp (use HConstants.FOREVER for unlimited TTL)
bloomFilter - Enable the specified bloom filter for this column
Throws:
IllegalArgumentException - if passed a family name that is made of other than 'word' characters: i.e. [a-zA-Z_0-9] and does not end in a :
IllegalArgumentException - if the number of versions is <= 0
Method Detail

isLegalFamilyName

public static byte[] isLegalFamilyName(byte[] b)
Parameters:
b - Family name.
Returns:
b
Throws:
IllegalArgumentException - If not null and not a legitimate family name: i.e. 'printable' and ends in a ':' (Null passes are allowed because b can be null when deserializing).

getName

public byte[] getName()
Returns:
Name of this column family

getNameWithColon

public byte[] getNameWithColon()
Returns:
Name of this column family with colon as required by client API

getNameAsString

public String getNameAsString()
Returns:
Name of this column family

getValue

public byte[] getValue(byte[] key)
Parameters:
key - The key.
Returns:
The value.

getValue

public String getValue(String key)
Parameters:
key - The key.
Returns:
The value as a string.

setValue

public void setValue(byte[] key,
                     byte[] value)
Parameters:
key - The key.
value - The value.

setValue

public void setValue(String key,
                     String value)
Parameters:
key - The key.
value - The value.

getCompression

public HColumnDescriptor.CompressionType getCompression()
Returns:
compression type being used for the column family

getMaxVersions

public int getMaxVersions()
Returns:
maximum number of versions

setMaxVersions

public void setMaxVersions(int maxVersions)
Parameters:
maxVersions - maximum number of versions

getCompressionType

public HColumnDescriptor.CompressionType getCompressionType()
Returns:
Compression type setting.

setCompressionType

public void setCompressionType(HColumnDescriptor.CompressionType type)
Parameters:
type - Compression type setting.

isInMemory

public boolean isInMemory()
Returns:
True if we are to keep all in use HRegionServer cache.

setInMemory

public void setInMemory(boolean inMemory)
Parameters:
inMemory - True if we are to keep all values in the HRegionServer cache

getMaxValueLength

public int getMaxValueLength()
Returns:
Maximum value length.

setMaxValueLength

public void setMaxValueLength(int maxLength)
Parameters:
maxLength - Maximum value length.

getTimeToLive

public int getTimeToLive()
Returns:
Time to live.

setTimeToLive

public void setTimeToLive(int timeToLive)
Parameters:
timeToLive -

isBlockCacheEnabled

public boolean isBlockCacheEnabled()
Returns:
True if MapFile blocks should be cached.

setBlockCacheEnabled

public void setBlockCacheEnabled(boolean blockCacheEnabled)
Parameters:
blockCacheEnabled - True if MapFile blocks should be cached.

isBloomfilter

public boolean isBloomfilter()
Returns:
true if a bloom filter is enabled

setBloomfilter

public void setBloomfilter(boolean onOff)
Parameters:
onOff - Enable/Disable bloom filter

getMapFileIndexInterval

public int getMapFileIndexInterval()
Returns:
The number of entries that are added to the store MapFile before an index entry is added.

setMapFileIndexInterval

public void setMapFileIndexInterval(int interval)
Parameters:
interval - The number of entries that are added to the store MapFile before an index entry is added.

toString

public String toString()

Overrides:
toString in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

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

compareTo

public int compareTo(Object o)

Specified by:
compareTo in interface Comparable


Copyright © 2008 The Apache Software Foundation