Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 32745 invoked from network); 15 Mar 2007 17:52:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Mar 2007 17:52:57 -0000 Received: (qmail 4868 invoked by uid 500); 15 Mar 2007 17:53:05 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 4837 invoked by uid 500); 15 Mar 2007 17:53:05 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 4815 invoked by uid 99); 15 Mar 2007 17:53:05 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Mar 2007 10:53:05 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Mar 2007 10:52:56 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id B645A1A9838; Thu, 15 Mar 2007 10:52:35 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r518708 - in /directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm: AttributeSerializer.java AttributesSerializer.java JdbmIndex.java JdbmMasterTable.java JdbmTable.java Date: Thu, 15 Mar 2007 17:52:35 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070315175235.B645A1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Thu Mar 15 10:52:34 2007 New Revision: 518708 URL: http://svn.apache.org/viewvc?view=rev&rev=518708 Log: Moved the Attribute(s)Serializer down to this project, to avoid cyclic dependencies. Modified the JdbmMasterTable to pass a keySerializer and a valueSerializer to the modified JdbmTRable constructor Modified JdbmTable to take two new arguments (which can be null) : a keySerializer and a valueSerializer. If the serializer is null, jdbm will use the default one (java serialization default method) Did the same with JdbmIndex, which creates BTrees too Added: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributeSerializer.java - copied, changed from r518575, directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributeSerializer.java directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributesSerializer.java - copied, changed from r518575, directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributesSerializer.java Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java Copied: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributeSerializer.java (from r518575, directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributeSerializer.java) URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributeSerializer.java?view=diff&rev=518708&p1=directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributeSerializer.java&r1=518575&p2=directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributeSerializer.java&r2=518708 ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributeSerializer.java (original) +++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributeSerializer.java Thu Mar 15 10:52:34 2007 @@ -1,488 +1,32 @@ -/* - * 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.impl.btree.jdbm; +package org.apache.directory.server.core.partition.impl.btree.jdbm; import java.io.IOException; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attribute; - -import org.apache.directory.shared.ldap.message.AttributeImpl; +import org.apache.directory.shared.ldap.util.AttributeSerializerUtils; import jdbm.helper.Serializer; - -/** - * Serializes a attributes object using a custom serialization mechanism - * so we do not have to rely on Java Serialization which is much more - * costly. - * - * @author Apache Directory Project - * @version $Rev$, $Date$ - */ public class AttributeSerializer implements Serializer { - private static final long serialVersionUID = -3756830073760754086L; - - static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; - - /** value for type parameter for string (non-binary) attributes */ - static final byte STRING_TYPE = 0x00; - /** value for type parameter for byte array (binary) attributes */ - static final byte BYTE_ARRAY_TYPE = 0x01; - + private static final long serialVersionUID = 1L; - // ----------------------------------------------------------------------- - // Methods for deserialization - // ----------------------------------------------------------------------- - - - /** - * Deserializes an attribute from the custom serialization structure. - * - * @see jdbm.helper.Serializer#deserialize(byte[]) - */ - public final Object deserialize( byte[] buf ) throws IOException - { - String id = readString( buf ); - AttributeImpl attr = new AttributeImpl( id ); - int pos = ( id.length() << 1 ) + 4; - - // read the type of the objects stored in this attribute - if ( buf[pos] == STRING_TYPE ) - { - pos++; - while ( pos < buf.length ) - { - String value = readString( buf, pos ); - pos += ( value.length() << 1 ) + 4; - attr.add( value ); - } - } - else - { - pos++; - while ( pos < buf.length ) - { - byte[] value = readBytes( buf, pos ); - pos += value.length + 4; - attr.add( value ); - } - } - - return attr; - } - - /** - * Deserializes an attribute from the custom serialization structure. - * + /* (non-Javadoc) * @see jdbm.helper.Serializer#deserialize(byte[]) */ - public static final DeserializedAttribute deserialize( byte[] buf, int offset ) throws IOException - { - final String id = readString( buf, offset ); - final AttributeImpl attr = new AttributeImpl( id ); - int pos = ( id.length() << 1 ) + 4 + offset; - - // read the type of the objects stored in this attribute - if ( buf[pos] == STRING_TYPE ) - { - pos++; - while ( pos < buf.length ) - { - String value = readString( buf, pos ); - pos += ( value.length() << 1 ) + 4; - attr.add( value ); - } - } - else - { - pos++; - while ( pos < buf.length ) - { - byte[] value = readBytes( buf, pos ); - pos += value.length + 4; - attr.add( value ); - } - } - - return new DeserializedAttribute( attr, pos ); - } - - - final static class DeserializedAttribute - { - private final int pos; - private final Attribute attr; - - private DeserializedAttribute( Attribute attr, int pos ) - { - this.pos = pos; - this.attr = attr; - } - - public int getPos() - { - return pos; - } - - public Attribute getAttr() - { - return attr; - } - } - - - /** - * Reads a String and it's length bytes from a buffer starting at - * position 0. - * - * @param buf the buffer to read the length and character bytes from - * @return the String contained at the start of the buffer - */ - static final String readString( byte[] buf ) - { - int length = getLength( buf ); - - if ( length == 0 ) - { - return ""; - } - - // create the new char buffer - char[] strchars = new char[length>>1]; - - int ch = 0; - for ( int ii = 0, jj = 0; ii < strchars.length; ii++ ) - { - jj = ( ii << 1 ) + 4; - ch = buf[jj] << 8 & 0x0000FF00; - ch |= buf[jj+1] & 0x000000FF; - strchars[ii] = ( char ) ch; - } - - return new String( strchars ); - } - - - /** - * Reads a String and it's length bytes from a buffer starting at - * a specific offset. - * - * @param buf the buffer to read the length and character bytes from - * @param offset the offset into the buffer to start reading from - * @return the String contained at the offset in the buffer - */ - static final String readString( byte[] buf, int offset ) + public Object deserialize( byte[] data ) throws IOException { - int length = getLength( buf, offset ); - - if ( length == 0 ) - { - return ""; - } - - // create the new char buffer - char[] strchars = new char[length>>1]; - - int ch = 0; - for ( int ii = 0, jj = 0; ii < strchars.length; ii++ ) - { - jj = ( ii << 1 ) + 4 + offset; - ch = buf[jj] << 8 & 0x0000FF00; - ch |= buf[jj+1] & 0x000000FF; - strchars[ii] = ( char ) ch; - } - - return new String( strchars ); + return AttributeSerializerUtils.deserialize( data ); } - - - /** - * Reads a byte array from a buffer including its length starting - * from an offset in the buffer. - * - * @param buf the buffer to read the byte array from - * @param offset the offset to start reading from starting with 4-byte length - * @return the byte array contained in the buffer - */ - static final byte[] readBytes( byte[] buf, int offset ) - { - int length = getLength( buf, offset ); - - if ( length == 0 ) - { - return EMPTY_BYTE_ARRAY; - } - byte[] bites = new byte[length]; - System.arraycopy( buf, offset+4, bites, 0, length ); - return bites; - } - - // ----------------------------------------------------------------------- - // Methods for serialization - // ----------------------------------------------------------------------- - - - /** - * Serializes an attribute using the following structure: - * - * [id-length][id-bytes][is-binary][length0][value0]...[lengthN][valueN] - * - * - * Here the id-length is the 4 byte int value of the length of bytes - * for the id string bytes. The id-bytes are the bytes for the id string. - * The is-binary byte is a true or false for whether or not the values - * are byte[] or String types. Following this is an array of length-value - * tuples for the values of the Attributes. - * + /* (non-Javadoc) + * @see jdbm.helper.Serializer#serialize(java.lang.Object) */ - public byte[] serialize( Object obj ) throws IOException - { - Attribute attr = ( Attribute ) obj; - - // calculate the size of the entire byte[] and allocate - byte[] buf = new byte[calculateSize( attr )]; - - // write the length of the id and it's value - int pos = write( buf, attr.getID() ); - - try - { - // write the type or is-binary field - Object first = attr.get(); - if ( first instanceof String ) - { - buf[pos] = STRING_TYPE; - pos++; - - // write out each value to the buffer whatever type it may be - for ( NamingEnumeration ii = attr.getAll(); ii.hasMore(); /**/ ) - { - String value = ( String ) ii.next(); - pos = write( buf, value, pos ); - } - } - else - { - buf[pos] = BYTE_ARRAY_TYPE; - pos++; - - // write out each value to the buffer whatever type it may be - for ( NamingEnumeration ii = attr.getAll(); ii.hasMore(); /**/ ) - { - byte[] value = ( byte[] ) ii.next(); - pos = write( buf, value, pos ); - } - } - - } - catch ( NamingException e ) - { - IOException ioe = new IOException( "Failed while accesssing attribute values." ); - ioe.initCause( e ); - throw ioe; - } - - return buf; - } - - - static final int calculateSize( Attribute attr ) throws IOException - { - int size = 4; // start with first length for attribute id - size += attr.getID().length() << 1; // the length of id * 2 added - size++; // add one for the type - - try - { - for ( NamingEnumeration ii = attr.getAll(); ii.hasMore(); /**/ ) - { - Object value = ii.next(); - if ( value instanceof String ) - { - size += ( ( String ) value ).length() << 1; // length of sting * 2 - } - else - { - size += ( ( byte [] ) value ).length; // no need to multiply byte[]s - } - - size += 4; // add 4 bytes for a length - } - } - catch ( NamingException e ) - { - IOException ioe = new IOException( "Failed while accesssing attribute values." ); - ioe.initCause( e ); - throw ioe; - } - - return size; - } - - - static final byte[] getLengthBytes( String str ) - { - return getLengthBytes( str.length() << 1 ); - } - - - static final byte[] getLengthBytes( byte[] bites ) + public byte[] serialize( Object data ) throws IOException { - return getLengthBytes( bites.length ); + return AttributeSerializerUtils.serialize( data ); } - - static final byte[] getLengthBytes( int length ) - { - byte[] lengthBytes = new byte[4]; - - lengthBytes[0] = ( byte ) ( length >> 24 & 0x000000FF ); - lengthBytes[1] = ( byte ) ( length >> 16 & 0x000000FF ); - lengthBytes[2] = ( byte ) ( length >> 8 & 0x000000FF ); - lengthBytes[3] = ( byte ) ( length & 0x000000FF ); - - return lengthBytes; - } - - - static final int getLength( byte[] bites ) - { - int length = bites[0] << 24 & 0xFF000000; - length |= bites[1] << 16 & 0x00FF0000; - length |= bites[2] << 8 & 0x0000FF00; - length |= bites[3] & 0x000000FF; - - return length; - } - - - static final int getLength( byte[] bites, int offset ) - { - int length = bites[offset] << 24 & 0xFF000000; - length |= bites[offset+1] << 16 & 0x00FF0000; - length |= bites[offset+2] << 8 & 0x0000FF00; - length |= bites[offset+3] & 0x000000FF; - - return length; - } - - - static final int write( byte[] buf, String value ) - { - int pos = writeLengthBytes( buf, value.length() << 1 ); - return writeValueBytes( buf, value, pos ); - } - - - static final int write( byte[] buf, byte[] value ) - { - int pos = writeLengthBytes( buf, value.length ); - return writeValueBytes( buf, value, pos ); - } - - - static final int write( byte[] buf, String value, int offset ) - { - offset = writeLengthBytes( buf, value.length() << 1, offset ); - return writeValueBytes( buf, value, offset ); - } - - - static final int write( byte[] buf, byte[] value, int offset ) - { - offset = writeLengthBytes( buf, value.length, offset ); - return writeValueBytes( buf, value, offset ); - } - - - static final int writeValueBytes( byte[] buf, String value ) - { - if ( ( ( String ) value ).length() == 0 ) - { - return 0; - } - - char[] strchars = ( ( String ) value ).toCharArray(); - int jj = 0; - for ( int ii = 0; ii < strchars.length; ii++, jj = ii << 1 ) - { - buf[jj] = ( byte ) ( strchars[ii] >> 8 & 0x00FF ); - buf[jj+1] = ( byte ) ( strchars[ii] & 0x00FF ); - } - return jj+2; - } - - - static final int writeValueBytes( byte[] buf, String value, int offset ) - { - if ( ( ( String ) value ).length() == 0 ) - { - return offset; - } - - char[] strchars = ( ( String ) value ).toCharArray(); - int jj = 0; - for ( int ii = 0; ii < strchars.length; ii++, jj = ii << 1 ) - { - buf[jj+offset] = ( byte ) ( strchars[ii] >> 8 & 0x00FF ); - buf[jj+offset+1] = ( byte ) ( strchars[ii] & 0x00FF ); - } - return jj+offset; - } - - - static final int writeValueBytes( byte[] buf, byte[] value, int offset ) - { - if ( value.length == 0 ) - { - return offset; - } - - System.arraycopy( value, 0, buf, offset, value.length ); - return offset + value.length; - } - - - static final int writeLengthBytes( byte[] buf, int length ) - { - buf[0] = ( byte ) ( length >> 24 & 0x000000FF ); - buf[1] = ( byte ) ( length >> 16 & 0x000000FF ); - buf[2] = ( byte ) ( length >> 8 & 0x000000FF ); - buf[3] = ( byte ) ( length & 0x000000FF ); - return 4; - } - - - static final int writeLengthBytes( byte[] buf, int length, int offset ) - { - buf[0+offset] = ( byte ) ( length >> 24 & 0x000000FF ); - buf[1+offset] = ( byte ) ( length >> 16 & 0x000000FF ); - buf[2+offset] = ( byte ) ( length >> 8 & 0x000000FF ); - buf[3+offset] = ( byte ) ( length & 0x000000FF ); - return offset+4; - } } Copied: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributesSerializer.java (from r518575, directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributesSerializer.java) URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributesSerializer.java?view=diff&rev=518708&p1=directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributesSerializer.java&r1=518575&p2=directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributesSerializer.java&r2=518708 ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributesSerializer.java (original) +++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/AttributesSerializer.java Thu Mar 15 10:52:34 2007 @@ -1,191 +1,32 @@ -/* - * 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.impl.btree.jdbm; +package org.apache.directory.server.core.partition.impl.btree.jdbm; import java.io.IOException; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attribute; -import javax.naming.directory.Attributes; - -import org.apache.directory.shared.ldap.message.AttributeImpl; -import org.apache.directory.shared.ldap.message.AttributesImpl; +import org.apache.directory.shared.ldap.util.AttributesSerializerUtils; import jdbm.helper.Serializer; - -/** - * - * @author Apache Directory Project - * @version $Rev$, $Date$ - */ public class AttributesSerializer implements Serializer { - private static final long serialVersionUID = -3756830073760754086L; - private static final byte SEPARATOR = -1; + private static final long serialVersionUID = 1L; - /** + /* (non-Javadoc) * @see jdbm.helper.Serializer#deserialize(byte[]) */ - public Object deserialize( byte[] buf ) throws IOException + public Object deserialize( byte[] data ) throws IOException { - if ( buf.length == 0 ) - { - return new AttributesImpl(); - } - - int pos = 0; - AttributesImpl attrs = new AttributesImpl(); - while ( pos < buf.length ) - { - String id = AttributeSerializer.readString( buf, pos ); - AttributeImpl attr = new AttributeImpl( id ); - pos += ( id.length() << 1 ) + 4; - - // read the type of the objects stored in this attribute - if ( buf[pos] == AttributeSerializer.STRING_TYPE ) - { - pos++; - while ( pos < buf.length && buf[pos] != SEPARATOR ) - { - String value = AttributeSerializer.readString( buf, pos ); - pos += ( value.length() << 1 ) + 4; - attr.add( value ); - } - } - else - { - pos++; - while ( pos < buf.length && buf[pos] != SEPARATOR ) - { - byte[] value = AttributeSerializer.readBytes( buf, pos ); - pos += value.length + 4; - attr.add( value ); - } - } - - pos++; // skip the separator - attrs.put( attr ); - } - - return attrs; + return AttributesSerializerUtils.deserialize( data ); } - /** + /* (non-Javadoc) * @see jdbm.helper.Serializer#serialize(java.lang.Object) */ - public byte[] serialize( Object attrsObj ) throws IOException + public byte[] serialize( Object data ) throws IOException { - Attributes attrs = ( Attributes ) attrsObj; - - // calculate the size of the entire byte[] and allocate - byte[] buf = new byte[calculateSize( attrs )]; - int pos = 0; - try - { - for ( NamingEnumeration ii = attrs.getAll(); ii.hasMore(); /**/) - { - // get an attribute at a time - Attribute attr = ( Attribute ) ii.next(); - - // write the length of the id and it's value - pos = AttributeSerializer.write( buf, attr.getID(), pos ); - - // write the type or is-binary field - Object first = attr.get(); - if ( first instanceof String ) - { - buf[pos] = AttributeSerializer.STRING_TYPE; - pos++; - - // write out each value to the buffer whatever type it may be - for ( NamingEnumeration jj = attr.getAll(); jj.hasMore(); /**/) - { - String value = ( String ) jj.next(); - pos = AttributeSerializer.write( buf, value, pos ); - } - } - else - { - buf[pos] = AttributeSerializer.BYTE_ARRAY_TYPE; - pos++; - - // write out each value to the buffer whatever type it may be - for ( NamingEnumeration jj = attr.getAll(); jj.hasMore(); /**/) - { - byte[] value = ( byte[] ) jj.next(); - pos = AttributeSerializer.write( buf, value, pos ); - } - } - - if ( ii.hasMore() ) - { - buf[pos] = SEPARATOR; - pos++; - } - } - } - catch ( NamingException e ) - { - IOException ioe = new IOException( "Failed while accesssing attributes and/or their values." ); - ioe.initCause( e ); - throw ioe; - } - - return buf; + return AttributesSerializerUtils.serialize( data ); } - - public int calculateSize( Attributes attrs ) throws IOException - { - int size = 0; - - try - { - for ( NamingEnumeration ii = attrs.getAll(); ii.hasMore(); /**/) - { - Attribute attr = ( Attribute ) ii.next(); - - if ( ii.hasMore() ) - { - // augment by attribute size and 1 for the separator - size += AttributeSerializer.calculateSize( attr ) + 1; - } - else - { - // augment by attribute size only since there are no more attributes left - size += AttributeSerializer.calculateSize( attr ); - } - } - } - catch ( NamingException e ) - { - IOException ioe = new IOException( "Failed while accesssing attributes." ); - ioe.initCause( e ); - throw ioe; - } - - return size; - } } Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?view=diff&rev=518708&r1=518707&r2=518708 ============================================================================== --- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original) +++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Thu Mar 15 10:52:34 2007 @@ -30,6 +30,7 @@ import javax.naming.directory.Attributes; import jdbm.RecordManager; +import jdbm.helper.LongSerializer; import jdbm.helper.MRU; import jdbm.recman.BaseRecordManager; import jdbm.recman.CacheRecordManager; @@ -137,7 +138,14 @@ * primary keys. A value for an attribute can occur several times in * different entries so the forward map can have more than one value. */ - forward = new JdbmTable( attribute.getName() + FORWARD_BTREE, true, numDupLimit, recMan, new IndexComparator( comp, true ) ); + forward = new JdbmTable( + attribute.getName() + FORWARD_BTREE, + true, + numDupLimit, + recMan, + new IndexComparator( comp, true ), + null, null ); + //LongSerializer.INSTANCE ); /* * Now the reverse map stores the primary key into the master table as @@ -145,8 +153,14 @@ * is single valued according to its specification based on a schema * then duplicate keys should not be allowed within the reverse table. */ - reverse = new JdbmTable( attribute.getName() + REVERSE_BTREE, !attribute.isSingleValue(), numDupLimit, recMan, - new IndexComparator( comp, false ) ); + reverse = new JdbmTable( + attribute.getName() + REVERSE_BTREE, + !attribute.isSingleValue(), + numDupLimit, + recMan, + new IndexComparator( comp, false ), + null, //LongSerializer.INSTANCE, + null); } Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java?view=diff&rev=518708&r1=518707&r2=518708 ============================================================================== --- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java (original) +++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java Thu Mar 15 10:52:34 2007 @@ -24,11 +24,14 @@ import javax.naming.directory.Attributes; import jdbm.RecordManager; +import jdbm.helper.LongSerializer; +import jdbm.helper.Serializer; import jdbm.helper.StringComparator; import org.apache.directory.server.core.partition.impl.btree.MasterTable; import org.apache.directory.server.schema.SerializableComparator; //import org.apache.directory.shared.ldap.util.BigIntegerComparator; +import org.apache.directory.shared.ldap.util.AttributesSerializerUtils; import org.apache.directory.shared.ldap.util.LongComparator; @@ -75,8 +78,8 @@ */ public JdbmMasterTable(RecordManager recMan) throws NamingException { - super( DBF, recMan, LONG_COMPARATOR ); - adminTbl = new JdbmTable( "admin", recMan, STRING_COMPARATOR ); + super( DBF, recMan, LONG_COMPARATOR, LongSerializer.INSTANCE, new AttributesSerializer() ); + adminTbl = new JdbmTable( "admin", recMan, STRING_COMPARATOR, null, null ); String seqValue = ( String ) adminTbl.get( SEQPROP_KEY ); if ( null == seqValue ) Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java?view=diff&rev=518708&r1=518707&r2=518708 ============================================================================== --- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java (original) +++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java Thu Mar 15 10:52:34 2007 @@ -35,6 +35,7 @@ import jdbm.RecordManager; import jdbm.btree.BTree; +import jdbm.helper.Serializer; import jdbm.helper.TupleBrowser; import org.apache.commons.collections.iterators.ArrayIterator; @@ -101,9 +102,14 @@ * @throws NamingException if the table's file cannot be created */ public JdbmTable( String name, boolean allowsDuplicates, int numDupLimit, - RecordManager manager, TupleComparator comparator ) + RecordManager manager, TupleComparator comparator, Serializer keySerializer, + Serializer valueSerializer ) throws NamingException { + /*System.out.println( "Creating BTree for " + name + ", key serializer = " + + (keySerializer == null ? "null" : keySerializer.getClass().getName()) + + ", valueSerializer = " + + (valueSerializer == null ? "null" : valueSerializer.getClass().getName()) );*/ this.numDupLimit = numDupLimit; this.name = name; this.recMan = manager; @@ -138,7 +144,7 @@ } else { - bt = BTree.createInstance( recMan, comparator.getKeyComparator() ); + bt = BTree.createInstance( recMan, comparator.getKeyComparator(), keySerializer, valueSerializer ); recId = bt.getRecid(); recMan.setNamedObject( name, recId ); recId = recMan.insert( new Integer( 0 ) ); @@ -163,9 +169,10 @@ * @param keyComparator a tuple comparator * @throws NamingException if the table's file cannot be created */ - public JdbmTable( String name, RecordManager manager, SerializableComparator keyComparator ) throws NamingException + public JdbmTable( String name, RecordManager manager, SerializableComparator keyComparator, Serializer keySerializer, Serializer valueSerializer ) + throws NamingException { - this( name, false, Integer.MAX_VALUE, manager, new KeyOnlyComparator( keyComparator ) ); + this( name, false, Integer.MAX_VALUE, manager, new KeyOnlyComparator( keyComparator ), keySerializer, valueSerializer ); }