vgritsenko 2004/01/06 20:02:04
Modified: java/src/org/apache/xindice/core/filer BTree.java Paged.java Log: Minor search optimizations Revision Changes Path 1.24 +34 -20 xml-xindice/java/src/org/apache/xindice/core/filer/BTree.java Index: BTree.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/BTree.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- BTree.java 22 Dec 2003 01:35:50 -0000 1.23 +++ BTree.java 7 Jan 2004 04:02:04 -0000 1.24 @@ -679,7 +679,7 @@ private Value getSeparator(Value value1, Value value2) { int idx = value1.compareTo(value2); byte[] b = new byte[Math.abs(idx)]; - System.arraycopy(value2.getData(), 0, b, 0, b.length); + value2.copyTo(b, 0, b.length); return new Value(b); } @@ -818,10 +818,15 @@ case IndexQuery.BW: case IndexQuery.IN: case IndexQuery.SW: - for (int i = 0; i < ptrs.length; i++) { - if (i >= leftIdx && i <= rightIdx) { - getChildNode(i).query(query, callback); - } + // TODO: Can leftIdx be less than 0 here? + if (leftIdx < 0) { + leftIdx = 0; + } + if (rightIdx > ptrs.length - 1) { + rightIdx = ptrs.length - 1; + } + for (int i = leftIdx; i <= rightIdx; i++) { + getChildNode(i).query(query, callback); } break; @@ -829,10 +834,17 @@ case IndexQuery.NBW: case IndexQuery.NIN: case IndexQuery.NSW: - for (int i = 0; i < ptrs.length; i++) { - if (i <= leftIdx || i >= rightIdx) { - getChildNode(i).query(query, callback); - } + if (leftIdx > ptrs.length - 1) { + leftIdx = ptrs.length - 1; + } + for (int i = 0; i <= leftIdx; i++) { + getChildNode(i).query(query, callback); + } + if (rightIdx < 0) { + rightIdx = 0; + } + for (int i = rightIdx; i < ptrs.length; i++) { + getChildNode(i).query(query, callback); } break; @@ -842,19 +854,21 @@ case IndexQuery.LT: case IndexQuery.LEQ: - for (int i = 0; i < ptrs.length; i++) { - if (i <= leftIdx) { - getChildNode(i).query(query, callback); - } + if (leftIdx > ptrs.length - 1) { + leftIdx = ptrs.length - 1; + } + for (int i = 0; i <= leftIdx; i++) { + getChildNode(i).query(query, callback); } break; case IndexQuery.GT: case IndexQuery.GEQ: - for (int i = 0; i < ptrs.length; i++) { - if (i >= rightIdx) { - getChildNode(i).query(query, callback); - } + if (rightIdx < 0) { + rightIdx = 0; + } + for (int i = rightIdx; i < ptrs.length; i++) { + getChildNode(i).query(query, callback); } break; @@ -893,7 +907,7 @@ if (rightIdx < 0) { rightIdx = -(rightIdx + 1); } - for (int i = 0; i < ptrs.length; i++) { + for (int i = 0; i < ptrs.length; i++) { // FIXME: VG: Optimize this loop if (i >= leftIdx && i <= rightIdx && query.testValue(values[i])) { callback.indexInfo(values[i], ptrs[i]); } 1.25 +4 -4 xml-xindice/java/src/org/apache/xindice/core/filer/Paged.java Index: Paged.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/Paged.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- Paged.java 22 Dec 2003 01:34:11 -0000 1.24 +++ Paged.java 7 Jan 2004 04:02:04 -0000 1.25 @@ -140,12 +140,12 @@ * The number of random access file objects that exist, either in the * cache [EMAIL PROTECTED] #descriptors}, or currently in use. */ - private int descCount = 0; + private int descCount; /** * Whether the file is opened or not. */ - private boolean opened = false; + private boolean opened; /** * The underlying file where the Paged object stores its pages.