Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
new kelondroRow objects now replace byte[][] objects in object cache
orbiter572d53506c7b
diff --git a/build.properties b/build.propertiesindex 9291a5e58..aa64a21bb 100644--- a/build.properties+++ b/build.properties@@ -3,7 +3,7 @@ javacSource=1.4javacTarget=1.4# Release Configuration-releaseVersion=0.452+releaseVersion=0.453releaseFile=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz#releaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gzreleaseDir=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}diff --git a/source/de/anomic/kelondro/kelondroRecords.java b/source/de/anomic/kelondro/kelondroRecords.javaindex 2d3de8299..9f1306da1 100644--- a/source/de/anomic/kelondro/kelondroRecords.java+++ b/source/de/anomic/kelondro/kelondroRecords.java@@ -730,6 +730,7 @@ public class kelondroRecords {return (h == NUL) ? null : new Handle(h);}+ /*public byte[][] setValueCells(byte[][] row) throws IOException {// if the index is defined, then write values directly to the file, else only to the objectbyte[][] result = getValueCells(); // previous value (this loads the values if not already happened)@@ -747,7 +748,7 @@ public class kelondroRecords {this.tailChanged = true;return result; // return previous value}-+ */public byte[] setValueRow(byte[] row) throws IOException {// if the index is defined, then write values directly to the file, else only to the objectassert row.length == ROW.size();@@ -768,6 +769,7 @@ public class kelondroRecords {return trimCopy(headChunk, overhead, ROW.width(0));}+ /*public byte[][] getValueCells() throws IOException {if (this.tailChunk == null) {@@ -792,7 +794,7 @@ public class kelondroRecords {return values;}-+*/public byte[] getValueRow() throws IOException {if (this.tailChunk == null) {@@ -867,8 +869,8 @@ public class kelondroRecords {h = getOHHandle(i);if (h == null) s = s + ":hNULL"; else s = s + ":h" + h.toString();}- byte[][] content = getValueCells();- for (int i = 0; i < content.length; i++) s = s + ":" + ((content[i] == null) ? "NULL" : (new String(content[i], "UTF-8")).trim());+ kelondroRow.Entry content = row().newEntry(getValueRow());+ for (int i = 0; i < row().columns(); i++) s = s + ":" + ((content.empty(i)) ? "NULL" : content.getColString(i, "UTF-8").trim());} catch (IOException e) {s = s + ":***LOAD ERROR***:" + e.getMessage();}@@ -1165,7 +1167,7 @@ public class kelondroRecords {Node n = new Node(pos);pos.index++;while ((markedDeleted.contains(pos)) && (pos.index < USAGE.allCount())) pos.index++;- return n.getValueCells();+ return row().newEntry(n.getValueRow()).getCols();} catch (IOException e) {throw new kelondroException(filename, e.getMessage());}diff --git a/source/de/anomic/kelondro/kelondroRow.java b/source/de/anomic/kelondro/kelondroRow.javaindex b64d78153..430e01782 100644--- a/source/de/anomic/kelondro/kelondroRow.java+++ b/source/de/anomic/kelondro/kelondroRow.java@@ -172,6 +172,25 @@ public class kelondroRow {kelondroNaturalOrder.encodeLong(cell, rowinstance, colstart[column], row[column].cellwidth());}+ public byte[][] getCols() {+ byte[][] values = new byte[row.length][];++ int length, offset;+ for (int i = 0; i < row.length; i++) {+ length = row[i].cellwidth();+ offset = colstart[i];+ while ((length > 0) && (rowinstance[offset + length - 1] == 0)) length--;+ if (length == 0) {+ values[i] = null;+ } else {+ values[i] = new byte[length];+ System.arraycopy(rowinstance, offset, values[i], 0, length);+ }+ }++ return values;+ }+public String getColString(int column, String encoding) {int length = row[column].cellwidth();int offset = colstart[column];diff --git a/source/de/anomic/kelondro/kelondroStack.java b/source/de/anomic/kelondro/kelondroStack.javaindex 9506148d2..97bd25fea 100644--- a/source/de/anomic/kelondro/kelondroStack.java+++ b/source/de/anomic/kelondro/kelondroStack.java@@ -206,7 +206,7 @@ public final class kelondroStack extends kelondroRecords {// return row relative to the bottom of the stack and remove addressed elementNode n = botNode(dist);if (n == null) return null;- kelondroRow.Entry ret = row().newEntry(n.getValueCells());+ kelondroRow.Entry ret = row().newEntry(n.getValueRow());// remove nodeunlinkNode(n);@@ -337,17 +337,17 @@ public final class kelondroStack extends kelondroRecords {Node n;try {Iterator it = iterator();+ kelondroRow.Entry r;while (it.hasNext()) {n = (Node) it.next();+ r = row().newEntry(n.getValueRow());// n = getNode(h, null, 0);System.out.println("> NODE " + hp(n.handle()) + "; left "+ hp(n.getOHHandle(left)) + ", right "+ hp(n.getOHHandle(right)));- System.out.print(" KEY:'"- + (new String(n.getValueCells()[0])).trim() + "'");+ System.out.print(" KEY:'" + r.getColString(0, null) + "'");for (int j = 1; j < columns(); j++)- System.out.print(", V[" + j + "]:'"- + (new String(n.getValueCells()[j])).trim() + "'");+ System.out.print(", V[" + j + "]:'" + r.getColString(j, null) + "'");System.out.println();}System.out.println();diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.javaindex 562b4f5a9..469bd33f1 100644--- a/source/de/anomic/kelondro/kelondroTree.java+++ b/source/de/anomic/kelondro/kelondroTree.java@@ -223,23 +223,23 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {// Returns the value to which this map maps the specified key.public byte[][] get(byte[] key) throws IOException {// System.out.println("kelondroTree.get " + new String(key) + " in " + filename);- byte[][] result = (objectCache == null) ? null : (byte[][]) objectCache.get(key);+ kelondroRow.Entry result = (objectCache == null) ? null : (kelondroRow.Entry) objectCache.get(key);if (result != null) {//System.out.println("cache hit in objectCache, db:" + super.filename);- return result;+ return result.getCols();}if ((objectCache != null) && (objectCache.has(key) == -1)) return null;synchronized (writeSearchObj) {writeSearchObj.process(key);if (writeSearchObj.found()) {- result = writeSearchObj.getMatcher().getValueCells();+ result = row().newEntry(writeSearchObj.getMatcher().getValueRow());if (objectCache != null) objectCache.put(key, result);} else {result = null;if (objectCache != null) objectCache.hasnot(key);}}- return result;+ return (result == null) ? null : result.getCols();}public class Search {@@ -373,17 +373,18 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {// Associates the specified value with the specified key in this mappublic byte[][] put(byte[][] newrow) throws IOException {- byte[][] result = null;+ kelondroRow.Entry result = null;//writeLock.stay(2000, 1000);if (newrow.length != columns()) throw new IllegalArgumentException("put: wrong row length " + newrow.length + "; must be " + columns());// first try to find the key element in the databasesynchronized(writeSearchObj) {- if (objectCache != null) objectCache.put(newrow[0], newrow);+ kelondroRow.Entry newentry = row().newEntry(newrow);+ if (objectCache != null) objectCache.put(newentry.getColBytes(0), newentry);writeSearchObj.process(newrow[0]);if (writeSearchObj.found()) {// a node with this key exist. simply overwrite the content and return old contentNode e = writeSearchObj.getMatcher();- result = e.setValueCells(newrow);+ result = row().newEntry(e.setValueRow(newentry.bytes()));commitNode(e);} else if (writeSearchObj.isRoot()) {// a node with this key does not exist and there is no node at all@@ -392,7 +393,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {throw new kelondroException(filename, "tried to create root node twice");// we dont have any Nodes in the file, so start here to create oneNode e = newNode();- e.setValueCells(newrow);+ e.setValueRow(newentry.bytes());// write the propetriese.setOHByte(magic, (byte) 1);e.setOHByte(balance, (byte) 0);@@ -414,7 +415,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {// create new node and assign valuesNode parentNode = writeSearchObj.getParent();Node theNode = newNode();- theNode.setValueCells(newrow);+ theNode.setValueRow(newentry.bytes());theNode.setOHByte(0, (byte) 1); // fresh magictheNode.setOHByte(1, (byte) 0); // fresh balancetheNode.setOHHandle(parent, parentNode.handle());@@ -514,7 +515,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {}}//writeLock.release();- return result;+ return (result == null) ? null : result.getCols();}private void assignChild(Node parentNode, Node childNode, int childType) throws IOException {@@ -647,9 +648,9 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {writeSearchObj.process(key);if (writeSearchObj.found()) {Node result = writeSearchObj.getMatcher();- byte[][] values = result.getValueCells();+ kelondroRow.Entry values = row().newEntry(result.getValueRow());remove(result, writeSearchObj.getParent());- return values;+ return values.getCols();} else {return null;}@@ -1006,7 +1007,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {Iterator i = (firstKey == null) ? new nodeIterator(up, rotating) : new nodeIterator(up, rotating, firstKey, including);while ((rows.size() < count) && (i.hasNext())) {n = (Node) i.next();- if (n != null) rows.put(new String(n.getKey()), n.getValueCells());+ if (n != null) rows.put(new String(n.getKey()), row().newEntry(n.getValueRow()).getCols());}}return rows;