Hi.
I am having trouble indexing multiple columns in hbase.
This is my code:
IndexKeyGenerator keyGen = new SimpleIndexKeyGenerator();
Map <byte[], byte[]> indexColumnsMap = new HashMap<byte[],
byte[]>();
for ( int x =0; x < columns.length; x++)
indexColumnsMap.put(Bytes.toBytes(x),
Bytes.toBytes(columns[x]));
keyGen.createIndexKey(Bytes.toBytes(tableName+ "IndexKey") ,
indexColumnsMap); // Problem lies here.
hbAdmin.addIndex(Bytes.toBytes(tableName), new
IndexSpecification(tableName + "Index", Bytes.toByteArrays(columns), null,
keyGen ));
I am able to index the tables in hbase, but when I want to index the table on
multiple columns I get the following error:
Exception in thread "main" java.lang.NullPointerException
at org.apache.hadoop.hbase.util.Bytes.add(Bytes.java:1131)
at org.apache.hadoop.hbase.util.Bytes.add(Bytes.java:1121)
at
org.apache.hadoop.hbase.client.tableindexed.SimpleIndexKeyGenerator.createIndexKey(SimpleIndexKeyGenerator.java:46)
I read that SimpleIndexKeyGenerator is used for single columns. If this is so
please advise me on using another way of indexing the tables on multiple
columns.
Thank you,
Michelan Arendse
Junior Developer | AD:DYNAMO // happy business ;-)
Office 0861 Dynamo (0861 396266) | Fax +27 (0) 21 465 2587
Advertise Online Instantly - www.addynamo.com<http://www.addynamo.com>
<http://www.addynamo.com>