Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2006 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2007 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 19-28
Link Here
|
19 |
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; |
19 |
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; |
20 |
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; |
20 |
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; |
21 |
import org.eclipse.jdt.internal.compiler.util.SimpleSet; |
21 |
import org.eclipse.jdt.internal.compiler.util.SimpleSet; |
|
|
22 |
import org.eclipse.jdt.internal.compiler.util.SimpleSetOfCharArray; |
22 |
|
23 |
|
23 |
public class DiskIndex { |
24 |
public class DiskIndex { |
24 |
|
25 |
|
25 |
String fileName; |
26 |
File indexFile; |
26 |
|
27 |
|
27 |
private int headerInfoOffset; |
28 |
private int headerInfoOffset; |
28 |
private int numberOfChunks; |
29 |
private int numberOfChunks; |
Lines 37-43
Link Here
|
37 |
private HashtableOfObject categoryTables; // category name -> HashtableOfObject(words -> int[] of document #'s) or offset if not read yet |
38 |
private HashtableOfObject categoryTables; // category name -> HashtableOfObject(words -> int[] of document #'s) or offset if not read yet |
38 |
private char[] cachedCategoryName; |
39 |
private char[] cachedCategoryName; |
39 |
|
40 |
|
40 |
public static final String SIGNATURE= "INDEX VERSION 1.120"; //$NON-NLS-1$ |
41 |
public static final String SIGNATURE= "INDEX VERSION 1.121.2"; //$NON-NLS-1$ |
|
|
42 |
public static final char[] SIGNATURE_ARRAY= SIGNATURE.toCharArray(); |
41 |
public static boolean DEBUG = false; |
43 |
public static boolean DEBUG = false; |
42 |
|
44 |
|
43 |
private static final int RE_INDEXED = -1; |
45 |
private static final int RE_INDEXED = -1; |
Lines 45-50
Link Here
|
45 |
|
47 |
|
46 |
private static final int CHUNK_SIZE = 100; |
48 |
private static final int CHUNK_SIZE = 100; |
47 |
|
49 |
|
|
|
50 |
private static final SimpleSetOfCharArray INTERNED_CATEGORY_NAMES = new SimpleSetOfCharArray(20); |
51 |
|
48 |
static class IntList { |
52 |
static class IntList { |
49 |
|
53 |
|
50 |
int size; |
54 |
int size; |
Lines 70-77
Link Here
|
70 |
} |
74 |
} |
71 |
|
75 |
|
72 |
|
76 |
|
73 |
DiskIndex(String fileName) { |
77 |
DiskIndex(File file) { |
74 |
this.fileName = fileName; |
78 |
this.indexFile = file; |
75 |
|
79 |
|
76 |
// clear cached items |
80 |
// clear cached items |
77 |
this.headerInfoOffset = -1; |
81 |
this.headerInfoOffset = -1; |
Lines 204-210
Link Here
|
204 |
private void cacheDocumentNames() throws IOException { |
208 |
private void cacheDocumentNames() throws IOException { |
205 |
// will need all document names so get them now |
209 |
// will need all document names so get them now |
206 |
this.cachedChunks = new String[this.numberOfChunks][]; |
210 |
this.cachedChunks = new String[this.numberOfChunks][]; |
207 |
DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(getIndexFile()), this.numberOfChunks > 5 ? 4096 : 2048)); |
211 |
DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(this.indexFile), this.numberOfChunks > 5 ? 4096 : 2048)); |
208 |
try { |
212 |
try { |
209 |
stream.skip(this.chunkOffsets[0]); |
213 |
stream.skip(this.chunkOffsets[0]); |
210 |
for (int i = 0; i < this.numberOfChunks; i++) { |
214 |
for (int i = 0; i < this.numberOfChunks; i++) { |
Lines 336-350
Link Here
|
336 |
} |
340 |
} |
337 |
} |
341 |
} |
338 |
File getIndexFile() { |
342 |
File getIndexFile() { |
339 |
if (this.fileName == null) return null; |
343 |
return this.indexFile; |
340 |
|
|
|
341 |
return new File(this.fileName); |
342 |
} |
344 |
} |
343 |
void initialize(boolean reuseExistingFile) throws IOException { |
345 |
void initialize(boolean reuseExistingFile) throws IOException { |
344 |
File indexFile = getIndexFile(); |
346 |
if (this.indexFile.exists()) { |
345 |
if (indexFile.exists()) { |
|
|
346 |
if (reuseExistingFile) { |
347 |
if (reuseExistingFile) { |
347 |
RandomAccessFile file = new RandomAccessFile(this.fileName, "r"); //$NON-NLS-1$ |
348 |
RandomAccessFile file = new RandomAccessFile(this.indexFile, "r"); //$NON-NLS-1$ |
348 |
try { |
349 |
try { |
349 |
String signature = file.readUTF(); |
350 |
String signature = file.readUTF(); |
350 |
if (!signature.equals(SIGNATURE)) |
351 |
if (!signature.equals(SIGNATURE)) |
Lines 359-371
Link Here
|
359 |
return; |
360 |
return; |
360 |
} |
361 |
} |
361 |
if (!indexFile.delete()) { |
362 |
if (!indexFile.delete()) { |
|
|
363 |
String fileName = this.indexFile.getPath(); |
362 |
if (DEBUG) |
364 |
if (DEBUG) |
363 |
System.out.println("initialize - Failed to delete index " + this.fileName); //$NON-NLS-1$ |
365 |
System.out.println("initialize - Failed to delete index " + fileName); //$NON-NLS-1$ |
364 |
throw new IOException("Failed to delete index " + this.fileName); //$NON-NLS-1$ |
366 |
throw new IOException("Failed to delete index " + fileName); //$NON-NLS-1$ |
365 |
} |
367 |
} |
366 |
} |
368 |
} |
367 |
if (indexFile.createNewFile()) { |
369 |
if (indexFile.createNewFile()) { |
368 |
RandomAccessFile file = new RandomAccessFile(this.fileName, "rw"); //$NON-NLS-1$ |
370 |
RandomAccessFile file = new RandomAccessFile(this.indexFile, "rw"); //$NON-NLS-1$ |
369 |
try { |
371 |
try { |
370 |
file.writeUTF(SIGNATURE); |
372 |
file.writeUTF(SIGNATURE); |
371 |
file.writeInt(-1); // file is empty |
373 |
file.writeInt(-1); // file is empty |
Lines 373-391
Link Here
|
373 |
file.close(); |
375 |
file.close(); |
374 |
} |
376 |
} |
375 |
} else { |
377 |
} else { |
|
|
378 |
String fileName = this.indexFile.getPath(); |
376 |
if (DEBUG) |
379 |
if (DEBUG) |
377 |
System.out.println("initialize - Failed to create new index " + this.fileName); //$NON-NLS-1$ |
380 |
System.out.println("initialize - Failed to create new index " + fileName); //$NON-NLS-1$ |
378 |
throw new IOException("Failed to create new index " + this.fileName); //$NON-NLS-1$ |
381 |
throw new IOException("Failed to create new index " + fileName); //$NON-NLS-1$ |
379 |
} |
382 |
} |
380 |
} |
383 |
} |
381 |
private void initializeFrom(DiskIndex diskIndex, File newIndexFile) throws IOException { |
384 |
private void initializeFrom(DiskIndex diskIndex, File newIndexFile) throws IOException { |
382 |
if (newIndexFile.exists() && !newIndexFile.delete()) { // delete the temporary index file |
385 |
if (newIndexFile.exists() && !newIndexFile.delete()) { // delete the temporary index file |
383 |
if (DEBUG) |
386 |
if (DEBUG) |
384 |
System.out.println("initializeFrom - Failed to delete temp index " + this.fileName); //$NON-NLS-1$ |
387 |
System.out.println("initializeFrom - Failed to delete temp index " + this.indexFile.getPath()); //$NON-NLS-1$ |
385 |
} else if (!newIndexFile.createNewFile()) { |
388 |
} else if (!newIndexFile.createNewFile()) { |
|
|
389 |
String fileName = this.indexFile.getPath(); |
386 |
if (DEBUG) |
390 |
if (DEBUG) |
387 |
System.out.println("initializeFrom - Failed to create temp index " + this.fileName); //$NON-NLS-1$ |
391 |
System.out.println("initializeFrom - Failed to create temp index " + fileName); //$NON-NLS-1$ |
388 |
throw new IOException("Failed to create temp index " + this.fileName); //$NON-NLS-1$ |
392 |
throw new IOException("Failed to create temp index " + fileName); //$NON-NLS-1$ |
389 |
} |
393 |
} |
390 |
|
394 |
|
391 |
int size = diskIndex.categoryOffsets == null ? 8 : diskIndex.categoryOffsets.elementSize; |
395 |
int size = diskIndex.categoryOffsets == null ? 8 : diskIndex.categoryOffsets.elementSize; |
Lines 465-477
Link Here
|
465 |
if (previousLength == 0) return this; // nothing to do... memory index contained deleted documents that had never been saved |
469 |
if (previousLength == 0) return this; // nothing to do... memory index contained deleted documents that had never been saved |
466 |
|
470 |
|
467 |
// index is now empty since all the saved documents were removed |
471 |
// index is now empty since all the saved documents were removed |
468 |
DiskIndex newDiskIndex = new DiskIndex(this.fileName); |
472 |
DiskIndex newDiskIndex = new DiskIndex(this.indexFile); |
469 |
newDiskIndex.initialize(false); |
473 |
newDiskIndex.initialize(false); |
470 |
return newDiskIndex; |
474 |
return newDiskIndex; |
471 |
} |
475 |
} |
472 |
|
476 |
|
473 |
DiskIndex newDiskIndex = new DiskIndex(this.fileName + ".tmp"); //$NON-NLS-1$ |
477 |
DiskIndex newDiskIndex = new DiskIndex(new File(this.indexFile.getPath() + ".tmp")); //$NON-NLS-1$ |
474 |
File newIndexFile = newDiskIndex.getIndexFile(); |
478 |
File newIndexFile = newDiskIndex.indexFile; |
475 |
try { |
479 |
try { |
476 |
newDiskIndex.initializeFrom(this, newIndexFile); |
480 |
newDiskIndex.initializeFrom(this, newIndexFile); |
477 |
DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(newIndexFile, false), 2048)); |
481 |
DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(newIndexFile, false), 2048)); |
Lines 487-494
Link Here
|
487 |
for (int i = 0, l = names.length; i < l; i++) |
491 |
for (int i = 0, l = names.length; i < l; i++) |
488 |
if (names[i] != null) |
492 |
if (names[i] != null) |
489 |
newDiskIndex.copyQueryResults( |
493 |
newDiskIndex.copyQueryResults( |
490 |
(HashtableOfObject) memoryIndex.docsToReferences.get(names[i]), |
494 |
(HashtableOfObject) memoryIndex.docsToReferences.get(names[i]), ((Integer) integerPositions[i]).intValue()); |
491 |
((Integer) integerPositions[i]).intValue()); |
|
|
492 |
} |
495 |
} |
493 |
indexedDocuments = null; // free up the space |
496 |
indexedDocuments = null; // free up the space |
494 |
|
497 |
|
Lines 506-537
Link Here
|
506 |
newDiskIndex.writeOffsetToHeader(offsetToHeader); |
509 |
newDiskIndex.writeOffsetToHeader(offsetToHeader); |
507 |
|
510 |
|
508 |
// rename file by deleting previous index file & renaming temp one |
511 |
// rename file by deleting previous index file & renaming temp one |
509 |
File old = getIndexFile(); |
512 |
File old = this.indexFile; |
510 |
if (old.exists() && !old.delete()) { |
513 |
if (old.exists() && !old.delete()) { |
|
|
514 |
String fileName = old.getPath(); |
511 |
if (DEBUG) |
515 |
if (DEBUG) |
512 |
System.out.println("mergeWith - Failed to delete " + this.fileName); //$NON-NLS-1$ |
516 |
System.out.println("mergeWith - Failed to delete " + fileName); //$NON-NLS-1$ |
513 |
throw new IOException("Failed to delete index file " + this.fileName); //$NON-NLS-1$ |
517 |
throw new IOException("Failed to delete index file " + fileName); //$NON-NLS-1$ |
514 |
} |
518 |
} |
515 |
if (!newIndexFile.renameTo(old)) { |
519 |
if (!newIndexFile.renameTo(old)) { |
|
|
520 |
String fileName = old.getPath(); |
516 |
if (DEBUG) |
521 |
if (DEBUG) |
517 |
System.out.println("mergeWith - Failed to rename " + this.fileName); //$NON-NLS-1$ |
522 |
System.out.println("mergeWith - Failed to rename " + fileName); //$NON-NLS-1$ |
518 |
throw new IOException("Failed to rename index file " + this.fileName); //$NON-NLS-1$ |
523 |
throw new IOException("Failed to rename index file " + fileName); //$NON-NLS-1$ |
519 |
} |
524 |
} |
520 |
} catch (IOException e) { |
525 |
} catch (IOException e) { |
521 |
if (newIndexFile.exists() && !newIndexFile.delete()) |
526 |
if (newIndexFile.exists() && !newIndexFile.delete()) |
522 |
if (DEBUG) |
527 |
if (DEBUG) |
523 |
System.out.println("mergeWith - Failed to delete temp index " + newDiskIndex.fileName); //$NON-NLS-1$ |
528 |
System.out.println("mergeWith - Failed to delete temp index " + newDiskIndex.indexFile.getPath()); //$NON-NLS-1$ |
524 |
throw e; |
529 |
throw e; |
525 |
} |
530 |
} |
526 |
|
531 |
|
527 |
newDiskIndex.fileName = this.fileName; |
532 |
newDiskIndex.indexFile = this.indexFile; |
528 |
return newDiskIndex; |
533 |
return newDiskIndex; |
529 |
} |
534 |
} |
530 |
private synchronized String[] readAllDocumentNames() throws IOException { |
535 |
private synchronized String[] readAllDocumentNames() throws IOException { |
531 |
if (this.numberOfChunks <= 0) |
536 |
if (this.numberOfChunks <= 0) |
532 |
return CharOperation.NO_STRINGS; |
537 |
return CharOperation.NO_STRINGS; |
533 |
|
538 |
|
534 |
DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(getIndexFile()), this.numberOfChunks > 5 ? 4096 : 2048)); |
539 |
DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(this.indexFile), this.numberOfChunks > 5 ? 4096 : 2048)); |
535 |
try { |
540 |
try { |
536 |
stream.skip(this.chunkOffsets[0]); |
541 |
stream.skip(this.chunkOffsets[0]); |
537 |
int lastIndex = this.numberOfChunks - 1; |
542 |
int lastIndex = this.numberOfChunks - 1; |
Lines 564-570
Link Here
|
564 |
} |
569 |
} |
565 |
} |
570 |
} |
566 |
|
571 |
|
567 |
DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(getIndexFile()), 2048)); |
572 |
DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(this.indexFile), 2048)); |
568 |
HashtableOfObject categoryTable = null; |
573 |
HashtableOfObject categoryTable = null; |
569 |
char[][] matchingWords = null; |
574 |
char[][] matchingWords = null; |
570 |
int count = 0; |
575 |
int count = 0; |
Lines 575-581
Link Here
|
575 |
try { |
580 |
try { |
576 |
if (size < 0) { // DEBUG |
581 |
if (size < 0) { // DEBUG |
577 |
System.err.println("-------------------- DEBUG --------------------"); //$NON-NLS-1$ |
582 |
System.err.println("-------------------- DEBUG --------------------"); //$NON-NLS-1$ |
578 |
System.err.println("file = "+getIndexFile()); //$NON-NLS-1$ |
583 |
System.err.println("file = "+this.indexFile); //$NON-NLS-1$ |
579 |
System.err.println("offset = "+offset); //$NON-NLS-1$ |
584 |
System.err.println("offset = "+offset); //$NON-NLS-1$ |
580 |
System.err.println("size = "+size); //$NON-NLS-1$ |
585 |
System.err.println("size = "+size); //$NON-NLS-1$ |
581 |
System.err.println("-------------------- END --------------------"); //$NON-NLS-1$ |
586 |
System.err.println("-------------------- END --------------------"); //$NON-NLS-1$ |
Lines 585-591
Link Here
|
585 |
// DEBUG |
590 |
// DEBUG |
586 |
oom.printStackTrace(); |
591 |
oom.printStackTrace(); |
587 |
System.err.println("-------------------- DEBUG --------------------"); //$NON-NLS-1$ |
592 |
System.err.println("-------------------- DEBUG --------------------"); //$NON-NLS-1$ |
588 |
System.err.println("file = "+getIndexFile()); //$NON-NLS-1$ |
593 |
System.err.println("file = "+this.indexFile); //$NON-NLS-1$ |
589 |
System.err.println("offset = "+offset); //$NON-NLS-1$ |
594 |
System.err.println("offset = "+offset); //$NON-NLS-1$ |
590 |
System.err.println("size = "+size); //$NON-NLS-1$ |
595 |
System.err.println("size = "+size); //$NON-NLS-1$ |
591 |
System.err.println("-------------------- END --------------------"); //$NON-NLS-1$ |
596 |
System.err.println("-------------------- END --------------------"); //$NON-NLS-1$ |
Lines 615-630
Link Here
|
615 |
categoryTable.put(word, new Integer(arrayOffset)); // offset to array in the file |
620 |
categoryTable.put(word, new Integer(arrayOffset)); // offset to array in the file |
616 |
} |
621 |
} |
617 |
} |
622 |
} |
618 |
this.categoryTables.put(categoryName, categoryTable); |
623 |
this.categoryTables.put(INTERNED_CATEGORY_NAMES.get(categoryName), categoryTable); |
619 |
// cache the table as long as its not too big |
624 |
// cache the table as long as its not too big |
620 |
// in practice, some tables can be greater than 500K when they contain more than 10K elements |
625 |
// in practice, some tables can be greater than 500K when they contain more than 10K elements |
621 |
this.cachedCategoryName = categoryTable.elementSize < 10000 ? categoryName : null; |
626 |
this.cachedCategoryName = categoryTable.elementSize < 20000 ? categoryName : null; |
|
|
627 |
if (DEBUG) { |
628 |
Util.verbose("Index file "+this.indexFile+" was read to populate category table..."); //$NON-NLS-1$ //$NON-NLS-2$ |
629 |
printCategoryTables(); |
630 |
} |
622 |
} finally { |
631 |
} finally { |
623 |
stream.close(); |
632 |
stream.close(); |
624 |
} |
633 |
} |
625 |
|
634 |
|
626 |
if (matchingWords != null && count > 0) { |
635 |
if (matchingWords != null && count > 0) { |
627 |
stream = new DataInputStream(new BufferedInputStream(new FileInputStream(getIndexFile()), 2048)); |
636 |
stream = new DataInputStream(new BufferedInputStream(new FileInputStream(this.indexFile), 2048)); |
628 |
try { |
637 |
try { |
629 |
stream.skip(firstOffset); |
638 |
stream.skip(firstOffset); |
630 |
for (int i = 0; i < count; i++) // each array follows the previous one |
639 |
for (int i = 0; i < count; i++) // each array follows the previous one |
Lines 688-694
Link Here
|
688 |
if (numberOfBytes < 0) |
697 |
if (numberOfBytes < 0) |
689 |
throw new IllegalArgumentException(); |
698 |
throw new IllegalArgumentException(); |
690 |
byte[] bytes = new byte[numberOfBytes]; |
699 |
byte[] bytes = new byte[numberOfBytes]; |
691 |
FileInputStream file = new FileInputStream(getIndexFile()); |
700 |
FileInputStream file = new FileInputStream(this.indexFile); |
692 |
try { |
701 |
try { |
693 |
file.skip(start); |
702 |
file.skip(start); |
694 |
if (file.read(bytes, 0, numberOfBytes) != numberOfBytes) |
703 |
if (file.read(bytes, 0, numberOfBytes) != numberOfBytes) |
Lines 708-714
Link Here
|
708 |
if (arrayOffset instanceof int[]) |
717 |
if (arrayOffset instanceof int[]) |
709 |
return (int[]) arrayOffset; |
718 |
return (int[]) arrayOffset; |
710 |
|
719 |
|
711 |
DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(getIndexFile()), 2048)); |
720 |
DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(this.indexFile), 2048)); |
712 |
try { |
721 |
try { |
713 |
stream.skip(((Integer) arrayOffset).intValue()); |
722 |
stream.skip(((Integer) arrayOffset).intValue()); |
714 |
return readDocumentArray(stream, stream.readInt()); |
723 |
return readDocumentArray(stream, stream.readInt()); |
Lines 733-739
Link Here
|
733 |
int size = file.readInt(); |
742 |
int size = file.readInt(); |
734 |
this.categoryOffsets = new HashtableOfIntValues(size); |
743 |
this.categoryOffsets = new HashtableOfIntValues(size); |
735 |
for (int i = 0; i < size; i++) |
744 |
for (int i = 0; i < size; i++) |
736 |
this.categoryOffsets.put(Util.readUTF(file), file.readInt()); // cache offset to category table |
745 |
this.categoryOffsets.put(INTERNED_CATEGORY_NAMES.get(Util.readUTF(file)), file.readInt()); // cache offset to category table |
737 |
this.categoryTables = new HashtableOfObject(3); |
746 |
this.categoryTables = new HashtableOfObject(3); |
738 |
} |
747 |
} |
739 |
synchronized void startQuery() { |
748 |
synchronized void startQuery() { |
Lines 909-915
Link Here
|
909 |
} |
918 |
} |
910 |
private void writeOffsetToHeader(int offsetToHeader) throws IOException { |
919 |
private void writeOffsetToHeader(int offsetToHeader) throws IOException { |
911 |
if (offsetToHeader > 0) { |
920 |
if (offsetToHeader > 0) { |
912 |
RandomAccessFile file = new RandomAccessFile(this.fileName, "rw"); //$NON-NLS-1$ |
921 |
RandomAccessFile file = new RandomAccessFile(this.indexFile, "rw"); //$NON-NLS-1$ |
913 |
try { |
922 |
try { |
914 |
file.seek(this.headerInfoOffset); // offset to position in header |
923 |
file.seek(this.headerInfoOffset); // offset to position in header |
915 |
file.writeInt(offsetToHeader); |
924 |
file.writeInt(offsetToHeader); |
Lines 919-922
Link Here
|
919 |
} |
928 |
} |
920 |
} |
929 |
} |
921 |
} |
930 |
} |
|
|
931 |
private void printCategoryTables() { |
932 |
StringBuffer buffer = new StringBuffer(" - categoryTables:"); //$NON-NLS-1$ |
933 |
int size = 0; |
934 |
if (this.categoryTables == null) { |
935 |
buffer.append(" null\n"); //$NON-NLS-1$ |
936 |
} else { |
937 |
char[][] categoryNames = this.categoryTables.keyTable; |
938 |
Object[] tables = this.categoryTables.valueTable; |
939 |
int length = categoryNames.length; |
940 |
for (int i = 0; i < length; i++) { |
941 |
if (categoryNames[i] != null) { |
942 |
buffer.append("\n + "+new String(categoryNames[i])); //$NON-NLS-1$ |
943 |
size += categoryNames[i].length + 16; |
944 |
HashtableOfObject table = (HashtableOfObject) tables[i]; |
945 |
buffer.append(" -> "); //$NON-NLS-1$ |
946 |
if (table == null) { |
947 |
buffer.append(" null\n"); //$NON-NLS-1$ |
948 |
} else { |
949 |
buffer.append(table.elementSize); |
950 |
buffer.append(" int arrays"); //$NON-NLS-1$ |
951 |
int offset = table.elementSize / 10; |
952 |
int tableSize = 16; |
953 |
for (int j=0, l=table.keyTable.length; j<l; j++) { |
954 |
char[] key = table.keyTable[j]; |
955 |
if (key != null) { |
956 |
tableSize += key.length*2 + 16; |
957 |
Object value = table.valueTable[j]; |
958 |
if (value instanceof int[]) { |
959 |
tableSize += (((int[]) value).length-1)*4 + 16; |
960 |
} else if (value instanceof Integer) { |
961 |
tableSize += 20; |
962 |
} |
963 |
if (offset == 0 || (j%offset) == 0) { |
964 |
buffer.append("\n . "); //$NON-NLS-1$ |
965 |
buffer.append(key); |
966 |
buffer.append(" -> "); //$NON-NLS-1$ |
967 |
buffer.append(value); |
968 |
} |
969 |
} |
970 |
} |
971 |
buffer.append("\n => size ~ "); //$NON-NLS-1$ |
972 |
buffer.append(tableSize); |
973 |
buffer.append('\n'); |
974 |
size += tableSize; |
975 |
} |
976 |
} |
977 |
} |
978 |
buffer.append("\n => size ~ "); //$NON-NLS-1$ |
979 |
buffer.append(size); |
980 |
buffer.append('\n'); |
981 |
} |
982 |
buffer.append(" - cached category:"); //$NON-NLS-1$ |
983 |
buffer.append(this.cachedCategoryName==null?"none":new String(this.cachedCategoryName)); //$NON-NLS-1$ |
984 |
buffer.append('\n'); |
985 |
Util.verbose(buffer.toString()); |
986 |
} |
987 |
/* (non-Javadoc) |
988 |
* @see java.lang.Object#toString() |
989 |
*/ |
990 |
public String toString() { |
991 |
return "DiskIndex for "+this.indexFile; //$NON-NLS-1$ |
992 |
} |
922 |
} |
993 |
} |