_binary From 936ba5d9f508c4e52996a1efc20fc886a2f76ab4 Mon Sep 17 00:00:00 2001
From: Akshat Kukreti <akshatkukreti@gmail.com>
Date: Thu, 23 May 2013 16:24:19 -0700
Subject: [PATCH 1/5] integrated BTNode with BTree

---
 lib/btree.php | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 54 insertions(+), 4 deletions(-)

diff --git a/lib/btree.php b/lib/btree.php
index b2442e3..08b02be 100644
--- a/lib/btree.php
+++ b/lib/btree.php
@@ -103,7 +103,7 @@ class BTree
             $this->id_count = unserialize(file_get_contents($this->dir.
                 "/count.txt"));
         } else {
-            $this->root = new Node();
+            $this->root = new BTNode();
             $this->root->id = "root";
             $this->id_count = 1;
         }
@@ -295,7 +295,7 @@ class BTree
     function bTreeSplitChild($parent, $i, $child)
     {
         $this->id_count += 1;
-        $temp = new Node();
+        $temp = new BTNode();
         $temp->id = $this->id_count;
         $this->saveNodeCount();
         $temp->is_leaf = $child->is_leaf;
@@ -346,7 +346,7 @@ class BTree
     function createEmptyParentNode()
     {
         $this->id_count += 1;
-        $temp = new Node();
+        $temp = new BTNode();
         $temp->id = $this->id_count;
         $this->saveNodeCount();
         $temp->is_leaf = false;
@@ -753,4 +753,54 @@ class BTree
         }
         return $siblings;
     }
-}
\ No newline at end of file
+}
+
+/**
+ * Class for B-Tree nodes
+ */
+
+class BTNode
+{
+    /**
+     * Storage for id of a B-Tree node
+     * @var int
+     */
+    var $id;
+
+    /**
+     * Flag for checking if node is a leaf node or internal node
+     * @var boolean
+     */
+    var $is_leaf;
+
+    /**
+     * Storage for keeping track of node ids
+     * @var int
+     */
+    var $count;
+
+    /**
+     * Storage for key-value pairs in a B-Tree node
+     * @var array
+     */
+    var $keys;
+
+    /**
+     * Storage for links to child nodes in a B-Tree node
+     * @var array
+     */
+    var $links;
+
+    /**
+     * Creates and initializes an empty leaf node with id -1
+     * @var int
+     */
+    function __construct()
+    {
+        $this->id = -1;
+        $this->is_leaf = true;
+        $this->count = 0;
+        $this->keys = null;
+        $this->links = null;
+    }
+}
-- 
1.7.11.msysgit.1


From b77fa9ca621dbd1077a0d780149b3e28b36486da Mon Sep 17 00:00:00 2001
From: Akshat Kukreti <akshatkukreti@gmail.com>
Date: Thu, 23 May 2013 16:26:57 -0700
Subject: [PATCH 2/5] changes to btree

---
 lib/btree.php | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/lib/btree.php b/lib/btree.php
index 08b02be..26a2de0 100644
--- a/lib/btree.php
+++ b/lib/btree.php
@@ -33,11 +33,6 @@
  */
 
 /**
- * Load Node class
- */
-require_once(BASE_DIR.'/lib/btree_node.php');
-
-/**
  * Default value of minimum degree. The minimum degree determines the minimum 
  * and maximum number of keys and child nodes, for nodes 
  * other than root node
-- 
1.7.11.msysgit.1


From 13b64b7bfcb3ad1710a67b5b1ff7003b52cc58fb Mon Sep 17 00:00:00 2001
From: Akshat Kukreti <akshatkukreti@gmail.com>
Date: Thu, 23 May 2013 16:28:14 -0700
Subject: [PATCH 3/5] btree_node.php removed

---
 lib/btree_node.php | 87 ------------------------------------------------------
 1 file changed, 87 deletions(-)
 delete mode 100644 lib/btree_node.php

diff --git a/lib/btree_node.php b/lib/btree_node.php
deleted file mode 100644
index 111fdc9..0000000
--- a/lib/btree_node.php
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-
-/**
- *  SeekQuarry/Yioop --
- *  Open Source Pure PHP Search Engine, Crawler, and Indexer
- *
- *  Copyright (C) 2009 - 2013  Chris Pollett chris@pollett.org
- *
- *  LICENSE:
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *  END LICENSE
- *
- * @author Chris Pollett chris@pollett.org
- * @package seek_quarry
- * @subpackage bin
- * @license http://www.gnu.org/licenses/ GPL3
- * @link http://www.seekquarry.com/
- * @copyright 2009 - 2013
- * @filesource
- */
-
-/**
- * This class implements B-Tree nodes used in the B-Tree implementation in 
- * btree.php
- * 
- * @author Akshat Kukreti
- * @package seek_quarry
- */
-
-class Node
-{
-    /**
-     * Storage for id of a B-Tree node
-     * @var int
-     */
-    var $id;
-
-    /**
-     * Flag for checking if node is a leaf node or internal node
-     * @var boolean
-     */
-    var $is_leaf;
-
-    /**
-     * Storage for keeping track of node ids
-     * @var int
-     */
-    var $count;
-
-    /**
-     * Storage for key-value pairs in a B-Tree node
-     * @var array
-     */
-    var $keys;
-
-    /**
-     * Storage for links to child nodes in a B-Tree node
-     * @var array
-     */
-    var $links;
-
-    /**
-     * Creates and initializes an empty leaf node with id -1
-     * @var int
-     */
-    function __construct()
-    {
-        $this->id = -1;
-        $this->is_leaf = true;
-        $this->count = 0;
-        $this->keys = null;
-        $this->links = null;
-    }
-}
\ No newline at end of file
-- 
1.7.11.msysgit.1


From e027d0e65749ed1e94f9f5265babab2e806c6e90 Mon Sep 17 00:00:00 2001
From: Akshat Kukreti <akshatkukreti@gmail.com>
Date: Thu, 23 May 2013 16:30:14 -0700
Subject: [PATCH 4/5] 8 byte URL hash for B-Tree instead of 11

---
 bin/queue_server.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/queue_server.php b/bin/queue_server.php
index a2270eb..edc5a4d 100755
--- a/bin/queue_server.php
+++ b/bin/queue_server.php
@@ -1652,7 +1652,7 @@ class QueueServer implements CrawlConstants, Join
         foreach($cache_page_validation_data as $data) {
             $link = $data[0];
             $value = $data[1];
-            $key = crawlHash($link);
+            $key = crawlHash($link, true);
             $entry = array($key, $value);
             $this->btree->insert($entry);
         }
@@ -2216,7 +2216,7 @@ class QueueServer implements CrawlConstants, Join
                   found, the ETag is appended to the URL so that it can be
                   processed by the fetcher.
                  */
-                $key = crawlHash($url);
+                $key = crawlHash($url, true);
                 $value = $this->btree->findValue($key);
                 if($value !== null) {
                     $cache_validation_data = $value[1];
-- 
1.7.11.msysgit.1


From 5f29d70c5b24762d7b4e97cb95829e989b8a2ea2 Mon Sep 17 00:00:00 2001
From: Akshat Kukreti <akshatkukreti@gmail.com>
Date: Thu, 23 May 2013 16:31:34 -0700
Subject: [PATCH 5/5] change in B-Tree test

---
 tests/btree_test.php | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/btree_test.php b/tests/btree_test.php
index d870a19..b9cf949 100644
--- a/tests/btree_test.php
+++ b/tests/btree_test.php
@@ -170,8 +170,8 @@
     {
         //Insert values
         for($i = 1;$i <= NUM_VALS;$i++) {
-            $value = crawlHash(rand(1, 1000));
-            $key = crawlHash($value);
+            $value = crawlHash(rand(1, 1000), true);
+            $key = crawlHash($value, true);
             $this->test_objects['FILE1']->insert(array($key, $value));
         }
 
@@ -198,8 +198,8 @@
         //Insert values
         $key_value_pairs = array();
         for($i = 1;$i <= NUM_VALS;$i++) {
-            $value = crawlHash(rand(1, 1000));
-            $key = crawlHash($value);
+            $value = crawlHash(rand(1, 1000), true);
+            $key = crawlHash($value, true);
             $this->test_objects['FILE1']->insert(array($key, $value));
             $key_value_pairs[] = array($key, $key);
         }
@@ -222,4 +222,4 @@
         }
     }
 
- }
\ No newline at end of file
+ }
-- 
1.7.11.msysgit.1

