activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r691268 - in /activemq/sandbox/kahadb/src/main/java/org/apache/kahadb: page/BTreeIndex.java page/BTreeNode.java page/Page.java page/PageFile.java page/Transaction.java util/DataByteArrayOutputStream.java
Date Tue, 02 Sep 2008 14:52:17 GMT
Author: chirino
Date: Tue Sep  2 07:52:17 2008
New Revision: 691268

URL: http://svn.apache.org/viewvc?rev=691268&view=rev
Log:
Added some more helpful methods..


Modified:
    activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/BTreeIndex.java
    activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/BTreeNode.java
    activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/Page.java
    activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java
    activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/Transaction.java
    activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayOutputStream.java

Modified: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/BTreeIndex.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/BTreeIndex.java?rev=691268&r1=691267&r2=691268&view=diff
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/BTreeIndex.java (original)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/BTreeIndex.java Tue Sep 
2 07:52:17 2008
@@ -116,7 +116,7 @@
     }    
 
     private final PageFile pageFile;
-    private final long rootPageId;
+    private final long pageId;
     private AtomicBoolean loaded = new AtomicBoolean();
     
     private final BTreeNode.Marshaller<Key, Value> marshaller = new BTreeNode.Marshaller<Key,
Value>(this);
@@ -129,7 +129,7 @@
     public BTreeIndex(PageFile pageFile, long rootPageId) {
         super();
         this.pageFile = pageFile;
-        this.rootPageId = rootPageId;
+        this.pageId = rootPageId;
     }
 
     synchronized public void load() throws IOException {
@@ -143,7 +143,7 @@
             }
             
             Transaction tx = pageFile.tx();
-            final Page<BTreeNode<Key,Value>> p = tx.load(rootPageId, null);
+            final Page<BTreeNode<Key,Value>> p = tx.load(pageId, null);
             if( p.getType() == Page.PAGE_FREE_TYPE ) {
                  // Need to initialize it..
                 tx.execute(new Transaction.Closure<IOException>(){
@@ -154,7 +154,7 @@
                 });
                 pageFile.checkpoint();
             } else {
-                root = loadNode(tx, rootPageId, null);    
+                root = loadNode(tx, pageId, null);    
             }
         }
     }
@@ -272,8 +272,8 @@
     public PageFile getPageFile() {
         return pageFile;
     }
-    public long getRootPageId() {
-        return rootPageId;
+    public long getPageId() {
+        return pageId;
     }
 
     public Marshaller<Key> getKeyMarshaller() {

Modified: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/BTreeNode.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/BTreeNode.java?rev=691268&r1=691267&r2=691268&view=diff
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/BTreeNode.java (original)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/BTreeNode.java Tue Sep  2
07:52:17 2008
@@ -155,7 +155,7 @@
             int idx = Arrays.binarySearch(keys, key);
             idx = idx < 0 ? -(idx + 1) : idx + 1;
             BTreeNode<Key, Value> child = getChild(tx, idx);
-            if( child.getPageId() == index.getRootPageId() ) {
+            if( child.getPageId() == index.getPageId() ) {
                 throw new IOException("BTree corrupted: Cylce detected.");
             }
             Value rc = child.remove(tx, key);

Modified: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/Page.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/Page.java?rev=691268&r1=691267&r2=691268&view=diff
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/Page.java (original)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/Page.java Tue Sep  2 07:52:17
2008
@@ -33,7 +33,7 @@
  * 
  * @version $Revision: 1.1.1.1 $
  */
-class Page<T> {
+public class Page<T> {
 
     public static final int PAGE_HEADER_SIZE = 17;
 

Modified: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java?rev=691268&r1=691267&r2=691268&view=diff
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java (original)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java Tue Sep  2
07:52:17 2008
@@ -752,6 +752,11 @@
         public boolean isReadOnly() {
             return false;
         }
+
+        public long getPageCount() {
+            return nextFreePageId;
+        }
+
     }
     
     public Transaction tx() {

Modified: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/Transaction.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/Transaction.java?rev=691268&r1=691267&r2=691268&view=diff
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/Transaction.java (original)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/page/Transaction.java Tue Sep
 2 07:52:17 2008
@@ -27,7 +27,7 @@
  * The interface used to read/update a PageFile object.  Using a transaction allows you to
  * do multiple update operations in a single unit of work.
  */
-interface Transaction extends Iterable<Page> {
+public interface Transaction extends Iterable<Page> {
     
     /**
      * 
@@ -49,8 +49,7 @@
         public long getPage() {
             return page;
         }
-    }
-    
+    }    
     
     /**
      * This closure interface is intended for the end user implement callbacks for the Transaction.exectue()
method.
@@ -211,6 +210,11 @@
     public InputStream openInputStream(final Page p) throws IOException;
     
     /**
+     * @return the number of pages allocated in the PageFile
+     */
+    public long getPageCount();
+    
+    /**
      * Allows you to iterate through all active Pages in this object.  Pages with type Page.FREE_TYPE
are 
      * not included in this iteration. 
      * 

Modified: activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayOutputStream.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayOutputStream.java?rev=691268&r1=691267&r2=691268&view=diff
==============================================================================
--- activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayOutputStream.java
(original)
+++ activemq/sandbox/kahadb/src/main/java/org/apache/kahadb/util/DataByteArrayOutputStream.java
Tue Sep  2 07:52:17 2008
@@ -277,4 +277,8 @@
         pos+=size;
         onWrite();
     }
+
+    public ByteSequence getByteSequence() {
+        return new ByteSequence(buf, 0, pos);
+    }
 }



Mime
View raw message