View | Details | Raw Unified | Return to bug 200064
Collapse All | Expand All

(-)search/org/eclipse/jdt/internal/core/index/DiskIndex.java (-3 / +7 lines)
Lines 44-51 Link Here
44
private byte[] streamBuffer;
44
private byte[] streamBuffer;
45
private int bufferIndex, bufferEnd; // used when reading from the file into the streamBuffer
45
private int bufferIndex, bufferEnd; // used when reading from the file into the streamBuffer
46
private int streamEnd; // used when writing data from the streamBuffer to the file
46
private int streamEnd; // used when writing data from the streamBuffer to the file
47
char separator = Index.DEFAULT_SEPARATOR;
47
48
48
public static final String SIGNATURE= "INDEX VERSION 1.122"; //$NON-NLS-1$
49
public static final String SIGNATURE= "INDEX VERSION 1.123"; //$NON-NLS-1$
49
private static final char[] SIGNATURE_CHARS = SIGNATURE.toCharArray();
50
private static final char[] SIGNATURE_CHARS = SIGNATURE.toCharArray();
50
public static boolean DEBUG = false;
51
public static boolean DEBUG = false;
51
52
Lines 423-428 Link Here
423
	this.categoryOffsets = new HashtableOfIntValues(size);
424
	this.categoryOffsets = new HashtableOfIntValues(size);
424
	this.categoryEnds = new HashtableOfIntValues(size);
425
	this.categoryEnds = new HashtableOfIntValues(size);
425
	this.categoryTables = new HashtableOfObject(size);
426
	this.categoryTables = new HashtableOfObject(size);
427
	this.separator = diskIndex.separator;
426
}
428
}
427
private void mergeCategories(DiskIndex onDisk, int[] positions, FileOutputStream stream) throws IOException {
429
private void mergeCategories(DiskIndex onDisk, int[] positions, FileOutputStream stream) throws IOException {
428
	// at this point, this.categoryTables contains the names -> wordsToDocs added in copyQueryResults()
430
	// at this point, this.categoryTables contains the names -> wordsToDocs added in copyQueryResults()
Lines 770-775 Link Here
770
	this.numberOfChunks = readStreamInt(stream);
772
	this.numberOfChunks = readStreamInt(stream);
771
	this.sizeOfLastChunk = this.streamBuffer[this.bufferIndex++] & 0xFF;
773
	this.sizeOfLastChunk = this.streamBuffer[this.bufferIndex++] & 0xFF;
772
	this.documentReferenceSize = this.streamBuffer[this.bufferIndex++] & 0xFF;
774
	this.documentReferenceSize = this.streamBuffer[this.bufferIndex++] & 0xFF;
775
	this.separator = (char) (this.streamBuffer[this.bufferIndex++] & 0xFF);
773
776
774
	this.chunkOffsets = new int[this.numberOfChunks];
777
	this.chunkOffsets = new int[this.numberOfChunks];
775
	for (int i = 0; i < this.numberOfChunks; i++)
778
	for (int i = 0; i < this.numberOfChunks; i++)
Lines 1123-1135 Link Here
1123
}
1126
}
1124
private void writeHeaderInfo(FileOutputStream stream) throws IOException {
1127
private void writeHeaderInfo(FileOutputStream stream) throws IOException {
1125
	writeStreamInt(stream, this.numberOfChunks);
1128
	writeStreamInt(stream, this.numberOfChunks);
1126
	if ((this.bufferIndex + 2) >= BUFFER_WRITE_SIZE)  {
1129
	if ((this.bufferIndex + 3) >= BUFFER_WRITE_SIZE)  {
1127
		stream.write(this.streamBuffer, 0, this.bufferIndex);
1130
		stream.write(this.streamBuffer, 0, this.bufferIndex);
1128
		this.bufferIndex = 0;
1131
		this.bufferIndex = 0;
1129
	}
1132
	}
1130
	this.streamBuffer[this.bufferIndex++] = (byte) this.sizeOfLastChunk;
1133
	this.streamBuffer[this.bufferIndex++] = (byte) this.sizeOfLastChunk;
1131
	this.streamBuffer[this.bufferIndex++] = (byte) this.documentReferenceSize;
1134
	this.streamBuffer[this.bufferIndex++] = (byte) this.documentReferenceSize;
1132
	this.streamEnd += 2;
1135
	this.streamBuffer[this.bufferIndex++] = (byte) this.separator;
1136
	this.streamEnd += 3;
1133
1137
1134
	// apend the file with chunk offsets
1138
	// apend the file with chunk offsets
1135
	for (int i = 0; i < this.numberOfChunks; i++) {
1139
	for (int i = 0; i < this.numberOfChunks; i++) {
(-)search/org/eclipse/jdt/internal/core/index/Index.java (-1 / +3 lines)
Lines 32-38 Link Here
32
public ReadWriteMonitor monitor;
32
public ReadWriteMonitor monitor;
33
33
34
// Separator to use after the container path
34
// Separator to use after the container path
35
private static final char DEFAULT_SEPARATOR = '/';
35
static final char DEFAULT_SEPARATOR = '/';
36
public char separator = DEFAULT_SEPARATOR;
36
public char separator = DEFAULT_SEPARATOR;
37
37
38
protected DiskIndex diskIndex;
38
protected DiskIndex diskIndex;
Lines 95-100 Link Here
95
	this.memoryIndex = new MemoryIndex();
95
	this.memoryIndex = new MemoryIndex();
96
	this.diskIndex = new DiskIndex(fileName);
96
	this.diskIndex = new DiskIndex(fileName);
97
	this.diskIndex.initialize(reuseExistingFile);
97
	this.diskIndex.initialize(reuseExistingFile);
98
	if (reuseExistingFile) this.separator = this.diskIndex.separator;
98
}
99
}
99
public void addIndexEntry(char[] category, char[] key, String containerRelativePath) {
100
public void addIndexEntry(char[] category, char[] key, String containerRelativePath) {
100
	this.memoryIndex.addIndexEntry(category, key, containerRelativePath);
101
	this.memoryIndex.addIndexEntry(category, key, containerRelativePath);
Lines 177-182 Link Here
177
	if (!hasChanged()) return;
178
	if (!hasChanged()) return;
178
179
179
	int numberOfChanges = this.memoryIndex.docsToReferences.elementSize;
180
	int numberOfChanges = this.memoryIndex.docsToReferences.elementSize;
181
	this.diskIndex.separator = this.separator;
180
	this.diskIndex = this.diskIndex.mergeWith(this.memoryIndex);
182
	this.diskIndex = this.diskIndex.mergeWith(this.memoryIndex);
181
	this.memoryIndex = new MemoryIndex();
183
	this.memoryIndex = new MemoryIndex();
182
	if (numberOfChanges > 1000)
184
	if (numberOfChanges > 1000)
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (+27 lines)
Lines 8413-8416 Link Here
8413
	}
8413
	}
8414
}
8414
}
8415
8415
8416
/**
8417
 * @bug 200064: [search] ResourceException while searching for method reference
8418
 * @test Ensure that indexing still works properly after close/restart
8419
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=200064"
8420
 */
8421
public void testBug200064() throws CoreException {
8422
	waitUntilIndexesReady();
8423
	simulateExitRestart();
8424
	waitUntilIndexesReady();
8425
	// Search all type names with TypeNameMatchRequestor
8426
	TypeNameMatchCollector collector = new TypeNameMatchCollector();
8427
	new SearchEngine().searchAllTypeNames(
8428
		null,
8429
		SearchPattern.R_EXACT_MATCH,
8430
		"Object".toCharArray(),
8431
		SearchPattern.R_PREFIX_MATCH,
8432
		IJavaSearchConstants.TYPE,
8433
		getJavaSearchScopeBugs(),
8434
		collector,
8435
		IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
8436
		null);
8437
	assertSearchResults(
8438
		"Object (not open) [in Object.class [in java.lang [in "+ getExternalJCLPathString("1.5") + "]]]",
8439
		collector
8440
	);
8441
}
8442
8416
}
8443
}

Return to bug 200064