org.apache.hadoop.hbase
Class HColumnDescriptor

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

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

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
          Deprecated. Compression now means which compression library rather than 'what' to compress.
 
Field Summary
static String BLOCKCACHE
           
static String BLOCKSIZE
          Size of storefile/hfile 'blocks'.
static String BLOOMFILTER
           
static String COMPRESSION
           
static String COMPRESSION_COMPACT
           
static boolean DEFAULT_BLOCKCACHE
          Default setting for whether to use a block cache or not.
static int DEFAULT_BLOCKSIZE
          Default size of blocks in files stored to the filesytem (hfiles).
static String DEFAULT_BLOOMFILTER
          Default setting for whether or not to use bloomfilters.
static String DEFAULT_COMPRESSION
          Default compression type.
static boolean DEFAULT_IN_MEMORY
          Default setting for whether to serve from memory or not.
static int DEFAULT_REPLICATION_SCOPE
          Default scope.
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 REPLICATION_SCOPE
           
static String TTL
           
protected  Map<ImmutableBytesWritable,ImmutableBytesWritable> values
           
 
Constructor Summary
HColumnDescriptor()
          Default constructor.
HColumnDescriptor(byte[] familyName)
          Construct a column descriptor specifying only the family name The other attributes are defaulted.
HColumnDescriptor(byte[] familyName, int maxVersions, String compression, boolean inMemory, boolean blockCacheEnabled, int blocksize, int timeToLive, String bloomFilter, int scope)
          Constructor
HColumnDescriptor(byte[] familyName, int maxVersions, String compression, boolean inMemory, boolean blockCacheEnabled, int timeToLive, String bloomFilter)
          Constructor
HColumnDescriptor(HColumnDescriptor desc)
          Constructor.
HColumnDescriptor(String familyName)
          Construct a column descriptor specifying only the family name The other attributes are defaulted.
 
Method Summary
 int compareTo(HColumnDescriptor o)
           
 boolean equals(Object obj)
           
 int getBlocksize()
           
 StoreFile.BloomType getBloomFilterType()
           
 Compression.Algorithm getCompactionCompression()
           
 Compression.Algorithm getCompactionCompressionType()
           
 Compression.Algorithm getCompression()
           
 Compression.Algorithm getCompressionType()
           
 int getMaxVersions()
           
 byte[] getName()
           
 String getNameAsString()
           
 int getScope()
           
 int getTimeToLive()
           
 byte[] getValue(byte[] key)
           
 String getValue(String key)
           
 Map<ImmutableBytesWritable,ImmutableBytesWritable> getValues()
           
 int hashCode()
           
 boolean isBlockCacheEnabled()
           
 boolean isInMemory()
           
static byte[] isLegalFamilyName(byte[] b)
           
 void readFields(DataInput in)
           
 void remove(byte[] key)
           
 void setBlockCacheEnabled(boolean blockCacheEnabled)
           
 void setBlocksize(int s)
           
 void setBloomFilterType(StoreFile.BloomType bt)
           
 void setCompactionCompressionType(Compression.Algorithm type)
          Compression types supported in hbase.
 void setCompressionType(Compression.Algorithm type)
          Compression types supported in hbase.
 void setInMemory(boolean inMemory)
           
 void setMaxVersions(int maxVersions)
           
 void setScope(int scope)
           
 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

COMPRESSION_COMPACT

public static final String COMPRESSION_COMPACT
See Also:
Constant Field Values

BLOCKCACHE

public static final String BLOCKCACHE
See Also:
Constant Field Values

BLOCKSIZE

public static final String BLOCKSIZE
Size of storefile/hfile 'blocks'. Default is DEFAULT_BLOCKSIZE. Use smaller block sizes for faster random-access at expense of larger indices (more memory consumption).

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

REPLICATION_SCOPE

public static final String REPLICATION_SCOPE
See Also:
Constant Field Values

DEFAULT_COMPRESSION

public static final String 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_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_BLOCKSIZE

public static final int DEFAULT_BLOCKSIZE
Default size of blocks in files stored to the filesytem (hfiles).

See Also:
Constant Field Values

DEFAULT_BLOOMFILTER

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


DEFAULT_TTL

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

See Also:
Constant Field Values

DEFAULT_REPLICATION_SCOPE

public static final int DEFAULT_REPLICATION_SCOPE
Default scope.

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 familyName)
Construct a column descriptor specifying only the family name The other attributes are defaulted.

Parameters:
familyName - Column family name. Must be 'printable' -- digit or letter -- and may not contain a :

HColumnDescriptor

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

Parameters:
familyName - Column family name. Must be 'printable' -- digit or letter -- and may not contain a :

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[] familyName,
                         int maxVersions,
                         String compression,
                         boolean inMemory,
                         boolean blockCacheEnabled,
                         int timeToLive,
                         String bloomFilter)
Constructor

Parameters:
familyName - Column family name. Must be 'printable' -- digit or letter -- and may not contain a :
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
timeToLive - Time-to-live of cell contents, in seconds (use HConstants.FOREVER for unlimited TTL)
bloomFilter - Bloom filter type 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] or contains a :
IllegalArgumentException - if the number of versions is <= 0

HColumnDescriptor

public HColumnDescriptor(byte[] familyName,
                         int maxVersions,
                         String compression,
                         boolean inMemory,
                         boolean blockCacheEnabled,
                         int blocksize,
                         int timeToLive,
                         String bloomFilter,
                         int scope)
Constructor

Parameters:
familyName - Column family name. Must be 'printable' -- digit or letter -- and may not contain a :
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
blocksize - Block size to use when writing out storefiles. Use smaller blocksizes for faster random-access at expense of larger indices (more memory consumption). Default is usually 64k.
timeToLive - Time-to-live of cell contents, in seconds (use HConstants.FOREVER for unlimited TTL)
bloomFilter - Bloom filter type for this column
scope - The scope tag 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] or contains 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). Cannot start with a '.' either.

getName

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

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.

getValues

public Map<ImmutableBytesWritable,ImmutableBytesWritable> getValues()
Returns:
All values.

setValue

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

remove

public void remove(byte[] key)
Parameters:
key - Key whose key and value we're to remove from HCD parameters.

setValue

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

getCompression

public Compression.Algorithm getCompression()
Returns:
compression type being used for the column family

getCompactionCompression

public Compression.Algorithm getCompactionCompression()
Returns:
compression type being used for the column family for major compression

getMaxVersions

public int getMaxVersions()
Returns:
maximum number of versions

setMaxVersions

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

getBlocksize

public int getBlocksize()
Returns:
The storefile/hfile blocksize for this column family.

setBlocksize

public void setBlocksize(int s)
Parameters:
s - Blocksize to use when writing out storefiles/hfiles on this column family.

getCompressionType

public Compression.Algorithm getCompressionType()
Returns:
Compression type setting.

setCompressionType

public void setCompressionType(Compression.Algorithm type)
Compression types supported in hbase. LZO is not bundled as part of the hbase distribution. See LZO Compression for how to enable it.

Parameters:
type - Compression type setting.

getCompactionCompressionType

public Compression.Algorithm getCompactionCompressionType()
Returns:
Compression type setting.

setCompactionCompressionType

public void setCompactionCompressionType(Compression.Algorithm type)
Compression types supported in hbase. LZO is not bundled as part of the hbase distribution. See LZO Compression for how to enable it.

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

getTimeToLive

public int getTimeToLive()
Returns:
Time-to-live of cell contents, in seconds.

setTimeToLive

public void setTimeToLive(int timeToLive)
Parameters:
timeToLive - Time-to-live of cell contents, in seconds.

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.

getBloomFilterType

public StoreFile.BloomType getBloomFilterType()
Returns:
bloom filter type used for new StoreFiles in ColumnFamily

setBloomFilterType

public void setBloomFilterType(StoreFile.BloomType bt)
Parameters:
bt - bloom filter type

getScope

public int getScope()
Returns:
the scope tag

setScope

public void setScope(int scope)
Parameters:
scope - the scope tag

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

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(HColumnDescriptor o)
Specified by:
compareTo in interface Comparable<HColumnDescriptor>


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.