directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r917770 [2/4] - in /directory/sandbox/seelmann/hbase-partition/src: main/java/org/apache/directory/server/core/partition/hbase/ main/java/org/apache/directory/server/core/partition/hbase/cursor/ main/java/org/apache/directory/server/core/pa...
Date Mon, 01 Mar 2010 22:45:48 GMT
Added: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/mapreduce/TreeTableBuilder.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/mapreduce/TreeTableBuilder.java?rev=917770&view=auto
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/mapreduce/TreeTableBuilder.java (added)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/mapreduce/TreeTableBuilder.java Mon Mar  1 22:45:47 2010
@@ -0,0 +1,143 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.server.core.partition.hbase.mapreduce;
+
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.partition.hbase.HBaseStore;
+import org.apache.directory.server.core.partition.hbase.Utils;
+import org.apache.directory.server.core.partition.hbase.table.HBaseMasterTable;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.loader.ldif.JarLdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
+import org.apache.hadoop.hbase.mapreduce.TableMapper;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.Mapper;
+
+
+/**
+ * Mapper that build indices.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class TreeTableBuilder extends TableMapper<IntWritable, Text>
+{
+
+    private static enum Counters
+    {
+        TREE_ENTRIES
+    }
+
+    public static final String SUFFIX = "org.apache.directory.suffix";
+    public static final String TABLE_PREFIX = "org.apache.directory.table.prefix";
+
+    private HBaseStore store;
+
+
+    protected void setup( Mapper<ImmutableBytesWritable, Result, IntWritable, Text>.Context context )
+        throws IOException, InterruptedException
+    {
+        try
+        {
+            JarLdifSchemaLoader schemaLoader = new JarLdifSchemaLoader();
+            SchemaManager schemaManager = new DefaultSchemaManager( schemaLoader );
+            schemaManager.loadAllEnabled();
+
+            LdapDN suffixDn = new LdapDN( context.getConfiguration().get( SUFFIX ) );
+            suffixDn.normalize( schemaManager.getNormalizerMapping() );
+
+            store = new HBaseStore();
+
+            store.setSuffixDn( suffixDn.getName() );
+            store.setCacheSize( 100 );
+            String tablePrefix = context.getConfiguration().get( TABLE_PREFIX );
+            store.setTablePrefix( tablePrefix );
+            store.init( schemaManager );
+
+            store.getConfiguration().setBoolean( HBaseStore.STRONG_CONSISTENCY_PROPERTY, false );
+            store.getConfiguration().setBoolean( HBaseMasterTable.MAINTAIN_COUNTERS_PROPERTY, true );
+            for ( Map.Entry<String, String> property : context.getConfiguration() )
+            {
+                store.getConfiguration().set( property.getKey(), property.getValue() );
+            }
+        }
+        catch ( Throwable e )
+        {
+            e.printStackTrace();
+            throw new IOException( e );
+        }
+    }
+
+
+    protected void cleanup( Mapper<ImmutableBytesWritable, Result, IntWritable, Text>.Context context )
+        throws IOException, InterruptedException
+    {
+        try
+        {
+            store.destroy();
+        }
+        catch ( Throwable e )
+        {
+            e.printStackTrace();
+            throw new IOException( e );
+        }
+    }
+
+
+    @Override
+    public void map( ImmutableBytesWritable key, Result result, Context context ) throws IOException,
+        InterruptedException
+    {
+        try
+        {
+            UUID id = Utils.toUUID( key.get() );
+            ServerEntry entry = store.getMasterTable().convertToServerEntry( id, result );
+
+            // write to tree table
+            UUID parentId = Utils.toUUID( result.getValue( HBaseMasterTable.TREE_INFO_FAMILY,
+                HBaseMasterTable.PARENT_ID_QUALIFIER ) );
+            String normRdn = Bytes.toString( result.getValue( HBaseMasterTable.TREE_INFO_FAMILY,
+                HBaseMasterTable.NORM_RDN_QUALIFIER ) );
+            String upRdn = Bytes.toString( result.getValue( HBaseMasterTable.TREE_INFO_FAMILY,
+                HBaseMasterTable.UP_RDN_QUALIFIER ) );
+            HBaseMasterTable.MasterTreeInfo mti = new HBaseMasterTable.MasterTreeInfo( parentId, normRdn, upRdn );
+            store.getMasterTable().addToTree( id, mti, entry );
+
+            context.getCounter( Counters.TREE_ENTRIES ).increment( 1 );
+        }
+        catch ( Exception e )
+        {
+            System.err.println( "Error indexing entry id=" + Utils.toUUID( key.get() ) );
+            System.err.println( ">>>" + result + "<<<" );
+            e.printStackTrace();
+        }
+    }
+
+}

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseColumnIndexTable.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseColumnIndexTable.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseColumnIndexTable.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseColumnIndexTable.java Mon Mar  1 22:45:47 2010
@@ -23,8 +23,10 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.NavigableMap;
+import java.util.UUID;
 
 import org.apache.directory.server.core.partition.hbase.Cache;
+import org.apache.directory.server.core.partition.hbase.Utils;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.util.Base64;
@@ -111,7 +113,7 @@
     }
 
 
-    public byte[] getScanKey( Object value, byte[] entryId ) throws Exception
+    public byte[] getScanKey( Object value ) throws Exception
     {
         ByteBuffer bb = new ByteBuffer();
 
@@ -133,21 +135,11 @@
             bb.append( normValue );
         }
 
-        // add entryId
-        if ( entryId == VALUE_SCAN_START )
-        {
-            bb.append( VALUE_SCAN_START );
-        }
-        else if ( entryId == VALUE_SCAN_STOP )
-        {
-            bb.append( VALUE_SCAN_STOP );
-        }
-
         return bb.copyOfUsedBytes();
     }
 
 
-    public List<Long> getColumnCandidates( Object value ) throws Exception
+    public List<UUID> getColumnCandidates( Object value ) throws Exception
     {
         byte[] equalsKey = getEqualsKey( value );
         Info info = fetchInfo( equalsKey );
@@ -159,7 +151,7 @@
     }
 
 
-    public List<Long> getColumnCandidates( Result result ) throws Exception
+    public List<UUID> getColumnCandidates( Result result ) throws Exception
     {
         Info info = extractInfo( result );
         return info.candidates;
@@ -175,7 +167,7 @@
      * @return
      * @throws Exception "index";
      */
-    public boolean exists( Object value, Long id ) throws Exception
+    public boolean exists( Object value, UUID id ) throws Exception
     {
         byte[] equalsKey = getEqualsKey( value );
         Info info = fetchInfo( equalsKey );
@@ -194,10 +186,13 @@
         {
             return null;
         }
+
         String key = String.valueOf( Base64.encode( row ) );
-        if ( infoCache.contains( key ) )
+
+        Info info = infoCache.get( key );
+        if ( info != null )
         {
-            return infoCache.get( key );
+            return info;
         }
 
         Get get = new Get( row );
@@ -229,21 +224,18 @@
         NavigableMap<byte[], byte[]> infoMap = result.getFamilyMap( INFO_FAMILY );
         for ( byte[] qualifier : infoMap.keySet() )
         {
-            if ( qualifier.length == 8 )
-            {
-                info.candidates.add( Bytes.toLong( qualifier ) );
-            }
+            info.candidates.add( Utils.toUUID( qualifier ) );
         }
         return info;
     }
 
 
-    public void add( byte[] value, Long id ) throws Exception
+    public void add( byte[] value, UUID id ) throws Exception
     {
         // exact match (attribute=value): =value -> id
         byte[] equalsKey = getEqualsKey( value );
         Put exactPut = new Put( equalsKey );
-        exactPut.add( INFO_FAMILY, Bytes.toBytes( id ), Bytes.toBytes( id ) );
+        exactPut.add( INFO_FAMILY, Utils.toBytes( id ), Utils.toBytes( id ) );
         HBaseTableHelper.put( getIndexTablePool(), indexTableName, exactPut );
 
         // TODO: optimize - don't need to clear the ẃhole cache
@@ -253,12 +245,12 @@
     }
 
 
-    public void drop( byte[] value, Long id ) throws Exception
+    public void drop( byte[] value, UUID id ) throws Exception
     {
         // exact match (attribute=value): =value -> id
         byte[] equalsKey = getEqualsKey( value );
         Delete exactDel = new Delete( equalsKey );
-        exactDel.deleteColumn( INFO_FAMILY, Bytes.toBytes( id ) );
+        exactDel.deleteColumn( INFO_FAMILY, Utils.toBytes( id ) );
         HBaseTableHelper.delete( getIndexTablePool(), indexTableName, exactDel );
 
         // TODO: optimize - don't need to clear the ẃhole cache
@@ -270,7 +262,7 @@
     class Info
     {
         Object value;
-        List<Long> candidates = new ArrayList<Long>();
+        List<UUID> candidates = new ArrayList<UUID>();
     }
 
 }

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseIndexTable.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseIndexTable.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseIndexTable.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseIndexTable.java Mon Mar  1 22:45:47 2010
@@ -20,6 +20,8 @@
 package org.apache.directory.server.core.partition.hbase.table;
 
 
+import java.util.UUID;
+
 import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -36,14 +38,12 @@
 
     public static final byte[] INFO_FAMILY = Bytes.toBytes( "info" );
     public static final byte[] ID_QUALIFIER = Bytes.toBytes( "id" );
-    public static final byte[] VALUE_SCAN_START = new byte[]
-        { 0x00 };
-    public static final byte[] VALUE_SCAN_STOP = new byte[]
-        { ( byte ) 0xFF };
-    public static final byte[] FULL_SCAN_START = new byte[]
-        { 0x00 };
-    public static final byte[] FULL_SCAN_STOP = new byte[]
-        { ( byte ) 0xFF };
+    public static final UUID VALUE_SCAN_START = UUID.fromString( "00000000-0000-0000-0000-000000000000" );
+    public static final UUID VALUE_SCAN_STOP = UUID.fromString( "ffffffff-ffff-ffff-ffff-ffffffffffff" );
+    
+    public static final Byte DELIMITER = Byte.valueOf( ( byte ) 0x00 );
+    public static final Byte FULL_SCAN_START = Byte.valueOf( ( byte ) 0x00 );
+    public static final Byte FULL_SCAN_STOP = Byte.valueOf( ( byte ) 0xFF );
 
 
     public abstract void close() throws Exception;
@@ -60,15 +60,15 @@
      * @return true if an index exists
      * @throws Exception
      */
-    public abstract boolean exists( Object value, Long id ) throws Exception;
+    public abstract boolean exists( Object value, UUID id ) throws Exception;
 
 
     public abstract ResultScanner getScanner( Scan scan ) throws Exception;
 
 
-    public abstract void add( byte[] value, Long id ) throws Exception;
+    public abstract void add( byte[] value, UUID id ) throws Exception;
 
 
-    public abstract void drop( byte[] value, Long id ) throws Exception;
+    public abstract void drop( byte[] value, UUID id ) throws Exception;
 
 }
\ No newline at end of file

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseMasterTable.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseMasterTable.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseMasterTable.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseMasterTable.java Mon Mar  1 22:45:47 2010
@@ -24,6 +24,9 @@
 import java.util.List;
 import java.util.Map;
 import java.util.NavigableMap;
+import java.util.UUID;
+
+import javax.naming.directory.InvalidAttributeValueException;
 
 import org.apache.directory.server.core.entry.DefaultServerAttribute;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
@@ -33,6 +36,8 @@
 import org.apache.directory.server.core.entry.ServerStringValue;
 import org.apache.directory.server.core.partition.hbase.Cache;
 import org.apache.directory.server.core.partition.hbase.HBaseStore;
+import org.apache.directory.server.core.partition.hbase.Utils;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -59,10 +64,8 @@
  */
 public class HBaseMasterTable
 {
-    public static final Long ROOT_ID = 0L;
-    public static final byte[] ROOT_ROW = Bytes.toBytes( ROOT_ID );
-    public static final byte[] SEQUENCE_ROW = Bytes.toBytes( ROOT_ID );
-    public static final byte[] SEQUENCE_QUALIFIER = Bytes.toBytes( "sequence" );
+    public static final UUID ROOT_ID = UUID.fromString( "00000000-0000-0000-0000-000000000000" );
+    public static final byte[] ROOT_ROW = Utils.toBytes( ROOT_ID );
 
     public static final byte[] TREE_INFO_FAMILY = Bytes.toBytes( "treeInfo" );
     public static final byte[] ID_QUALIFIER = Bytes.toBytes( "id" );
@@ -86,6 +89,7 @@
     public static final String MASTER_TABLE = "master";
     public static final String TREE_TABLE = "tree";
     public static final String MAINTAIN_COUNTERS_PROPERTY = "org.apache.directory.maintain.counters";
+    public static final String COMPRESSION_ALGORITHM_PROPERTY = "org.apache.directory.compression.algorithm";
 
     private HBaseConfiguration configuration;
     private boolean maintainCounters;
@@ -99,22 +103,22 @@
     private MasterTreeInfo suffixMti;
 
     /** id -> master tree info */
-    private Cache<Long, MasterTreeInfo> mtiCache;
+    private Cache<UUID, MasterTreeInfo> mtiCache;
 
     /** master tree info -> id */
-    private Cache<String, Long> idCache;
+    private Cache<String, UUID> idCache;
 
     /** id -> one level count */
-    private Cache<Long, Long> oneLevelCountCache;
+    private Cache<UUID, Long> oneLevelCountCache;
 
     /** id -> sub level count */
-    private Cache<Long, Long> subLevelCountCache;
+    private Cache<UUID, Long> subLevelCountCache;
 
     /** id -> DN */
-    private Cache<Long, LdapDN> dnCache;
+    private Cache<UUID, LdapDN> dnCache;
 
     /** id -> entry */
-    private Cache<Long, ServerEntry> entryCache;
+    private Cache<UUID, ServerEntry> entryCache;
 
 
     public HBaseMasterTable( HBaseStore store )
@@ -127,16 +131,16 @@
         this.treeTableName = store.getTablePrefix() + TREE_TABLE;
         this.suffixMti = new MasterTreeInfo( ROOT_ID, suffixDn.getNormName(), null );
 
-        this.entryCache = new Cache<Long, ServerEntry>( store.getCacheSize() );
+        this.entryCache = new Cache<UUID, ServerEntry>( store.getCacheSize() );
 
         int dnCacheSize = Math.max( store.getCacheSize(), store.getNdnIndex().getCacheSize() );
-        this.dnCache = new Cache<Long, LdapDN>( dnCacheSize );
-        this.mtiCache = new Cache<Long, MasterTreeInfo>( dnCacheSize );
-        this.idCache = new Cache<String, Long>( dnCacheSize );
+        this.dnCache = new Cache<UUID, LdapDN>( dnCacheSize );
+        this.mtiCache = new Cache<UUID, MasterTreeInfo>( dnCacheSize );
+        this.idCache = new Cache<String, UUID>( dnCacheSize );
 
-        this.oneLevelCountCache = new Cache<Long, Long>( Math.max( store.getCacheSize(), store.getOneLevelIndex()
+        this.oneLevelCountCache = new Cache<UUID, Long>( Math.max( store.getCacheSize(), store.getOneLevelIndex()
             .getCacheSize() ) );
-        this.subLevelCountCache = new Cache<Long, Long>( Math.max( store.getCacheSize(), store.getSubLevelIndex()
+        this.subLevelCountCache = new Cache<UUID, Long>( Math.max( store.getCacheSize(), store.getSubLevelIndex()
             .getCacheSize() ) );
     }
 
@@ -154,18 +158,14 @@
     }
 
 
-    public Long add( ServerEntry entry ) throws Exception
+    public UUID add( ServerEntry entry ) throws Exception
     {
-        Long id = addToMaster( entry );
-        addToTree( id, entry );
-        return id;
-    }
-
-
-    public Long addToMaster( ServerEntry entry ) throws Exception
-    {
-        Long id = nextId();
-        List<Long> parentIds = fetchParentIds( entry.getDn(), false );
+        UUID id = getId( entry );
+        List<UUID> parentIds = fetchParentIds( entry.getDn(), false );
+        if ( parentIds == null )
+        {
+            throw new NullPointerException( "fetchParentIds() returned null for " + entry.getDn() );
+        }
         String upRdn;
         String normRdn;
         if ( entry.getDn().equals( suffixDn ) )
@@ -178,12 +178,22 @@
             upRdn = entry.getDn().getRdn().getUpName();
             normRdn = entry.getDn().getRdn().getNormName();
         }
+        MasterTreeInfo mti = new MasterTreeInfo( parentIds.get( 0 ), normRdn, upRdn );
+
+        addToMaster( id, mti, entry );
+        addToTree( id, mti, entry );
+
+        return id;
+    }
+
 
-        // put to master and tree table
-        Put masterPut = new Put( Bytes.toBytes( id ) );
-        masterPut.add( TREE_INFO_FAMILY, PARENT_ID_QUALIFIER, Bytes.toBytes( parentIds.get( 0 ) ) );
-        masterPut.add( TREE_INFO_FAMILY, UP_RDN_QUALIFIER, Bytes.toBytes( upRdn ) );
-        masterPut.add( TREE_INFO_FAMILY, NORM_RDN_QUALIFIER, Bytes.toBytes( normRdn ) );
+    public void addToMaster( UUID id, MasterTreeInfo mti, ServerEntry entry ) throws Exception
+    {
+        // put to master table
+        Put masterPut = new Put( Utils.toBytes( id ) );
+        masterPut.add( TREE_INFO_FAMILY, PARENT_ID_QUALIFIER, Utils.toBytes( mti.parentId ) );
+        masterPut.add( TREE_INFO_FAMILY, UP_RDN_QUALIFIER, Bytes.toBytes( mti.upName ) );
+        masterPut.add( TREE_INFO_FAMILY, NORM_RDN_QUALIFIER, Bytes.toBytes( mti.normName ) );
         for ( EntryAttribute attribute : entry )
         {
             String attr = attribute.getUpId();
@@ -199,33 +209,14 @@
             }
         }
         HBaseTableHelper.put( getMasterTablePool(), masterTableName, masterPut );
-
-        return id;
     }
 
 
-    public Long addToTree( Long id, ServerEntry entry ) throws Exception
+    public void addToTree( UUID id, MasterTreeInfo mti, ServerEntry entry ) throws Exception
     {
-        List<Long> parentIds = fetchParentIds( entry.getDn(), false );
-        String upRdn;
-        String normRdn;
-        MasterTreeInfo treeTableKey;
-        if ( entry.getDn().equals( suffixDn ) )
-        {
-            upRdn = entry.getDn().getName();
-            normRdn = entry.getDn().getNormName();
-            treeTableKey = new MasterTreeInfo( parentIds.get( 0 ), normRdn, upRdn );
-        }
-        else
-        {
-            upRdn = entry.getDn().getRdn().getUpName();
-            normRdn = entry.getDn().getRdn().getNormName();
-            treeTableKey = new MasterTreeInfo( parentIds.get( 0 ), normRdn, upRdn );
-        }
-
         // put to tree table
-        Put treePut = new Put( treeTableKey.treeTableKey );
-        treePut.add( TREE_INFO_FAMILY, ID_QUALIFIER, Bytes.toBytes( id ) );
+        Put treePut = new Put( mti.treeTableKey );
+        treePut.add( TREE_INFO_FAMILY, ID_QUALIFIER, Utils.toBytes( id ) );
         for ( EntryAttribute attribute : entry )
         {
             String attrOid = ( ( ServerAttribute ) attribute ).getAttributeType().getOid();
@@ -253,12 +244,11 @@
                 }
             }
         }
-        HBaseTableHelper.put( getTreeTablePool(), treeTableName, treePut );
 
         if ( maintainCounters )
         {
             // update parent one-level count
-            MasterTreeInfo parentKey = fetchMasterTreeInfo( parentIds.get( 0 ) );
+            MasterTreeInfo parentKey = fetchMasterTreeInfo( mti.parentId );
             if ( parentKey != null )
             {
                 HBaseTableHelper.increment( getTreeTablePool(), treeTableName, parentKey.treeTableKey,
@@ -266,14 +256,11 @@
             }
 
             // update all parents sub-level count
-            for ( Long parentId : parentIds )
+            while ( parentKey != null )
             {
-                parentKey = fetchMasterTreeInfo( parentId );
-                if ( parentKey != null )
-                {
-                    HBaseTableHelper.increment( getTreeTablePool(), treeTableName, parentKey.treeTableKey,
-                        TREE_INFO_FAMILY, SUB_LEVEL_COUNT_QUALIFIER );
-                }
+                HBaseTableHelper.increment( getTreeTablePool(), treeTableName, parentKey.treeTableKey,
+                    TREE_INFO_FAMILY, SUB_LEVEL_COUNT_QUALIFIER );
+                parentKey = fetchMasterTreeInfo( parentKey.parentId );
             }
 
             // clear caches
@@ -281,16 +268,16 @@
             subLevelCountCache.clear();
         }
 
-        return id;
+        HBaseTableHelper.put( getTreeTablePool(), treeTableName, treePut );
     }
 
 
-    public void delete( Long id, ServerEntry entry ) throws Exception
+    public void delete( UUID id, ServerEntry entry ) throws Exception
     {
         MasterTreeInfo key = fetchMasterTreeInfo( id );
 
         // delete in master table
-        Delete masterDel = new Delete( Bytes.toBytes( id ) );
+        Delete masterDel = new Delete( Utils.toBytes( id ) );
         HBaseTableHelper.delete( getMasterTablePool(), masterTableName, masterDel );
 
         // delete in tree table
@@ -300,8 +287,8 @@
         if ( maintainCounters )
         {
             // update parent one-level count
-            Long parentId = key.parentId;
-            if ( parentId > ROOT_ID )
+            UUID parentId = key.parentId;
+            if ( !parentId.equals( ROOT_ID ) )
             {
                 MasterTreeInfo parentKey = fetchMasterTreeInfo( parentId );
                 HBaseTableHelper.decrement( getTreeTablePool(), treeTableName, parentKey.treeTableKey,
@@ -309,7 +296,7 @@
             }
 
             // update sub-level count of all parents
-            while ( parentId > ROOT_ID )
+            while ( !parentId.equals( ROOT_ID ) )
             {
                 MasterTreeInfo parentKey = fetchMasterTreeInfo( parentId );
                 HBaseTableHelper.decrement( getTreeTablePool(), treeTableName, parentKey.treeTableKey,
@@ -328,16 +315,16 @@
     }
 
 
-    public void modify( Long id, ServerEntry entry ) throws Exception
+    public void modify( UUID id, ServerEntry entry ) throws Exception
     {
         // TODO: replace quick-and-dirty implementation (delete+put) with with better algorithm
         MasterTreeInfo ttk = fetchMasterTreeInfo( id );
 
         // delete complete attribute family
-        Delete masterDel = new Delete( Bytes.toBytes( id ) );
+        Delete masterDel = new Delete( Utils.toBytes( id ) );
         masterDel.deleteFamily( UP_ATTRIBUTES_FAMILY );
         HBaseTableHelper.delete( getMasterTablePool(), masterTableName, masterDel );
-        Delete treeDel = new Delete( Bytes.toBytes( id ) );
+        Delete treeDel = new Delete( Utils.toBytes( id ) );
         treeDel.deleteFamily( NORM_ATTRIBUTES_FAMILY );
         HBaseTableHelper.delete( getTreeTablePool(), treeTableName, treeDel );
 
@@ -348,7 +335,7 @@
 
         // add all attributes
         // TODO: duplicate code
-        Put masterPut = new Put( Bytes.toBytes( id ) );
+        Put masterPut = new Put( Utils.toBytes( id ) );
         Put treePut = new Put( ttk.treeTableKey );
         for ( EntryAttribute attribute : entry )
         {
@@ -396,18 +383,19 @@
      * @return the server entry, null if entry doesn't exist.
      * @throws Exception the exception
      */
-    public ServerEntry fetchEntry( Long id ) throws Exception
+    public ServerEntry fetchEntry( UUID id ) throws Exception
     {
         if ( id == null || id.equals( ROOT_ID ) )
         {
             return null;
         }
-        if ( entryCache.contains( id ) )
+        ServerEntry entry = entryCache.get( id );
+        if ( entry != null )
         {
-            return entryCache.get( id );
+            return entry;
         }
 
-        Get entryGet = new Get( Bytes.toBytes( id ) );
+        Get entryGet = new Get( Utils.toBytes( id ) );
         entryGet.addColumn( TREE_INFO_FAMILY, ID_QUALIFIER );
         entryGet.addColumn( TREE_INFO_FAMILY, PARENT_ID_QUALIFIER );
         entryGet.addColumn( TREE_INFO_FAMILY, UP_RDN_QUALIFIER );
@@ -418,16 +406,16 @@
         {
             return null;
         }
-        ServerEntry entry = convertToServerEntry( id, result );
+        entry = convertToServerEntry( id, result );
         entryCache.put( id, entry );
         return entry;
     }
 
 
-    public ServerEntry convertToServerEntry( Long id, Result result ) throws Exception
+    public ServerEntry convertToServerEntry( UUID id, Result result ) throws Exception
     {
-        Long parentId = Bytes.toLong( result.getValue( TREE_INFO_FAMILY, PARENT_ID_QUALIFIER ) );
-        String normRdn = Bytes.toString( result.getValue( TREE_INFO_FAMILY, UP_RDN_QUALIFIER ) );
+        UUID parentId = Utils.toUUID( result.getValue( TREE_INFO_FAMILY, PARENT_ID_QUALIFIER ) );
+        String normRdn = Bytes.toString( result.getValue( TREE_INFO_FAMILY, NORM_RDN_QUALIFIER ) );
         String upRdn = Bytes.toString( result.getValue( TREE_INFO_FAMILY, UP_RDN_QUALIFIER ) );
         MasterTreeInfo mti = new MasterTreeInfo( parentId, normRdn, upRdn );
         LdapDN dn = fetchDn( id, mti );
@@ -461,11 +449,12 @@
     }
 
 
-    private LdapDN fetchDn( Long id, MasterTreeInfo mti ) throws Exception
+    private LdapDN fetchDn( UUID id, MasterTreeInfo mti ) throws Exception
     {
-        if ( dnCache.contains( id ) )
+        LdapDN dn = dnCache.get( id );
+        if ( dn != null )
         {
-            return dnCache.get( id );
+            return dn;
         }
 
         // build DN, only normalize the RDN part, the parent is already normalized
@@ -480,7 +469,7 @@
             }
         }
         while ( mti != null );
-        LdapDN dn = new LdapDN( sb.toString() );
+        dn = new LdapDN( sb.toString() );
         dn.normalize( schemaManager.getAttributeTypeRegistry().getNormalizerMapping() );
 
         // put DN to cache
@@ -497,13 +486,13 @@
      * @return the entry ID, null if entry doesn't exist.
      * @throws Exception
      */
-    public Long fetchId( LdapDN dn ) throws Exception
+    public UUID fetchId( LdapDN dn ) throws Exception
     {
         if ( dn == null )
         {
             return null;
         }
-        List<Long> ids = fetchParentIds( dn, true );
+        List<UUID> ids = fetchParentIds( dn, true );
         return ids == null ? null : ids.get( 0 );
     }
 
@@ -515,7 +504,7 @@
      * @return the parent ID, null if entry doesn't exist.
      * @throws Exception
      */
-    public Long fetchParentId( Long id ) throws Exception
+    public UUID fetchParentId( UUID id ) throws Exception
     {
         if ( id == null || id.equals( ROOT_ID ) )
         {
@@ -530,7 +519,7 @@
     }
 
 
-    public NavigableMap<byte[], byte[]> fetchNormAttributes( Long id ) throws Exception
+    public NavigableMap<byte[], byte[]> fetchNormAttributes( UUID id ) throws Exception
     {
         MasterTreeInfo mti = fetchMasterTreeInfo( id );
         Get get = new Get( mti.treeTableKey );
@@ -548,11 +537,12 @@
      * @return the one level count, 0 if entry doesn't exist.
      * @throws Exception
      */
-    public int getOneLevelCount( Long id ) throws Exception
+    public int getOneLevelCount( UUID id ) throws Exception
     {
-        if ( oneLevelCountCache.contains( id ) )
+        Long count = oneLevelCountCache.get( id );
+        if ( count != null )
         {
-            return oneLevelCountCache.get( id ).intValue();
+            return count.intValue();
         }
 
         MasterTreeInfo mti = fetchMasterTreeInfo( id );
@@ -560,8 +550,8 @@
         {
             return 0;
         }
-        Long count = HBaseTableHelper.getLongValue( getTreeTablePool(), treeTableName, mti.treeTableKey,
-            TREE_INFO_FAMILY, ONE_LEVEL_COUNT_QUALIFIER, 0L );
+        count = HBaseTableHelper.getLongValue( getTreeTablePool(), treeTableName, mti.treeTableKey, TREE_INFO_FAMILY,
+            ONE_LEVEL_COUNT_QUALIFIER, 0L );
 
         oneLevelCountCache.put( id, count );
         return count.intValue();
@@ -575,11 +565,12 @@
      * @return the sub level count, 0 if entry doesn't exist.
      * @throws Exception
      */
-    public int getSubLevelCount( Long id ) throws Exception
+    public int getSubLevelCount( UUID id ) throws Exception
     {
-        if ( subLevelCountCache.contains( id ) )
+        Long count = subLevelCountCache.get( id );
+        if ( count != null )
         {
-            return subLevelCountCache.get( id ).intValue();
+            return count.intValue();
         }
 
         MasterTreeInfo mti = fetchMasterTreeInfo( id );
@@ -587,8 +578,8 @@
         {
             return 0;
         }
-        Long count = HBaseTableHelper.getLongValue( getTreeTablePool(), treeTableName, mti.treeTableKey,
-            TREE_INFO_FAMILY, SUB_LEVEL_COUNT_QUALIFIER, 0L );
+        count = HBaseTableHelper.getLongValue( getTreeTablePool(), treeTableName, mti.treeTableKey, TREE_INFO_FAMILY,
+            SUB_LEVEL_COUNT_QUALIFIER, 0L );
 
         subLevelCountCache.put( id, count );
         return count.intValue();
@@ -602,18 +593,18 @@
     }
 
 
-    private List<Long> fetchParentIds( LdapDN dn, boolean includeChild ) throws Exception
+    private List<UUID> fetchParentIds( LdapDN dn, boolean includeChild ) throws Exception
     {
         if ( !dn.startsWith( suffixDn ) )
         {
             return null;
         }
-        List<Long> path = new ArrayList<Long>();
+        List<UUID> path = new ArrayList<UUID>();
         path.add( ROOT_ID );
 
         if ( !dn.equals( suffixDn ) || includeChild )
         {
-            Long parentId = getSuffixId();
+            UUID parentId = getSuffixId();
             if ( parentId == null )
             {
                 return null;
@@ -638,31 +629,17 @@
     }
 
 
-    private Long getSuffixId() throws Exception
+    private UUID getSuffixId() throws Exception
     {
         return fetchId( suffixMti );
     }
 
-    private List<Long> ids = new ArrayList<Long>();
-
 
-    private long nextId() throws Exception
+    private UUID getId( ServerEntry entry ) throws InvalidAttributeValueException
     {
-        if ( ids.isEmpty() )
-        {
-            long amount = 100;
-            byte[] id = HBaseTableHelper.increment( getMasterTablePool(), masterTableName, SEQUENCE_ROW,
-                TREE_INFO_FAMILY, SEQUENCE_QUALIFIER, amount );
-            long upper = Bytes.toLong( id );
-            long lower = upper - amount + 1;
-            for ( long l = lower; l <= upper; l++ )
-            {
-                ids.add( l );
-            }
-        }
-
-        Long id = ids.remove( 0 );
-        return id;
+        String name = entry.get( SchemaConstants.ENTRY_UUID_AT ).getString();
+        UUID uuid = UUID.fromString( name );
+        return uuid;
     }
 
 
@@ -688,14 +665,15 @@
     }
 
 
-    private Long fetchId( MasterTreeInfo mti ) throws Exception
+    private UUID fetchId( MasterTreeInfo mti ) throws Exception
     {
-        if ( idCache.contains( mti.string ) )
+        UUID id = idCache.get( mti.string );
+        if ( id != null )
         {
-            return idCache.get( mti.string );
+            return id;
         }
 
-        Long id = HBaseTableHelper.getLongValue( getTreeTablePool(), treeTableName, mti.treeTableKey, TREE_INFO_FAMILY,
+        id = HBaseTableHelper.getUUIDValue( getTreeTablePool(), treeTableName, mti.treeTableKey, TREE_INFO_FAMILY,
             ID_QUALIFIER, null );
         if ( id == null )
         {
@@ -715,18 +693,19 @@
      * @return the master tree info, null if entry doesn't exist
      * @throws Exception
      */
-    private MasterTreeInfo fetchMasterTreeInfo( Long id ) throws Exception
+    private MasterTreeInfo fetchMasterTreeInfo( UUID id ) throws Exception
     {
         if ( id == null || id.equals( ROOT_ID ) )
         {
             return null;
         }
-        if ( mtiCache.contains( id ) )
+        MasterTreeInfo mti = mtiCache.get( id );
+        if ( mti != null )
         {
-            return mtiCache.get( id );
+            return mti;
         }
 
-        Get get = new Get( Bytes.toBytes( id ) );
+        Get get = new Get( Utils.toBytes( id ) );
         get.addColumn( TREE_INFO_FAMILY, PARENT_ID_QUALIFIER );
         get.addColumn( TREE_INFO_FAMILY, NORM_RDN_QUALIFIER );
         get.addColumn( TREE_INFO_FAMILY, UP_RDN_QUALIFIER );
@@ -735,33 +714,41 @@
         {
             return null;
         }
-        Long parentId = Bytes.toLong( result.getValue( TREE_INFO_FAMILY, PARENT_ID_QUALIFIER ) );
+        UUID parentId = Utils.toUUID( result.getValue( TREE_INFO_FAMILY, PARENT_ID_QUALIFIER ) );
         String normRdn = Bytes.toString( result.getValue( TREE_INFO_FAMILY, NORM_RDN_QUALIFIER ) );
         String upRdn = Bytes.toString( result.getValue( TREE_INFO_FAMILY, UP_RDN_QUALIFIER ) );
 
-        MasterTreeInfo mti = new MasterTreeInfo( parentId, normRdn, upRdn );
+        mti = new MasterTreeInfo( parentId, normRdn, upRdn );
         mtiCache.put( id, mti );
         idCache.put( mti.string, id );
         return mti;
     }
 
-    static class MasterTreeInfo
+    public static class MasterTreeInfo
     {
-        private final Long parentId;
+        private final UUID parentId;
         private final String normName;
         private final String upName;
         public final byte[] treeTableKey;
         public final String string;
 
 
-        public MasterTreeInfo( Long parentId, String normName, String upName )
+        public MasterTreeInfo( UUID parentId, String normName, String upName )
         {
             this.parentId = parentId;
             this.normName = normName;
             this.upName = upName;
-            this.treeTableKey = Bytes.add( Bytes.toBytes( parentId ), KEY_DELIMITER_BYTES, Bytes.toBytes( normName ) );
+            this.treeTableKey = Bytes.add( Utils.toBytes( parentId ), KEY_DELIMITER_BYTES, Bytes.toBytes( normName ) );
             this.string = "" + parentId + KEY_DELIMITER + normName;
         }
+
+
+        @Override
+        public String toString()
+        {
+            return string;
+        }
+
     }
 
 

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=917770&r1=917769&r2=917770&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 Mon Mar  1 22:45:47 2010
@@ -20,13 +20,13 @@
 package org.apache.directory.server.core.partition.hbase.table;
 
 
+import java.util.UUID;
+
 import org.apache.directory.server.core.partition.hbase.Cache;
 import org.apache.directory.server.core.partition.hbase.HBaseStore;
+import org.apache.directory.server.core.partition.hbase.Utils;
 import org.apache.directory.server.core.partition.hbase.cursor.HBasePresenceIndexCursor;
-import org.apache.directory.shared.ldap.schema.SchemaManager;
-import org.apache.directory.shared.ldap.util.Base64;
 import org.apache.directory.shared.ldap.util.ByteBuffer;
-import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.Put;
@@ -49,10 +49,8 @@
     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[] VALUE_SCAN_FIRST_ENTRYID = new byte[]
-        { 0x00 };
-    public static final byte[] VALUE_SCAN_LAST_ENTRYID = new byte[]
-        { ( byte ) 0xFF };
+    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" );
 
     protected String indexTableName;
     private HBaseTablePool indexTablePool;
@@ -91,7 +89,7 @@
      * @return the presence index row key for the entry ID
      * @throws Exception
      */
-    public byte[] getPresenceKey( byte[] entryId ) throws Exception
+    public byte[] getPresenceKey( UUID entryId ) throws Exception
     {
         ByteBuffer bb = new ByteBuffer();
 
@@ -100,15 +98,15 @@
         // add entryId
         if ( entryId == VALUE_SCAN_FIRST_ENTRYID )
         {
-            bb.append( VALUE_SCAN_FIRST_ENTRYID );
+            bb.append( Bytes.toBytes( VALUE_SCAN_FIRST_ENTRYID.toString() ) );
         }
         else if ( entryId == VALUE_SCAN_LAST_ENTRYID )
         {
-            bb.append( VALUE_SCAN_LAST_ENTRYID );
+            bb.append( Bytes.toBytes( VALUE_SCAN_LAST_ENTRYID.toString() ) );
         }
         else if ( entryId != null )
         {
-            bb.append( Bytes.toBytes( String.valueOf( Base64.encode( entryId ) ) ) );
+            bb.append( Bytes.toBytes( entryId.toString() ) );
         }
 
         return bb.copyOfUsedBytes();
@@ -117,9 +115,10 @@
 
     public int count() throws Exception
     {
-        if ( countCache.contains( attributeTypeOid ) )
+        Integer cachedCount = countCache.get( attributeTypeOid );
+        if ( cachedCount != null )
         {
-            return countCache.get( attributeTypeOid ).intValue();
+            return cachedCount.intValue();
         }
 
         // TODO: scan directly instead of using the cursor?
@@ -146,13 +145,13 @@
      * Checks if the entry has such an attribute (attributeType=*)
      *
      * @param attributeType
-     * @param id the entry id
+     * @param entryId the entry id
      * @return true if the entry contains such an attribute type
      * @throws Exception
      */
-    public boolean exists( Long id ) throws Exception
+    public boolean exists( UUID entryId ) throws Exception
     {
-        byte[] row = getPresenceKey( Bytes.toBytes( id ) );
+        byte[] row = getPresenceKey( entryId );
         Get get = new Get( row );
         return HBaseTableHelper.exists( getIndexTablePool(), indexTableName, get );
     }
@@ -164,22 +163,22 @@
     }
 
 
-    public void add( Long entryId ) throws Exception
+    public void add( UUID entryId ) throws Exception
     {
         // presence (attribute=*): *<id> -> id
-        byte[] presenceRow = getPresenceKey( Bytes.toBytes( entryId ) );
+        byte[] presenceRow = getPresenceKey( entryId );
         Put presencePut = new Put( presenceRow );
-        presencePut.add( INFO_FAMILY, ID_QUALIFIER, Bytes.toBytes( entryId ) );
+        presencePut.add( INFO_FAMILY, ID_QUALIFIER, Utils.toBytes( entryId ) );
         HBaseTableHelper.put( getIndexTablePool(), indexTableName, presencePut );
 
         countCache.clear();
     }
 
 
-    public void drop( Long entryId ) throws Exception
+    public void drop( UUID entryId ) throws Exception
     {
         // presence (attribute=*): *<id> -> id
-        byte[] presenceRow = getPresenceKey( Bytes.toBytes( entryId ) );
+        byte[] presenceRow = getPresenceKey( entryId );
         Delete presenceDel = new Delete( presenceRow );
         HBaseTableHelper.delete( getIndexTablePool(), indexTableName, presenceDel );
 

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=917770&r1=917769&r2=917770&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 Mon Mar  1 22:45:47 2010
@@ -20,12 +20,14 @@
 package org.apache.directory.server.core.partition.hbase.table;
 
 
+import java.util.UUID;
+
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.partition.hbase.HBaseStore;
+import org.apache.directory.server.core.partition.hbase.Utils;
 import org.apache.directory.server.core.partition.hbase.index.HBaseUserIndex;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.util.Base64;
 import org.apache.directory.shared.ldap.util.ByteBuffer;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Get;
@@ -69,7 +71,7 @@
      * @return the equals row key for the value
      * @throws Exception
      */
-    private byte[] getEqualsKey( Object value, Long id ) throws Exception
+    private byte[] getEqualsKey( Object value, UUID id ) throws Exception
     {
         if ( value == null || id == null )
         {
@@ -83,13 +85,15 @@
         byte[] normValue = getNormalized( value );
         bb.append( normValue );
 
-        bb.append( Bytes.toBytes( String.valueOf( Base64.encode( Bytes.toBytes( id ) ) ) ) );
+        bb.append( '\u0000' );
+
+        bb.append( Bytes.toBytes( id.toString() ) );
 
         return bb.copyOfUsedBytes();
     }
 
 
-    public byte[] getScanKey( Object value, byte[] entryId ) throws Exception
+    public byte[] getScanKey( Object value, Byte delimiter, UUID entryId ) throws Exception
     {
         ByteBuffer bb = new ByteBuffer();
 
@@ -99,11 +103,11 @@
         // there are special values to support attribute scan
         if ( value == FULL_SCAN_START )
         {
-            bb.append( FULL_SCAN_START );
+            bb.append( FULL_SCAN_START.byteValue() );
         }
         else if ( value == FULL_SCAN_STOP )
         {
-            bb.append( FULL_SCAN_STOP );
+            bb.append( FULL_SCAN_STOP.byteValue() );
         }
         else if ( value != null )
         {
@@ -111,31 +115,35 @@
             bb.append( normValue );
         }
 
+        if ( delimiter != null )
+        {
+            bb.append( delimiter.byteValue() );
+        }
+
         // add entryId
         if ( entryId == VALUE_SCAN_START )
         {
-            bb.append( VALUE_SCAN_START );
+            bb.append( Bytes.toBytes( VALUE_SCAN_START.toString() ) );
         }
         else if ( entryId == VALUE_SCAN_STOP )
         {
-            bb.append( VALUE_SCAN_STOP );
+            bb.append( Bytes.toBytes( VALUE_SCAN_STOP.toString() ) );
         }
         else if ( entryId != null )
         {
-            bb.append( Bytes.toBytes( String.valueOf( Base64.encode( entryId ) ) ) );
+            bb.append( Bytes.toBytes( entryId.toString() ) );
         }
 
         return bb.copyOfUsedBytes();
     }
 
 
-    public Object getValueFromEqualsKey( byte[] row ) throws Exception
+    public Object extractValueFromEqualsKey( byte[] row ) throws Exception
     {
         byte[] value = Bytes.tail( row, row.length - 1 );
-        value = Bytes.head( value, value.length - 12 );
+        value = Bytes.head( value, value.length - 1 - 36 ); // \00 + length of UUID
         AttributeType at = schemaManager.getAttributeTypeRegistry().lookup( attributeTypeOid );
         return at.getSyntax().isHumanReadable() ? Bytes.toString( value ) : value;
-
     }
 
 
@@ -144,14 +152,15 @@
      */
     public int count( Object value ) throws Exception
     {
-        if ( countCache.contains( value ) )
+        Integer cachedCount = countCache.get( value );
+        if ( cachedCount != null )
         {
-            return countCache.get( value ).intValue();
+            return cachedCount.intValue();
         }
 
         // TODO: scan directly instead of using the cursor?
         HBaseUserIndex<HBaseIndexTable> index = store.getUserIndex( attributeTypeOid );
-        IndexCursor<Object, ServerEntry> cursor = index.forwardCursor( value );
+        IndexCursor<Object, ServerEntry, UUID> cursor = index.forwardCursor( value );
         int count = 0;
         int limit = 100;
         while ( cursor.next() && count <= limit )
@@ -170,12 +179,13 @@
     }
 
 
-    public boolean exists( Object value, Long id ) throws Exception
+    public boolean exists( Object value, UUID id ) throws Exception
     {
         String key = value + ":" + id;
-        if ( existsCache.contains( key ) )
+        Boolean cachedExists = existsCache.get( key );
+        if ( cachedExists != null )
         {
-            return existsCache.get( key );
+            return cachedExists.booleanValue();
         }
 
         byte[] row = getEqualsKey( value, id );
@@ -190,12 +200,12 @@
     }
 
 
-    public void add( byte[] value, Long id ) throws Exception
+    public void add( byte[] value, UUID id ) throws Exception
     {
-        // exact match (attribute=value): =value<id> -> id, value
+        // exact match (attribute=value): =value<0x00><id> -> id, value
         byte[] exactRow = getEqualsKey( value, id );
         Put exactPut = new Put( exactRow );
-        exactPut.add( INFO_FAMILY, ID_QUALIFIER, Bytes.toBytes( id ) );
+        exactPut.add( INFO_FAMILY, ID_QUALIFIER, Utils.toBytes( id ) );
         HBaseTableHelper.put( getIndexTablePool(), indexTableName, exactPut );
 
         // TODO: optimize - don't need to clear the ẃhole cache
@@ -204,9 +214,9 @@
     }
 
 
-    public void drop( byte[] value, Long id ) throws Exception
+    public void drop( byte[] value, UUID id ) throws Exception
     {
-        // exact match (attribute=value): =value<id> -> id
+        // exact match (attribute=value): =value<0x00><id> -> id
         byte[] exactRow = getEqualsKey( value, id );
         Delete exactDel = new Delete( exactRow );
         HBaseTableHelper.delete( getIndexTablePool(), indexTableName, exactDel );

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseTableHelper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseTableHelper.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseTableHelper.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/table/HBaseTableHelper.java Mon Mar  1 22:45:47 2010
@@ -20,6 +20,8 @@
 package org.apache.directory.server.core.partition.hbase.table;
 
 
+import java.util.UUID;
+
 import org.apache.directory.server.core.partition.hbase.Utils;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HColumnDescriptor;
@@ -199,6 +201,56 @@
 
 
     /**
+     * Gets the UUID value of a column, the default value if the column doesn't exist.
+     * 
+     * @param pool the table pool
+     * @param tableName the table name
+     * @param row the row
+     * @param family the family
+     * @param qualifier the qualifier
+     * @param defaultValue the default value if the column doesn't exist
+     * 
+     * @return the long value
+     * 
+     * @throws Exception the exception
+     */
+    public static UUID getUUIDValue( HBaseTablePool pool, String tableName, byte[] row, byte[] family,
+        byte[] qualifier, UUID defaultValue ) throws Exception
+    {
+        HTable table = pool.getTable();
+        try
+        {
+            Get get = new Get( row );
+            get.addColumn( family, qualifier );
+            Result result = table.get( get );
+            RPC_COUNT++;
+            byte[] value = result.getValue( family, qualifier );
+            UUID uuid;
+            if ( value == null )
+            {
+                uuid = defaultValue;
+            }
+            else
+            {
+                uuid = Utils.toUUID( value );
+            }
+
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( "Get Long from " + tableName + ":" + Utils.getPrintableString( row ) + ":"
+                    + Utils.getPrintableString( family ) + ":" + Utils.getPrintableString( qualifier ) + " -> " + uuid );
+                logStack( 2 );
+            }
+            return uuid;
+        }
+        finally
+        {
+            pool.putTable( table );
+        }
+    }
+
+
+    /**
      * Commits a {@link Put} to the table.
      * 
      * @param pool the table pool
@@ -410,7 +462,9 @@
                 HColumnDescriptor columnDescriptor = new HColumnDescriptor( family );
                 columnDescriptor.setMaxVersions( 1 );
                 //columnDescriptor.setInMemory( true );
-                columnDescriptor.setCompressionType( Algorithm.LZO );
+                String typeValue = configuration.get( HBaseMasterTable.COMPRESSION_ALGORITHM_PROPERTY, "NONE" );
+                Algorithm type = Algorithm.valueOf( typeValue );
+                columnDescriptor.setCompressionType( type );
                 descriptor.addFamily( columnDescriptor );
 
             }

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedCursorBuilder.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedCursorBuilder.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedCursorBuilder.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedCursorBuilder.java Mon Mar  1 22:45:47 2010
@@ -39,13 +39,13 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 659774 $
  */
-public class ExtendedCursorBuilder extends CursorBuilder
+public class ExtendedCursorBuilder<ID> extends CursorBuilder<ID>
 {
     /** The database used by this builder */
-    private Store<ServerEntry> db = null;
+    private Store<ServerEntry, ID> db = null;
 
     /** Evaluator dependency on a EvaluatorBuilder */
-    private ExtendedEvaluatorBuilder evaluatorBuilder;
+    private ExtendedEvaluatorBuilder<ID> evaluatorBuilder;
 
 
     /**
@@ -54,7 +54,7 @@
      * @param db database used by this enumerator
      * @param evaluatorBuilder the evaluator builder
      */
-    public ExtendedCursorBuilder( Store<ServerEntry> db, ExtendedEvaluatorBuilder evaluatorBuilder )
+    public ExtendedCursorBuilder( Store<ServerEntry, ID> db, ExtendedEvaluatorBuilder<ID> evaluatorBuilder )
     {
         super( db, evaluatorBuilder );
         this.db = db;
@@ -62,7 +62,7 @@
     }
 
 
-    public IndexCursor<?, ServerEntry> build( ExprNode node ) throws Exception
+    public IndexCursor<?, ServerEntry, ID> build( ExprNode node ) throws Exception
     {
         // set the "real" filter node as annotation to the scope node
         if ( node.getAssertionType() == AssertionType.AND )
@@ -77,19 +77,19 @@
         switch ( node.getAssertionType() )
         {
             case SUBSTRING:
-                return new ExtendedSubstringCursor( db, ( ExtendedSubstringEvaluator ) evaluatorBuilder.build( node ) );
+                return new ExtendedSubstringCursor<ID>( db, ( ExtendedSubstringEvaluator<ID> ) evaluatorBuilder.build( node ) );
 
             case SCOPE:
                 ExprNode filter = ( ExprNode ) node.get( "filter" );
 
                 if ( ( ( ScopeNode ) node ).getScope() == SearchScope.ONELEVEL )
                 {
-                    return new ExtendedOneLevelScopeCursor( db, filter, ( OneLevelScopeEvaluator ) evaluatorBuilder
+                    return new ExtendedOneLevelScopeCursor<ID>( db, filter, ( OneLevelScopeEvaluator<ServerEntry, ID> ) evaluatorBuilder
                         .build( node ) );
                 }
                 else
                 {
-                    return new ExtendedSubtreeScopeCursor( db, filter, ( SubtreeScopeEvaluator ) evaluatorBuilder
+                    return new ExtendedSubtreeScopeCursor<ID>( db, filter, ( SubtreeScopeEvaluator<ServerEntry, ID> ) evaluatorBuilder
                         .build( node ) );
                 }
 

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedEvaluatorBuilder.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedEvaluatorBuilder.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedEvaluatorBuilder.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedEvaluatorBuilder.java Mon Mar  1 22:45:47 2010
@@ -36,9 +36,9 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 659774 $
  */
-public class ExtendedEvaluatorBuilder extends EvaluatorBuilder
+public class ExtendedEvaluatorBuilder<ID> extends EvaluatorBuilder<ID>
 {
-    private final Store<ServerEntry> db;
+    private final Store<ServerEntry, ID> db;
     private final SchemaManager schemaManager;
 
 
@@ -50,7 +50,7 @@
      * @param registries the schema registries
      * @throws Exception failure to access db or lookup schema in registries
      */
-    public ExtendedEvaluatorBuilder( Store<ServerEntry> db, SchemaManager schemaManager ) throws Exception
+    public ExtendedEvaluatorBuilder( Store<ServerEntry, ID> db, SchemaManager schemaManager ) throws Exception
     {
         super( db, schemaManager );
         this.db = db;
@@ -58,11 +58,11 @@
     }
 
 
-    public Evaluator<? extends ExprNode, ServerEntry> build( ExprNode node ) throws Exception
+    public Evaluator<? extends ExprNode, ServerEntry, ID> build( ExprNode node ) throws Exception
     {
         if ( node.getAssertionType() == AssertionType.SUBSTRING )
         {
-            return new ExtendedSubstringEvaluator( ( SubstringNode ) node, db, schemaManager );
+            return new ExtendedSubstringEvaluator<ID>( ( SubstringNode ) node, db, schemaManager );
         }
         else
         {

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedOneLevelScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedOneLevelScopeCursor.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedOneLevelScopeCursor.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedOneLevelScopeCursor.java Mon Mar  1 22:45:47 2010
@@ -39,26 +39,25 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ExtendedOneLevelScopeCursor extends AbstractIndexCursor<Long, ServerEntry>
+public class ExtendedOneLevelScopeCursor<ID> extends AbstractIndexCursor<ID, ServerEntry, ID>
 {
     /** Error message for unsupported operations */
     private static final String UNSUPPORTED_MSG = "Scope Cursors are not ordered and do not support positioning by element.";
 
     /** The entry database/store */
-    private final Store<ServerEntry> db;
+    private final Store<ServerEntry, ID> db;
 
     /** A onelevel ScopeNode Evaluator */
-    @SuppressWarnings("unchecked")
-    private final OneLevelScopeEvaluator evaluator;
+    private final OneLevelScopeEvaluator<ServerEntry, ID> evaluator;
 
     /** A Cursor over the entries in the scope of the search base */
-    private final IndexCursor<Long, ServerEntry> scopeCursor;
+    private final IndexCursor<ID, ServerEntry, ID> scopeCursor;
 
     /** A Cursor over entries brought into scope by alias dereferencing */
-    private final Cursor<IndexEntry<Long, ServerEntry>> dereferencedCursor;
+    private final Cursor<IndexEntry<ID, ServerEntry, ID>> dereferencedCursor;
 
     /** Currently active Cursor: we switch between two cursors */
-    private Cursor<IndexEntry<Long, ServerEntry>> cursor;
+    private Cursor<IndexEntry<ID, ServerEntry, ID>> cursor;
 
     /** Whether or not this Cursor is positioned so an entry is available */
     private boolean available = false;
@@ -72,17 +71,16 @@
      * @param evaluator an IndexEntry (candidate) evaluator
      * @throws Exception on db access failures
      */
-    @SuppressWarnings("unchecked")
-    public ExtendedOneLevelScopeCursor( Store<ServerEntry> db, ExprNode filter, OneLevelScopeEvaluator evaluator )
-        throws Exception
+    public ExtendedOneLevelScopeCursor( Store<ServerEntry, ID> db, ExprNode filter,
+        OneLevelScopeEvaluator<ServerEntry, ID> evaluator ) throws Exception
     {
         this.db = db;
         this.evaluator = evaluator;
 
-        Index<Long, ServerEntry> oneLevelIndex = db.getOneLevelIndex();
-        if ( oneLevelIndex instanceof IndexFilteringExtension<?, ?> )
+        Index<ID, ServerEntry, ID> oneLevelIndex = db.getOneLevelIndex();
+        if ( oneLevelIndex instanceof IndexFilteringExtension<?, ?, ?> )
         {
-            IndexFilteringExtension<Long, ServerEntry> filteringIndex = ( IndexFilteringExtension<Long, ServerEntry> ) oneLevelIndex;
+            IndexFilteringExtension<ID, ServerEntry, ID> filteringIndex = ( IndexFilteringExtension<ID, ServerEntry, ID> ) oneLevelIndex;
             scopeCursor = filteringIndex.forwardFilteringCursor( evaluator.getBaseId(), filter );
         }
         else
@@ -107,25 +105,25 @@
     }
 
 
-    public void beforeValue( Long id, Long value ) throws Exception
+    public void beforeValue( ID id, ID value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void afterValue( Long id, Long value ) throws Exception
+    public void afterValue( ID id, ID value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void before( IndexEntry<Long, ServerEntry> element ) throws Exception
+    public void before( IndexEntry<ID, ServerEntry, ID> element ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void after( IndexEntry<Long, ServerEntry> element ) throws Exception
+    public void after( IndexEntry<ID, ServerEntry, ID> element ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
@@ -303,7 +301,7 @@
     }
 
 
-    public IndexEntry<Long, ServerEntry> get() throws Exception
+    public IndexEntry<ID, ServerEntry, ID> get() throws Exception
     {
         checkNotClosed( "get()" );
         if ( available )

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedOptimizer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedOptimizer.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedOptimizer.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedOptimizer.java Mon Mar  1 22:45:47 2010
@@ -33,14 +33,14 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 777037 $
  */
-public class ExtendedOptimizer<E> extends DefaultOptimizer<E>
+public class ExtendedOptimizer<E, ID> extends DefaultOptimizer<E, ID>
 {
     /** the database this optimizer operates on */
-    private final Store<E> db;
+    private final Store<E, ID> db;
     /** creates cursors over entries satisfying filter expressions */
-    private final ExtendedCursorBuilder cursorBuilder;
+    private final ExtendedCursorBuilder<ID> cursorBuilder;
     /** creates evaluators which check to see if candidates satisfy a filter expression */
-    private final ExtendedEvaluatorBuilder evaluatorBuilder;
+    private final ExtendedEvaluatorBuilder<ID> evaluatorBuilder;
 
 
     /**
@@ -48,8 +48,8 @@
      *
      * @param db the database this optimizer works for.
      */
-    public ExtendedOptimizer( Store<E> db, ExtendedCursorBuilder cursorBuilder,
-        ExtendedEvaluatorBuilder evaluatorBuilder ) throws Exception
+    public ExtendedOptimizer( Store<E, ID> db, ExtendedCursorBuilder<ID> cursorBuilder,
+        ExtendedEvaluatorBuilder<ID> evaluatorBuilder ) throws Exception
     {
         super( db );
         this.db = db;
@@ -95,10 +95,10 @@
     {
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
-            Index<?, E> idx = db.getUserIndex( node.getAttribute() );
-            if ( idx instanceof IndexSubstringExtension<?, ?> )
+            Index<?, E, ID> idx = db.getUserIndex( node.getAttribute() );
+            if ( idx instanceof IndexSubstringExtension<?, ?, ?> )
             {
-                IndexSubstringExtension<?, E> substringIdx = ( IndexSubstringExtension<?, E> ) idx;
+                IndexSubstringExtension<?, E, ID> substringIdx = ( IndexSubstringExtension<?, E, ID> ) idx;
                 return substringIdx.substringCount( node );
             }
         }

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedSubstringCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedSubstringCursor.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedSubstringCursor.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedSubstringCursor.java Mon Mar  1 22:45:47 2010
@@ -36,18 +36,18 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ExtendedSubstringCursor extends AbstractIndexCursor<String, ServerEntry>
+public class ExtendedSubstringCursor<ID> extends AbstractIndexCursor<String, ServerEntry, ID>
 {
     private static final String UNSUPPORTED_MSG = "SubstringCursors may not be ordered and do not support positioning by element.";
     private final boolean hasIndex;
-    private final IndexCursor<String, ServerEntry> wrapped;
-    private final ExtendedSubstringEvaluator evaluator;
-    private final ForwardIndexEntry<String, ServerEntry> indexEntry = new ForwardIndexEntry<String, ServerEntry>();
+    private final IndexCursor<String, ServerEntry, ID> wrapped;
+    private final ExtendedSubstringEvaluator<ID> evaluator;
+    private final ForwardIndexEntry<String, ServerEntry, ID> indexEntry = new ForwardIndexEntry<String, ServerEntry, ID>();
     private boolean available = false;
 
 
     @SuppressWarnings("unchecked")
-    public ExtendedSubstringCursor( Store<ServerEntry> db, final ExtendedSubstringEvaluator substringEvaluator )
+    public ExtendedSubstringCursor( Store<ServerEntry, ID> db, final ExtendedSubstringEvaluator substringEvaluator )
         throws Exception
     {
         evaluator = substringEvaluator;
@@ -55,9 +55,9 @@
 
         if ( hasIndex )
         {
-            Index<String, ServerEntry> idx = ( Index<String, ServerEntry> ) db.getUserIndex( evaluator.getExpression()
+            Index<String, ServerEntry, ID> idx = ( Index<String, ServerEntry, ID> ) db.getUserIndex( evaluator.getExpression()
                 .getAttribute() );
-            if ( idx instanceof IndexSubstringExtension<?, ?> )
+            if ( idx instanceof IndexSubstringExtension<?, ?, ?> )
             {
                 wrapped = ( ( IndexSubstringExtension ) idx ).forwardSubstringCursor( evaluator.getExpression() );
             }
@@ -93,25 +93,25 @@
     }
 
 
-    public void beforeValue( Long id, String value ) throws Exception
+    public void beforeValue( ID id, String value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void afterValue( Long id, String value ) throws Exception
+    public void afterValue( ID id, String value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void before( IndexEntry<String, ServerEntry> element ) throws Exception
+    public void before( IndexEntry<String, ServerEntry, ID> element ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void after( IndexEntry<String, ServerEntry> element ) throws Exception
+    public void after( IndexEntry<String, ServerEntry, ID> element ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
@@ -122,7 +122,7 @@
         checkNotClosed( "beforeFirst()" );
         if ( evaluator.getExpression().getInitial() != null && hasIndex )
         {
-            ForwardIndexEntry<String, ServerEntry> indexEntry = new ForwardIndexEntry<String, ServerEntry>();
+            ForwardIndexEntry<String, ServerEntry, ID> indexEntry = new ForwardIndexEntry<String, ServerEntry, ID>();
             indexEntry.setValue( evaluator.getExpression().getInitial() );
             wrapped.before( indexEntry );
         }
@@ -163,7 +163,7 @@
     }
 
 
-    private boolean evaluateCandidate( IndexEntry<String, ServerEntry> indexEntry ) throws Exception
+    private boolean evaluateCandidate( IndexEntry<String, ServerEntry, ID> indexEntry ) throws Exception
     {
         if ( hasIndex )
         {
@@ -188,7 +188,7 @@
         while ( wrapped.previous() )
         {
             checkNotClosed( "previous()" );
-            IndexEntry<String, ServerEntry> entry = wrapped.get();
+            IndexEntry<String, ServerEntry, ID> entry = wrapped.get();
             if ( evaluateCandidate( entry ) )
             {
                 available = true;
@@ -209,7 +209,7 @@
         while ( wrapped.next() )
         {
             checkNotClosed( "next()" );
-            IndexEntry<String, ServerEntry> entry = wrapped.get();
+            IndexEntry<String, ServerEntry, ID> entry = wrapped.get();
             if ( evaluateCandidate( entry ) )
             {
                 available = true;
@@ -225,7 +225,7 @@
     }
 
 
-    public IndexEntry<String, ServerEntry> get() throws Exception
+    public IndexEntry<String, ServerEntry, ID> get() throws Exception
     {
         checkNotClosed( "get()" );
         if ( available )

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedSubstringEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedSubstringEvaluator.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedSubstringEvaluator.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedSubstringEvaluator.java Mon Mar  1 22:45:47 2010
@@ -45,10 +45,10 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 764131 $
  */
-public class ExtendedSubstringEvaluator implements Evaluator<SubstringNode, ServerEntry>
+public class ExtendedSubstringEvaluator<ID> implements Evaluator<SubstringNode, ServerEntry, ID>
 {
     /** Database used while evaluating candidates */
-    private final Store<ServerEntry> db;
+    private final Store<ServerEntry, ID> db;
 
     /** Schema manager used to translate attributeIds to OIDs */
     private final SchemaManager schemaManager;
@@ -63,7 +63,7 @@
 
     private final Normalizer normalizer;
 
-    private final Index<String, ServerEntry> idx;
+    private final Index<String, ServerEntry, ID> idx;
 
 
     /**
@@ -74,7 +74,7 @@
      * @param registries the set of registries
      * @throws Exception if there are failures accessing resources and the db
      */
-    public ExtendedSubstringEvaluator( SubstringNode node, Store<ServerEntry> db, SchemaManager schemaManager )
+    public ExtendedSubstringEvaluator( SubstringNode node, Store<ServerEntry, ID> db, SchemaManager schemaManager )
         throws Exception
     {
         this.db = db;
@@ -106,7 +106,7 @@
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
             //noinspection unchecked
-            idx = ( Index<String, ServerEntry> ) db.getUserIndex( node.getAttribute() );
+            idx = ( Index<String, ServerEntry, ID> ) db.getUserIndex( node.getAttribute() );
         }
         else
         {
@@ -115,13 +115,13 @@
     }
 
 
-    public boolean evaluate( IndexEntry<?, ServerEntry> indexEntry ) throws Exception
+    public boolean evaluate( IndexEntry<?, ServerEntry, ID> indexEntry ) throws Exception
     {
 
         if ( idx == null || indexEntry.getObject() != null )
         {
             //noinspection unchecked
-            return evaluateWithoutIndex( ( IndexEntry<String, ServerEntry> ) indexEntry );
+            return evaluateWithoutIndex( ( IndexEntry<String, ServerEntry, ID> ) indexEntry );
         }
         else
         {
@@ -130,7 +130,7 @@
     }
 
 
-    public boolean evaluate( Long id ) throws Exception
+    public boolean evaluateId( ID id ) throws Exception
     {
 
         if ( idx == null )
@@ -145,7 +145,7 @@
     }
 
 
-    public boolean evaluate( ServerEntry entry ) throws Exception
+    public boolean evaluateEntry( ServerEntry entry ) throws Exception
     {
 
         if ( idx == null )
@@ -172,7 +172,7 @@
     }
 
 
-    private boolean evaluateWithIndex( IndexEntry<?, ServerEntry> indexEntry ) throws Exception
+    private boolean evaluateWithIndex( IndexEntry<?, ServerEntry, ID> indexEntry ) throws Exception
     {
         /*
          * Note that this is using the reverse half of the index giving a
@@ -180,15 +180,15 @@
          * Otherwise we would have to scan the entire index if there were
          * no reverse lookups.
          */
-        Cursor<IndexEntry<String, ServerEntry>> entries = idx.reverseCursor( indexEntry.getId() );
+        Cursor<IndexEntry<String, ServerEntry, ID>> entries = idx.reverseCursor( indexEntry.getId() );
 
         // cycle through the attribute values testing for a match
         while ( entries.next() )
         {
-            IndexEntry rec = entries.get();
+            IndexEntry<String, ServerEntry, ID> rec = entries.get();
 
             // once match is found cleanup and return true
-            if ( regex.matcher( ( String ) rec.getValue() ).matches() )
+            if ( regex.matcher( rec.getValue() ).matches() )
             {
                 entries.close();
                 return true;
@@ -200,15 +200,13 @@
     }
 
 
-    @SuppressWarnings(
-        { "UnusedDeclaration" })
     private boolean evaluateWithIndex( ServerEntry entry ) throws Exception
     {
         throw new UnsupportedOperationException( "This is too inefficient without getId() on ServerEntry" );
     }
 
 
-    private boolean evaluateWithIndex( Long id ) throws Exception
+    private boolean evaluateWithIndex( ID id ) throws Exception
     {
         /*
          * Note that this is using the reverse half of the index giving a
@@ -216,15 +214,15 @@
          * Otherwise we would have to scan the entire index if there were
          * no reverse lookups.
          */
-        Cursor<IndexEntry<String, ServerEntry>> entries = idx.reverseCursor( id );
+        Cursor<IndexEntry<String, ServerEntry, ID>> entries = idx.reverseCursor( id );
 
         // cycle through the attribute values testing for a match
         while ( entries.next() )
         {
-            IndexEntry rec = entries.get();
+            IndexEntry<String, ServerEntry, ID> rec = entries.get();
 
             // once match is found cleanup and return true
-            if ( regex.matcher( ( String ) rec.getValue() ).matches() )
+            if ( regex.matcher( rec.getValue() ).matches() )
             {
                 entries.close();
                 return true;
@@ -238,7 +236,7 @@
 
     // TODO - determine if comaparator and index entry should have the Value
     // wrapper or the raw normalized value
-    private boolean evaluateWithoutIndex( Long id ) throws Exception
+    private boolean evaluateWithoutIndex( ID id ) throws Exception
     {
         return evaluateWithoutIndex( db.lookup( id ) );
     }
@@ -260,7 +258,7 @@
              * The test uses the comparator obtained from the appropriate
              * substring matching rule.
              */
-            for ( Value value : attr )
+            for ( Value<?> value : attr )
             {
                 value.normalize( normalizer );
                 String strValue = ( String ) value.getNormalizedValue();
@@ -301,7 +299,7 @@
                      * The test uses the comparator obtained from the appropriate
                      * substring matching rule.
                      */
-                    for ( Value value : attr )
+                    for ( Value<?> value : attr )
                     {
                         value.normalize( normalizer );
                         String strValue = ( String ) value.getNormalizedValue();
@@ -323,7 +321,7 @@
 
     // TODO - determine if comaparator and index entry should have the Value
     // wrapper or the raw normalized value
-    private boolean evaluateWithoutIndex( IndexEntry<String, ServerEntry> indexEntry ) throws Exception
+    private boolean evaluateWithoutIndex( IndexEntry<String, ServerEntry, ID> indexEntry ) throws Exception
     {
         ServerEntry entry = indexEntry.getObject();
 
@@ -352,7 +350,7 @@
              * The test uses the comparator obtained from the appropriate
              * substring matching rule.
              */
-            for ( Value value : attr )
+            for ( Value<?> value : attr )
             {
                 value.normalize( normalizer );
                 String strValue = ( String ) value.getNormalizedValue();
@@ -395,7 +393,7 @@
                      * The test uses the comparator obtained from the appropriate
                      * substring matching rule.
                      */
-                    for ( Value value : attr )
+                    for ( Value<?> value : attr )
                     {
                         value.normalize( normalizer );
                         String strValue = ( String ) value.getNormalizedValue();

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedSubtreeScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedSubtreeScopeCursor.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedSubtreeScopeCursor.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/ExtendedSubtreeScopeCursor.java Mon Mar  1 22:45:47 2010
@@ -39,29 +39,29 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ExtendedSubtreeScopeCursor extends AbstractIndexCursor<Long, ServerEntry>
+public class ExtendedSubtreeScopeCursor<ID> extends AbstractIndexCursor<ID, ServerEntry, ID>
 {
     private static final String UNSUPPORTED_MSG = "Scope Cursors are not ordered and do not support positioning by element.";
 
     /** The Entry database/store */
-    private final Store<ServerEntry> db;
+    private final Store<ServerEntry, ID> db;
 
     /** A ScopeNode Evaluator */
-    private final SubtreeScopeEvaluator<ServerEntry> evaluator;
+    private final SubtreeScopeEvaluator<ServerEntry, ID> evaluator;
 
     /** A Cursor over the entries in the scope of the search base */
-    private final IndexCursor<Long, ServerEntry> scopeCursor;
+    private final IndexCursor<ID, ServerEntry, ID> scopeCursor;
 
     /** A Cursor over entries brought into scope by alias dereferencing */
-    private final IndexCursor<Long, ServerEntry> dereferencedCursor;
+    private final IndexCursor<ID, ServerEntry, ID> dereferencedCursor;
 
     /** Currently active Cursor: we switch between two cursors */
-    private IndexCursor<Long, ServerEntry> cursor;
+    private IndexCursor<ID, ServerEntry, ID> cursor;
 
     /** Whether or not this Cursor is positioned so an entry is available */
     private boolean available = false;
 
-    private Long contextEntryId;
+    private ID contextEntryId;
 
 
     /**
@@ -72,21 +72,21 @@
      * @param evaluator an IndexEntry (candidate) evaluator
      * @throws Exception on db access failures
      */
-    public ExtendedSubtreeScopeCursor( Store<ServerEntry> db, ExprNode filter,
-        SubtreeScopeEvaluator<ServerEntry> evaluator ) throws Exception
+    public ExtendedSubtreeScopeCursor( Store<ServerEntry, ID> db, ExprNode filter,
+        SubtreeScopeEvaluator<ServerEntry, ID> evaluator ) throws Exception
     {
         this.db = db;
         this.evaluator = evaluator;
 
-        Index<Long, ServerEntry> subLevelIndex = db.getSubLevelIndex();
-        if ( subLevelIndex instanceof IndexFilteringExtension<?, ?> )
+        Index<ID, ServerEntry, ID> subLevelIndex = db.getSubLevelIndex();
+        if ( subLevelIndex instanceof IndexFilteringExtension<?, ?, ?> )
         {
-            IndexFilteringExtension<Long, ServerEntry> filteringIndex = ( IndexFilteringExtension<Long, ServerEntry> ) subLevelIndex;
+            IndexFilteringExtension<ID, ServerEntry, ID> filteringIndex = ( IndexFilteringExtension<ID, ServerEntry, ID> ) subLevelIndex;
             scopeCursor = filteringIndex.forwardFilteringCursor( evaluator.getBaseId(), filter );
         }
-        else if ( evaluator.getBaseId() == getContextEntryId() )
+        else if ( evaluator.getBaseId().equals( getContextEntryId() ) )
         {
-            scopeCursor = new AllEntriesCursor( db );
+            scopeCursor = new AllEntriesCursor<ID>( db );
         }
         else
         {
@@ -104,7 +104,7 @@
     }
 
 
-    private Long getContextEntryId()
+    private ID getContextEntryId() throws Exception
     {
         if ( contextEntryId == null )
         {
@@ -121,7 +121,7 @@
 
         if ( contextEntryId == null )
         {
-            return 1L;
+            return db.getDefaultId();
         }
 
         return contextEntryId;
@@ -134,25 +134,25 @@
     }
 
 
-    public void beforeValue( Long id, Long value ) throws Exception
+    public void beforeValue( ID id, ID value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void before( IndexEntry<Long, ServerEntry> element ) throws Exception
+    public void before( IndexEntry<ID, ServerEntry, ID> element ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void afterValue( Long id, Long value ) throws Exception
+    public void afterValue( ID id, ID value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void after( IndexEntry<Long, ServerEntry> element ) throws Exception
+    public void after( IndexEntry<ID, ServerEntry, ID> element ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
@@ -329,7 +329,7 @@
     }
 
 
-    public IndexEntry<Long, ServerEntry> get() throws Exception
+    public IndexEntry<ID, ServerEntry, ID> get() throws Exception
     {
         checkNotClosed( "get()" );
         if ( available )

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/IndexFilteringExtension.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/IndexFilteringExtension.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/IndexFilteringExtension.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/IndexFilteringExtension.java Mon Mar  1 22:45:47 2010
@@ -31,10 +31,10 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 787602 $
  */
-public interface IndexFilteringExtension<K, O> extends Index<K, O>
+public interface IndexFilteringExtension<K, O, ID> extends Index<K, O, ID>
 {
 
-    IndexCursor<K, O> forwardFilteringCursor( Long id, ExprNode filter ) throws Exception;
-    //IndexCursor<K, O> reverseCursor( Long id, ExprNode filter ) throws Exception;
+    IndexCursor<K, O, ID> forwardFilteringCursor( ID id, ExprNode filter ) throws Exception;
+    //IndexCursor<K, O, ID> reverseCursor( ID id, ExprNode filter ) throws Exception;
 
 }

Modified: directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/IndexSubstringExtension.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/IndexSubstringExtension.java?rev=917770&r1=917769&r2=917770&view=diff
==============================================================================
--- directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/IndexSubstringExtension.java (original)
+++ directory/sandbox/seelmann/hbase-partition/src/main/java/org/apache/directory/server/core/partition/hbase/xdbmext/IndexSubstringExtension.java Mon Mar  1 22:45:47 2010
@@ -33,7 +33,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 787602 $
  */
-public interface IndexSubstringExtension<K, O> extends Index<K, O>
+public interface IndexSubstringExtension<K, O, ID> extends Index<K, O, ID>
 {
 
     int substringCount( SubstringNode node ) throws Exception;
@@ -42,10 +42,10 @@
     boolean forwardSubstring( SubstringNode node, Pattern valuePattern ) throws Exception;
 
 
-    boolean forwardSubstring( SubstringNode node, Pattern valuePattern, Long id ) throws Exception;
+    boolean forwardSubstring( SubstringNode node, Pattern valuePattern, ID id ) throws Exception;
 
 
-    IndexCursor<Object, O> forwardSubstringCursor( SubstringNode node ) throws Exception;
+    IndexCursor<Object, O, ID> forwardSubstringCursor( SubstringNode node ) throws Exception;
 
     //boolean reverseGreaterOrEq( Long id ) throws Exception;
     //boolean reverseGreaterOrEq( Long id, K attrVal ) throws Exception;



Mime
View raw message