You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2008/11/19 01:43:02 UTC
svn commit: r718820 - in /hadoop/hbase/trunk/src:
java/org/apache/hadoop/hbase/
java/org/apache/hadoop/hbase/client/tableindexed/
test/org/apache/hadoop/hbase/client/tableindexed/
Author: apurtell
Date: Tue Nov 18 16:43:01 2008
New Revision: 718820
URL: http://svn.apache.org/viewvc?rev=718820&view=rev
Log:
HBASE-883 Secondary indexes; fixes
Modified:
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexNotFoundException.java
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexSpecification.java
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexedTableAdmin.java
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/package.html
hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/tableindexed/TestIndexedTable.java
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java?rev=718820&r1=718819&r2=718820&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java Tue Nov 18 16:43:01 2008
@@ -69,8 +69,6 @@
new ImmutableBytesWritable(Bytes.toBytes(IS_ROOT));
public static final String IS_META = "IS_META";
- public static final String ROW_KEY_COMPARATOR = "ROW_KEY_COMPARATOR";
-
public static final ImmutableBytesWritable IS_META_KEY =
new ImmutableBytesWritable(Bytes.toBytes(IS_META));
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexNotFoundException.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexNotFoundException.java?rev=718820&r1=718819&r2=718820&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexNotFoundException.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexNotFoundException.java Tue Nov 18 16:43:01 2008
@@ -26,6 +26,8 @@
*/
public class IndexNotFoundException extends IOException {
+ private static final long serialVersionUID = 6533971528557000965L;
+
public IndexNotFoundException() {
super();
}
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexSpecification.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexSpecification.java?rev=718820&r1=718819&r2=718820&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexSpecification.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexSpecification.java Tue Nov 18 16:43:01 2008
@@ -24,11 +24,9 @@
import java.io.IOException;
import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.WritableComparator;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.ObjectWritable;
import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
/** Holds the specification for a single secondary index. */
public class IndexSpecification implements Writable {
@@ -39,8 +37,6 @@
// Constructs the
private IndexKeyGenerator keyGenerator;
- private WritableComparator<byte[]> keyComparator;
-
// Additional columns mapped into the indexed row. These will be available for
// filters when scanning the index.
private byte[][] additionalColumns;
@@ -51,11 +47,9 @@
private String indexId;
/** Construct an "simple" index spec for a single column. */
- public IndexSpecification(String indexId, byte[] indexedColumn,
- boolean acending) {
+ public IndexSpecification(String indexId, byte[] indexedColumn) {
this(indexId, new byte[][] { indexedColumn }, null,
- new SimpleIndexKeyGenerator(indexedColumn), acending == true ? null
- : new ReverseByteArrayComparator());
+ new SimpleIndexKeyGenerator(indexedColumn));
}
/**
@@ -68,13 +62,11 @@
* @param keyComparator
*/
public IndexSpecification(String indexId, byte[][] indexedColumns,
- byte[][] additionalColumns, IndexKeyGenerator keyGenerator,
- WritableComparator<byte[]> keyComparator) {
+ byte[][] additionalColumns, IndexKeyGenerator keyGenerator) {
this.indexId = indexId;
this.indexedColumns = indexedColumns;
this.additionalColumns = additionalColumns;
this.keyGenerator = keyGenerator;
- this.keyComparator = keyComparator;
this.makeAllColumns();
}
@@ -111,15 +103,6 @@
}
/**
- * Get the keyComparator.
- *
- * @return Return the keyComparator.
- */
- public WritableComparator<byte[]> getKeyComparator() {
- return keyComparator;
- }
-
- /**
* Get the additionalColumns.
*
* @return Return the additionalColumns.
@@ -171,8 +154,6 @@
makeAllColumns();
HBaseConfiguration conf = new HBaseConfiguration();
keyGenerator = (IndexKeyGenerator) ObjectWritable.readObject(in, conf);
- keyComparator = (WritableComparator<byte[]>) ObjectWritable.readObject(in,
- conf);
}
/** {@inheritDoc} */
@@ -193,8 +174,6 @@
HBaseConfiguration conf = new HBaseConfiguration();
ObjectWritable
.writeObject(out, keyGenerator, IndexKeyGenerator.class, conf);
- ObjectWritable.writeObject(out, keyComparator, WritableComparable.class,
- conf);
}
}
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexedTableAdmin.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexedTableAdmin.java?rev=718820&r1=718819&r2=718820&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexedTableAdmin.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/IndexedTableAdmin.java Tue Nov 18 16:43:01 2008
@@ -92,8 +92,6 @@
indexTableDesc.addFamily(new HColumnDescriptor(colFamily));
}
- indexTableDesc.setRowKeyComparator(indexSpec.getKeyComparator());
-
return indexTableDesc;
}
}
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/package.html
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/package.html?rev=718820&r1=718819&r2=718820&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/package.html (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/tableindexed/package.html Tue Nov 18 16:43:01 2008
@@ -26,9 +26,8 @@
The IndexSpecification class provides the metadata for the index. This includes:
<li> the columns that contribute to the index key,
<li> additional columns to put in the index table (and are thus made available to filters on the index table),
-<li> an IndexKeyGenerator which constructs the index-row-key from the indexed column(s) and the original row,
<br> and
-<li> (optionally) a custom key comparator for the indexed table. This can allow an index on a deserialized column value.
+<li> an IndexKeyGenerator which constructs the index-row-key from the indexed column(s) and the original row.
IndexesSpecifications can be added to a table's metadata (HTableDescriptor) before the table is constructed.
Afterwards, updates and deletes to the original table will trigger the updates in the index, and
Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/tableindexed/TestIndexedTable.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/tableindexed/TestIndexedTable.java?rev=718820&r1=718819&r2=718820&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/tableindexed/TestIndexedTable.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/tableindexed/TestIndexedTable.java Tue Nov 18 16:43:01 2008
@@ -45,7 +45,7 @@
private static final byte[] FAMILY = Bytes.toBytes("family:");
private static final byte[] COL_A = Bytes.toBytes("family:a");
- private static final String INDEX_COL_A_ASC = "A-Acending";
+ private static final String INDEX_COL_A = "A";
private static final int NUM_ROWS = 10;
private static final int MAX_VAL = 10000;
@@ -70,8 +70,8 @@
desc.addFamily(new HColumnDescriptor(FAMILY));
// Create a new index that does lexicographic ordering on COL_A
- IndexSpecification colAIndex = new IndexSpecification(INDEX_COL_A_ASC,
- COL_A, true);
+ IndexSpecification colAIndex = new IndexSpecification(INDEX_COL_A,
+ COL_A);
desc.addIndex(colAIndex);
admin = new IndexedTableAdmin(conf);
@@ -97,7 +97,7 @@
}
private void assertRowsInOrder(int numRowsExpected) throws IndexNotFoundException, IOException {
- Scanner scanner = table.getIndexedScanner(INDEX_COL_A_ASC,
+ Scanner scanner = table.getIndexedScanner(INDEX_COL_A,
HConstants.EMPTY_START_ROW, null, null, null);
int numRows = 0;
byte[] lastColA = null;