You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2010/03/06 14:42:49 UTC
svn commit: r919764 - in /directory/sandbox/seelmann/hbase-partition/src:
main/java/org/apache/directory/server/core/partition/hbase/cursor/
main/java/org/apache/directory/server/core/partition/hbase/table/
test/java/org/apache/directory/server/core/pa...
Author: seelmann
Date: Sat Mar 6 13:42:49 2010
New Revision: 919764
URL: http://svn.apache.org/viewvc?rev=919764&view=rev
Log:
simplyfied presence index table
Modified:
directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/cursor/HBasePresenceIndexCursor.java
directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTable.java
directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseRowIndexTable.java
directory/sandbox/seelmann/hbase-partition/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTableTest.java
Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/cursor/HBasePresenceIndexCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/cursor/HBasePresenceIndexCursor.java?rev=919764&r1=919763&r2=919764&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/cursor/HBasePresenceIndexCursor.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/cursor/HBasePresenceIndexCursor.java Sat Mar 6 13:42:49 2010
@@ -54,10 +54,8 @@
{
if ( scanner == null )
{
- byte[] start;
- byte[] stop;
- start = presenceIndexTable.getPresenceKey( HBasePresenceIndexTable.VALUE_SCAN_FIRST_ENTRYID );
- stop = presenceIndexTable.getPresenceKey( HBasePresenceIndexTable.VALUE_SCAN_LAST_ENTRYID );
+ byte[] start = presenceIndexTable.getPresenceKey( null );
+ byte[] stop = Utils.incrementBytes( start );
Scan s = new Scan( start, stop );
s.addFamily( HBasePresenceIndexTable.INFO_FAMILY );
scanner = presenceIndexTable.getScanner( s );
@@ -67,11 +65,9 @@
while ( iterator.hasNext() )
{
Result next = iterator.next();
- //byte[] row = next.getRow();
- byte[] id = next.getValue( HBasePresenceIndexTable.INFO_FAMILY, HBasePresenceIndexTable.ID_QUALIFIER );
-
+ UUID id = presenceIndexTable.extractEntryIdFromPresenceKey( next.getRow() );
currentEntry = new ForwardIndexEntry<String, ServerEntry, UUID>();
- currentEntry.setId( Utils.toUUID( id ) );
+ currentEntry.setId( id );
return true;
}
return false;
Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTable.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTable.java?rev=919764&r1=919763&r2=919764&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTable.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTable.java Sat Mar 6 13:42:49 2010
@@ -46,9 +46,10 @@
{
// private static final Logger LOG = LoggerFactory.getLogger( HBasePresenceIndexTable.class );
- public static final byte[] COUNT_ROW = Bytes.toBytes( "!" );
public static final byte[] INFO_FAMILY = Bytes.toBytes( "info" );
public static final byte[] ID_QUALIFIER = Bytes.toBytes( "id" );
+ public static final byte[] DUMMY =
+ { 0x00 };
public static final UUID VALUE_SCAN_FIRST_ENTRYID = UUID.fromString( "00000000-0000-0000-0000-000000000000" );
public static final UUID VALUE_SCAN_LAST_ENTRYID = UUID.fromString( "ffffffff-ffff-ffff-ffff-ffffffffffff" );
@@ -83,7 +84,7 @@
* Gets the index equals key.
* The key has the following syntax:
* <pre> *<entryId></pre>
- * <code>entryId</code> is the Base64 encoded 8-byte row key from the master table.
+ * <code>entryId</code> is the UUID row key from the master table.
*
* @param entryId the entry ID
* @return the presence index row key for the entry ID
@@ -96,15 +97,7 @@
bb.append( '*' );
// add entryId
- if ( entryId == VALUE_SCAN_FIRST_ENTRYID )
- {
- bb.append( Bytes.toBytes( VALUE_SCAN_FIRST_ENTRYID.toString() ) );
- }
- else if ( entryId == VALUE_SCAN_LAST_ENTRYID )
- {
- bb.append( Bytes.toBytes( VALUE_SCAN_LAST_ENTRYID.toString() ) );
- }
- else if ( entryId != null )
+ if ( entryId != null )
{
bb.append( Bytes.toBytes( entryId.toString() ) );
}
@@ -113,6 +106,14 @@
}
+ public UUID extractEntryIdFromPresenceKey( byte[] row )
+ {
+ byte[] id = Bytes.tail( row, 36 );
+ UUID uuid = Utils.toUUID( id );
+ return uuid;
+ }
+
+
public int count() throws Exception
{
Integer cachedCount = countCache.get( attributeTypeOid );
@@ -165,10 +166,10 @@
public void add( UUID entryId ) throws Exception
{
- // presence (attribute=*): *<id> -> id
+ // presence (attribute=*): *<id>
byte[] presenceRow = getPresenceKey( entryId );
Put presencePut = new Put( presenceRow );
- presencePut.add( INFO_FAMILY, ID_QUALIFIER, Utils.toBytes( entryId ) );
+ presencePut.add( INFO_FAMILY, ID_QUALIFIER, DUMMY );
HBaseTableHelper.put( getIndexTablePool(), indexTableName, presencePut );
countCache.clear();
Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseRowIndexTable.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseRowIndexTable.java?rev=919764&r1=919763&r2=919764&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseRowIndexTable.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseRowIndexTable.java Sat Mar 6 13:42:49 2010
@@ -64,7 +64,7 @@
* The key has the following syntax:
* <pre> =value<entryId></pre>
* where <code>value</code> is the normalized value, and
- * <code>entryId</code> is the Base64 encoded 8-byte row key from the master table.
+ * <code>entryId</code> is the UUID row key from the master table.
*
* @param value the value
* @param entryId the entry ID
Modified: directory/sandbox/seelmann/hbase-partition/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTableTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTableTest.java?rev=919764&r1=919763&r2=919764&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTableTest.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTableTest.java Sat Mar 6 13:42:49 2010
@@ -109,8 +109,7 @@
NavigableMap<byte[], byte[]> presenceInfoMap = presenceResult.getFamilyMap( Bytes.toBytes( "info" ) );
assertNotNull( presenceInfoMap );
assertEquals( 1, presenceInfoMap.size() );
- assertEquals( "00000000-0000-0000-0000-000000000001", Bytes.toString( presenceInfoMap
- .get( Bytes.toBytes( "id" ) ) ) );
+ assertEquals( "\u0000", Bytes.toString( presenceInfoMap.get( Bytes.toBytes( "id" ) ) ) );
// 2nd entry
objectClassPresenceIndexTable.add( OU_SALES_ID );
@@ -275,6 +274,15 @@
@Test
+ public void testExtractGetPresenceKey() throws Exception
+ {
+ UUID uuid = objectClassPresenceIndexTable.extractEntryIdFromPresenceKey( Bytes
+ .toBytes( "*00000000-0000-0000-0000-000000000000" ) );
+ assertEquals( "00000000-0000-0000-0000-000000000000", uuid.toString() );
+ }
+
+
+ @Test
public void last() throws Exception
{
}