summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2008-03-18 20:25:32 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2008-03-18 20:25:32 +0000
commit09ebeb51843e5c656b8a0e9e31eb4e8dd6fdda93 (patch)
treedcd66f4b2ec83ffc0fb0c5f960feeb952207053b
parent404056c33b047e8ec75b0f6def90b4a27bf8079b (diff)
downloadjackcess-09ebeb51843e5c656b8a0e9e31eb4e8dd6fdda93.tar.gz
jackcess-09ebeb51843e5c656b8a0e9e31eb4e8dd6fdda93.zip
no need to sort entries, should already be sorted (but verify just to be paranoid)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@284 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r--src/java/com/healthmarketscience/jackcess/Index.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Index.java b/src/java/com/healthmarketscience/jackcess/Index.java
index 944866d..5df3277 100644
--- a/src/java/com/healthmarketscience/jackcess/Index.java
+++ b/src/java/com/healthmarketscience/jackcess/Index.java
@@ -41,7 +41,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
-import java.util.TreeSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -396,9 +395,6 @@ public class Index implements Comparable<Index> {
private void readIndexEntries()
throws IOException
{
- // use sorted set initially to do the bulk of the sorting
- SortedSet<Entry> tmpEntries = new TreeSet<Entry>();
-
ByteBuffer indexPage = getPageChannel().createPageBuffer();
// find first leaf page
@@ -419,10 +415,11 @@ public class Index implements Comparable<Index> {
}
}
- // read all leaf pages
+ // read all leaf pages. since we read all the entries in sort order, we
+ // can insert them directly into the _entries list
while(true) {
- leafPageNumber = readLeafPage(indexPage, tmpEntries);
+ leafPageNumber = readLeafPage(indexPage, _entries);
if(leafPageNumber != 0) {
// FIXME we can't modify this index at this point in time
_readOnly = true;
@@ -436,8 +433,15 @@ public class Index implements Comparable<Index> {
}
}
- // dump all the entries (sorted) into the actual _entries list
- _entries.addAll(tmpEntries);
+ // check the entry order, just to be safe
+ for(int i = 0; i < (_entries.size() - 1); ++i) {
+ Entry e1 = _entries.get(i);
+ Entry e2 = _entries.get(i + 1);
+ if(e1.compareTo(e2) > 0) {
+ throw new IOException("Unexpected order in index entries, " +
+ e1 + " is greater than " + e2);
+ }
+ }
}
/**