directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r636474 - /directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java
Date Wed, 12 Mar 2008 19:27:24 GMT
Author: kayyagari
Date: Wed Mar 12 12:27:22 2008
New Revision: 636474

URL: http://svn.apache.org/viewvc?rev=636474&view=rev
Log:
changed the AvlTree wire format. Now starts with a Zero byte.
Updated the serialize method to assign index numbers to each node present in the linked list
of AvlTree

Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java?rev=636474&r1=636473&r2=636474&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java
Wed Mar 12 12:27:22 2008
@@ -70,12 +70,21 @@
             return null;
         }
 
+        LinkedAvlNode<E> x = tree.getFirst().next;
+        
+        while( x != null )
+        {
+            x.setIndex( x.previous.getIndex() + 1 );  
+            x = x.next;
+        }
+        
         ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
         DataOutputStream out = new DataOutputStream( byteStream );
         byte[] data = null;
         
         try
         {
+            out.writeByte( 0 ); // represents the start of AvlTree byte stream
             out.writeInt( tree.getSize() );
             writeTree( tree.getRoot(), out );
             out.flush();
@@ -94,6 +103,7 @@
      * writes the content of the AVLTree to an output stream.
      * The current format is 
      *  
+     *  AvlTree = [0(zero-byte-value)][node] // the '0' (zero) is to distinguish AvlTree
from BTreeRedirect which starts with 1 (one)
      *   node = [size] [data-length] [data] [index] [child-marker] [node] [child-marker]
[node]
      *
      * @param node the node to be marshalled to bytes
@@ -143,6 +153,13 @@
         
         try
         {
+            byte startByte = din.readByte();
+            
+            if( startByte != 0 )
+            {
+                throw new IOException("wrong AvlTree serialized data format");
+            }
+            
             int size = din.readInt();
             
             nodes = new LinkedAvlNode[ size ];



Mime
View raw message