Dear Wiki user, You have subscribed to a wiki page or wiki category on "Lucene-hadoop Wiki" for change notification.
The following page has been changed by JimKellerman: http://wiki.apache.org/lucene-hadoop/Hbase/HbaseArchitecture The comment on the change is: added client apis ------------------------------------------------------------------------------ * [#ipctabletmaster Tablet Server to Master Messages] * [#clientlib Client Library] * [#api API] + * [#accesscontrol Access Control Entries] + * [#columnmeta Column Metadata] + * [#adminapi Administrative API] + * [#dataapi Client Data Access API] * [#other Other] * [#comments Comments] @@ -510, +514 @@ [[Anchor(api)]] == API == + There are four components to the client API. Two are supporting + classes for access control entries and column metadata and two interfaces: one for administrative functions such as creating tables and columns and one for client access to the data. + + [[Anchor(accesscontrol)]] + === Access Control Entries === {{{ + package org.apache.hbase.client; - CreateTable() - ChangeColumnMetadata(name=ACL, value=foo) - Scanner - FetchColumnMap - Lookup - RowName - ScanStream - SetReturnAllVersions - Next - Done - ColumnName - MicroTimestamp - Value + /** Access Control List Entry (ACE) */ + public class AccessControlEntry { + + public enum Permission { // The kind of access this entry applies to + READ, // read access + WRITE, // write access + CONTROL // control (can change ACL) access + } + + /** Authorized users */ + private String[] authorizedUsers; + + /** Permission granted */ + private Permission permission; + + /** + * Constructs an ACE for the specified permission with an empty user list + * + * @param p - access permission + */ + public AccessControlEntry(Permission p) { + this.permission = p; + this.authorizedUsers = new String[0]; + } + + /** + * Constructs an ACE for the specified permission with the specified users + * + * @param p - access permission + * @param users - user list + */ + public AccessControlEntry(Permission p, String[] users) { + this.permission = p; + this.authorizedUsers = users; + } - WriteStream? - Batch interface - Increment IntegerCounter? + // Accessors + public String[] getUsers() { return this.authorizedUsers; } + public Permission getPermission() { return this.permission; } + + public void setUsers(String[] users) { this.authorizedUsers = users; } + public void setPermission(Permission p) { this.permission = p; } + } + }}} + + [[Anchor(columnmeta)]] + === Column Metadata === + {{{ + package org.apache.hbase.client; + + public class ColumnMetadata { + + /** The kinds of columns */ + public enum ColumnType { + COLUMN, // a 'normal' column - one value per row key + COUNTER, // an integer counter - one value per row key + MAP // a 'map' of key/value pairs for the same row key + } + + /** Garbage collection policies */ + public enum GarbageCollectionPolicy { + LATEST_N_VERSIONS, // keep latest N versions + NEWER_THAN_N_DAYS // keep versions newer than N days old + } + + public static final int DEFAULT_MAX_TABLET_SIZE = 128 * 1024 * 1024; // 128MB + public static final int DEFAULT_BLOCK_SIZE = 64 * 1024 * 1024; // 64MB + public static final int DEFAULT_GC_N = 3; // latest 3 versions or newer than 3 days old + + // Accessor methods + + public ColumnType getColumnType() { return columnType; } + public boolean mapCompressionEnabled() { return mapCompressionEnabled; } + public GarbageCollectionPolicy getGarbageCollectionPolicy() { return gcPolicy; } + public int getGarbageCollectionN() { return gcN; } + public int getMaxTabletSize() { return maxTabletSize; } + public int getBlockSize() { return blockSize; } + public boolean blockCompressionEnabled() { return compressionEnabled; } + public boolean isInMemory() { return inMemory; } + public boolean bloomFilterEnabled() { return bloomFilterEnabled; } + + // Set value methods + + public void setColumnType(ColumnType type) { this.columnType = type; } + public void setMapCompression(boolean compression) { + this.mapCompressionEnabled = compression; + } + public void setGarbageCollection(GarbageCollectionPolicy policy, int n) { + this.gcPolicy = policy; + this.gcN = n; + } + public void setMaxTabletSize(int size) { this.maxTabletSize = size; } + public void setBlockSize(int size) { this.blockSize = size; } + public void setBlockCompression(boolean compression) { + this.compressionEnabled = compression; + } + public void setInMemory(boolean isInMemory) { this.inMemory = isInMemory; } + public void setBloomFilter(boolean bloomFilter) { + this.bloomFilterEnabled = bloomFilter; + } + + /** Constructor. Sets default values */ + public ColumnMetadata() { + this.columnType = ColumnType.COLUMN; + this.mapCompressionEnabled = false; + this.gcPolicy = GarbageCollectionPolicy.LATEST_N_VERSIONS; + this.gcN = DEFAULT_GC_N; + this.maxTabletSize = DEFAULT_MAX_TABLET_SIZE; + this.blockSize = DEFAULT_BLOCK_SIZE; + this.compressionEnabled = false; + this.inMemory = false; + this.bloomFilterEnabled = false; + } + + /** + * Constructor that requires all the settings to be specified + * + * @param type - ColumnType + * @param compressMap - if map, is map compressed + * @param policy - GarbageCollectionPolicy + * @param gcn - The N for garbage collection + * @param tabletSize - Max tablet size + * @param blocksize - Tablet block size + * @param compressBlocks - Enable block compression + * @param isInMemory - Keep tablet in memory + * @param enableBloomFilter - Enable tablet bloom filter + */ + public ColumnMetadata(ColumnType type, + boolean compressMap, + GarbageCollectionPolicy policy, + int gcn, + int tabletSize, + int blocksize, + boolean compressBlocks, + boolean isInMemory, + boolean enableBloomFilter + ) { + this.columnType = type; + this.mapCompressionEnabled = compressMap; + this.gcPolicy = policy; + this.gcN = gcn; + this.maxTabletSize = tabletSize; + this.blockSize = blocksize; + this.inMemory = isInMemory; + this.bloomFilterEnabled = enableBloomFilter; + } + + // Implementation details - how the values are currently stored + + private ColumnType columnType; // The column type + private boolean mapCompressionEnabled; // If map, whether map should be compressed + + private GarbageCollectionPolicy gcPolicy; // Garbage collection policy + private int gcN; // The N for garbage collection + + private int maxTabletSize; // Maximum tablet size + private int blockSize; // Tablet block size + + private boolean compressionEnabled; // block compression setting + private boolean inMemory; // tablet should be kept in memory + private boolean bloomFilterEnabled; // column has a bloom filter + } + }}} + + [[Anchor(adminapi)]] + === Administrative API === + + {{{ + package org.apache.hbase.client; + + import java.util.List; + + /** Interface for Hbase administrative functions */ + public interface HbaseAdministration { + + /** + * Create a Hbase table + * + * @param tableName - name of the table to create + */ + public void createTable(String tableName); + + /** + * Create a column in an Hbase table + * + * @param tableName - name of the table + * @param columnName - name of the column + * @param columnDescription - column description metadata + */ + public void createColumn(String tableName, String columnName, ColumnMetadata columnDescription ); + + /** + * Fetch metadata for a column + * + * @param tableName - name of table + * @param columnName - name of column + * @return - metadata for specified column + */ + public ColumnMetadata getColumnMetadata(String tableName, String columnName); + + /** + * Deletes the specified table + * + * @param tableName - table to be deleted + */ + public void deleteTable(String tableName); + + /** + * Deletes the specified column from the specified table + * + * @param tableName - name of table + * @param columnName - name of column to be deleted + */ + public void deleteColumn(String tableName, String columnName); + + /** + * Set access control for a column + * + * @param tableName - name of table + * @param columnName - name of column + * @param acl - access to set + */ + public void setColumnACE(String tableName, String columnName, AccessControlEntry acl); + + /** + * Set access control list for a column. Specifies more than one kind of access. + * + * @param tableName - name of table + * @param columnName - name of column + * @param acls - List of ACEs to set + */ + public void setColumnACL(String tableName, String columnName, List<AccessControlEntry> acls); + + /** + * Return all the access control entries for the specified column. + * + * @param tableName - name of the table + * @param columnName - name of the column + * @return - List of access control entries for column + */ + public List<AccessControlEntry> getColumnACL(String tableName, String columnName); + } + }}} + + [[Anchor(dataapi)]] + === Client Data Access API === + + {{{ + package org.apache.hbase.client; + + import java.util.Iterator; + import java.util.Map; + + /** General Hbase client API */ + public interface HbaseClient { + + public enum OpenAccess { + READ_ACCESS, + WRITE_ACCESS + } + + /** + * Open a table for read or write access + * + * @param tableName - table to open + * @param access - open access (read or write) + */ + public void openTable(String tableName, OpenAccess access); + + /** + * Get the value of a 'normal' column + * + * @param columnName - name of column + * @param rowKey - select row of column + * @param timestamp - value timestamp (zero for most recent value) + * @return - column value + */ + public byte[] read(String columnName, String rowKey, long timestamp); + + /** + * Get the value of a 'counter' column for the specified row + * + * @param columnName - name of counter column + * @param rowKey - select row of column + * @return - value of counter + */ + public int read(String columnName, String rowKey); + + /** + * Get the value of a map column given the specified row and column keys + * + * @param columnName - name of column + * @param rowKey - select row of column + * @param columnKey - select column map member + * @param timestamp - value timestamp (zero for most recent value) + * @return + */ + public byte[] read(String columnName, String rowKey, String columnKey, long timestamp); + + /** + * Increment the value of a counter column (by one) + * + * @param columnName - name of the column + * @param rowKey - select row of column + */ + public void incrementColumn(String columnName, String rowKey); + + /** + * Increment the value of a counter column (by the specified increment) + * + * @param columnName - name of the column + * @param rowKey - select row of column + * @param increment - amount to increment counter + */ + public void incrementColumn(String columnName, String rowKey, int increment); + + /** + * Write the specified value into the specified column at the specified row + * with the specified timestamp. + * + * @param columnName - name of column + * @param rowKey - select row of column + * @param timestamp - timestamp for value (if zero, current time is used) + * @param value - value to store + */ + public void write(String columnName, String rowKey, long timestamp, byte[] value); + + /** + * Write a single value into the specified map column at the specified row for + * the specified timestamp and specified map key + * + * @param columnName - name of column + * @param rowKey - select row of column + * @param timestamp - timestamp for value (if zero, current time is used) + * @param columnKey - column map key + * @param value - value to associate with column map key. + */ + public void write(String columnName, String rowKey, long timestamp, String columnKey, byte[] value); + + /** + * Write the specified key/value map to the specified column in the specified + * row for the specified timestamp + * + * @param columnName - name of column + * @param rowKey - select row of column + * @param timestamp - timestamp for value (if zero, current time is used) + * @param value - Map of key/value pairs to store + */ + public void write(String columnName, String rowKey, long timestamp, Map<String, byte[]> value); + + /** + * Delete the value in the specified row of the specified column for the specified + * timestamp. (Note: for map columns, deletes all the values for the specified + * row key and timestamp) + * + * @param columnName - name of column + * @param rowKey - select row of column + * @param timestamp - timestamp of value (if zero, most recent value is deleted. + * if -1, oldest value is deleted) + */ + public void delete(String columnName, String rowKey, long timestamp); + + /** + * Delete the value associated with the specified map key in the specified row + * of the specified column for the specified timestamp. + * + * @param columnName - name of column + * @param rowKey - select row of column + * @param timestamp - timestamp of value (if zero, most recent value is deleted. + * if -1, oldest value is deleted) + * @param columnKey - column map key of value to be deleted + */ + public void delete(String columnName, String rowKey, long timestamp, String columnKey); + + public abstract interface HbaseIterator extends Iterator, Iterable { + + /** + * @return - current row key + */ + public String getRowKey(); + + /** + * @return - timestamp of current value + */ + public int getTimestamp(); + + } + + /** iterate over a 'normal' column */ + public interface columnIterator extends HbaseIterator { + /** + * Get an iterator for the specified normal column + * + * @param columnName - name of column + * @param rowKey - starting row key (if null, start at beginning of table) + * @param timestamp - timestamp of value (if zero, return most recent version, + * if -1, return all versions) + * @return - iterator object + */ + public columnIterator getIterator(String columnName, String rowKey, long timestamp); + + /** + * @return - current value + */ + public byte[] getValue(); + } + + /** iterate over a 'counter' column */ + public interface counterIterator extends HbaseIterator { + /** + * Get an iterator for the specified counter column + * + * @param columnName - name of column + * @param rowKey - starting row key (if null, start at beginning of table) + * @param timestamp - timestamp of value (if zero, return most recent version, + * if -1, return all versions) + * @return - iterator object + */ + public counterIterator getIterator(String columnName, String rowKey, long timestamp); + + /** + * @return - current value + */ + public int getValue(); + } + + public interface mapIterator extends HbaseIterator { + + /** + * Get an iterator for the specified map column + * + * @param columnName - name of column + * @param rowKey - starting row key (if null, start at beginning of table) + * @param timestamp - timestamp of value (if zero, return most recent version, + * if -1, return all versions) + * @return - iterator object + */ + public mapIterator getIterator(String columnName, String rowKey, long timestamp); + + /** + * Get an iterator for all values for a particular row key + * + * @return - iterator object + */ + public Iterator<Map<String, byte[]>> getValueIterator(); + } + } }}} [[Anchor(other)]]