### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: search/org/eclipse/jdt/internal/core/index/DiskIndex.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/DiskIndex.java,v retrieving revision 1.69 diff -u -r1.69 DiskIndex.java --- search/org/eclipse/jdt/internal/core/index/DiskIndex.java 9 Mar 2010 05:55:04 -0000 1.69 +++ search/org/eclipse/jdt/internal/core/index/DiskIndex.java 30 Mar 2010 06:19:26 -0000 @@ -132,7 +132,7 @@ } return results; } -private HashtableOfObject addQueryResult(HashtableOfObject results, char[] word, CategoryTable wordsToDocNumbers, MemoryIndex memoryIndex) throws IOException { +private HashtableOfObject addQueryResult(HashtableOfObject results, char[] word, HashtableOfObject wordsToDocNumbers, MemoryIndex memoryIndex) throws IOException { // must skip over documents which have been added/changed/deleted in the memory index if (results == null) results = new HashtableOfObject(13); @@ -163,7 +163,7 @@ HashtableOfObject results = null; // initialized if needed if (key == null) { for (int i = 0, l = categories.length; i < l; i++) { - CategoryTable wordsToDocNumbers = readCategoryTable(categories[i], true); // cache if key is null since its a definite match + HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], true); // cache if key is null since its a definite match if (wordsToDocNumbers != null) { char[][] words = wordsToDocNumbers.keyTable; if (results == null) @@ -179,14 +179,14 @@ switch (matchRule) { case SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE: for (int i = 0, l = categories.length; i < l; i++) { - CategoryTable wordsToDocNumbers = readCategoryTable(categories[i], false); + HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], false); if (wordsToDocNumbers != null && wordsToDocNumbers.containsKey(key)) results = addQueryResult(results, key, wordsToDocNumbers, memoryIndex); } break; case SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE: for (int i = 0, l = categories.length; i < l; i++) { - CategoryTable wordsToDocNumbers = readCategoryTable(categories[i], false); + HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], false); if (wordsToDocNumbers != null) { char[][] words = wordsToDocNumbers.keyTable; for (int j = 0, m = words.length; j < m; j++) { @@ -199,7 +199,7 @@ break; default: for (int i = 0, l = categories.length; i < l; i++) { - CategoryTable wordsToDocNumbers = readCategoryTable(categories[i], false); + HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], false); if (wordsToDocNumbers != null) { char[][] words = wordsToDocNumbers.keyTable; for (int j = 0, m = words.length; j < m; j++) { @@ -336,9 +336,9 @@ char[] categoryName = categoryNames[i]; if (categoryName != null) { SimpleWordSet wordSet = (SimpleWordSet) wordSets[i]; - CategoryTable wordsToDocs = (CategoryTable) this.categoryTables.get(categoryName); + HashtableOfObject wordsToDocs = (HashtableOfObject) this.categoryTables.get(categoryName); if (wordsToDocs == null) - this.categoryTables.put(categoryName, wordsToDocs = new CategoryTable(wordSet.elementSize)); + this.categoryTables.put(categoryName, wordsToDocs = new HashtableOfObject(wordSet.elementSize)); char[][] words = wordSet.words; for (int j = 0, m = words.length; j < m; j++) { @@ -442,11 +442,11 @@ this.categoryTables = null; } private void mergeCategory(char[] categoryName, DiskIndex onDisk, int[] positions, FileOutputStream stream) throws IOException { - CategoryTable wordsToDocs = (CategoryTable) this.categoryTables.get(categoryName); + HashtableOfObject wordsToDocs = (HashtableOfObject) this.categoryTables.get(categoryName); if (wordsToDocs == null) - wordsToDocs = new CategoryTable(3); + wordsToDocs = new HashtableOfObject(3); - CategoryTable oldWordsToDocs = onDisk.readCategoryTable(categoryName, true); + HashtableOfObject oldWordsToDocs = onDisk.readCategoryTable(categoryName, true); if (oldWordsToDocs != null) { char[][] oldWords = oldWordsToDocs.keyTable; Object[] oldArrayOffsets = oldWordsToDocs.valueTable; @@ -580,7 +580,7 @@ this.streamBuffer = null; } } -private synchronized CategoryTable readCategoryTable(char[] categoryName, boolean readDocNumbers) throws IOException { +private synchronized HashtableOfObject readCategoryTable(char[] categoryName, boolean readDocNumbers) throws IOException { // result will be null if categoryName is unknown int offset = this.categoryOffsets.get(categoryName); if (offset == HashtableOfIntValues.NO_VALUE) { @@ -590,7 +590,7 @@ if (this.categoryTables == null) { this.categoryTables = new HashtableOfObject(3); } else { - CategoryTable cachedTable = (CategoryTable) this.categoryTables.get(categoryName); + HashtableOfObject cachedTable = (HashtableOfObject) this.categoryTables.get(categoryName); if (cachedTable != null) { if (readDocNumbers) { // must cache remaining document number arrays Object[] arrayOffsets = cachedTable.valueTable; @@ -603,7 +603,7 @@ } FileInputStream stream = new FileInputStream(this.indexFile); - CategoryTable categoryTable = null; + HashtableOfObject categoryTable = null; char[][] matchingWords = null; int count = 0; int firstOffset = -1; @@ -621,7 +621,11 @@ System.err.println("size = "+size); //$NON-NLS-1$ System.err.println("-------------------- END --------------------"); //$NON-NLS-1$ } - categoryTable = new CategoryTable(size); + if (size > 1024) { + categoryTable = new CategoryTable(size); + } else { + categoryTable = new HashtableOfObject(size); + } } catch (OutOfMemoryError oom) { // DEBUG oom.printStackTrace(); @@ -1030,10 +1034,10 @@ Object[] tables = this.categoryTables.valueTable; for (int i = 0, l = categoryNames.length; i < l; i++) if (categoryNames[i] != null) - writeCategoryTable(categoryNames[i], (CategoryTable) tables[i], stream); + writeCategoryTable(categoryNames[i], (HashtableOfObject) tables[i], stream); this.categoryTables = null; } -private void writeCategoryTable(char[] categoryName, CategoryTable wordsToDocs, FileOutputStream stream) throws IOException { +private void writeCategoryTable(char[] categoryName, HashtableOfObject wordsToDocs, FileOutputStream stream) throws IOException { // the format of a category table is as follows: // any document number arrays with >= 256 elements are written before the table (the offset to each array is remembered) // then the number of word->int[] pairs in the table is written