private synchronized String[] readAllDocumentNames() throws IOException { if (this.numberOfChunks <= 0) return CharOperation.NO_STRINGS; InputStream stream = this.indexLocation.getInputStream(); try { int offset = this.chunkOffsets[0]; stream.skip(offset); this.streamBuffer = new byte[BUFFER_READ_SIZE]; this.bufferIndex = 0; this.bufferEnd = stream.read(this.streamBuffer, 0, this.streamBuffer.length); int lastIndex = this.numberOfChunks - 1; String[] docNames = new String[lastIndex * CHUNK_SIZE + this.sizeOfLastChunk]; for (int i = 0; i < this.numberOfChunks; i++) readChunk(docNames, stream, i * CHUNK_SIZE, i < lastIndex ? CHUNK_SIZE : this.sizeOfLastChunk); return docNames; } finally { stream.close(); this.indexLocation.close(); this.streamBuffer = null; } } private synchronized HashtableOfObject readCategoryTable(char[] categoryName, boolean readDocNumbers) throws IOException {
protected boolean hasPreBuiltIndex() { return !this.forceIndexUpdate && (this.indexFileURL != null && this.indexFileURL.exists()); } }
private void writeSavedIndexNamesFile() { Object[] keys = this.indexStates.keyTable; Object[] states = this.indexStates.valueTable; int numToSave = 0; for (int i = 0, l = states.length; i < l; i++) { IndexLocation key = (IndexLocation) keys[i]; if (key != null && states[i] == SAVED_STATE) { numToSave++; } } char[][] arrays = new char[numToSave][]; int idx = 0; for (int i = 0, l = states.length; i < l; i++) { IndexLocation key = (IndexLocation) keys[i]; if (key != null && states[i] == SAVED_STATE) { arrays[idx++] = key.fileName().toCharArray(); } } this.nameRegistry.write(arrays); } }
void initialize(boolean reuseExistingFile) throws IOException { if (this.indexLocation.exists()) { if (reuseExistingFile) { InputStream stream = this.indexLocation.getInputStream(); if (stream == null) { throw new IOException("Failed to use the index file"); //$NON-NLS-1$ this.indexLocation.close(); if (!this.indexLocation.delete()) { if (DEBUG) System.out.println("initialize - Failed to delete index " + this.indexLocation); //$NON-NLS-1$ if (this.indexLocation.createNewFile()) { FileOutputStream stream = new FileOutputStream(this.indexLocation.getIndexFile(), false); try { this.streamBuffer = new byte[BUFFER_READ_SIZE];
if (indexLocation == null) continue; if (indexLocation.startsWith(path)) { Index index = (Index) valueTable[i]; index.monitor = null; locations[count++] = indexLocation; if (this.indexStates.get(indexLocation) == REUSE_STATE) { indexLocation.close(); } else { if (DEBUG) Util.verbose("removing index file " + indexLocation); //$NON-NLS-1$ indexLocation.delete();
indexFile = indexLocation.getIndexFile(); // index is not cached yet, but still want to delete the file if (this.indexStates.get(indexLocation) == REUSE_STATE) { indexLocation.close(); this.indexLocations.put(containerPath, null); } else if (indexFile != null && indexFile.exists()) {
if (indexLocation == null) { if(newIndexURL != null) { indexLocation = IndexLocation.createIndexLocation(newIndexURL); URL existingURL = indexLocation.getUrl(); if (newIndexURL != null) { indexLocation = IndexLocation.createIndexLocation(newIndexURL);
if(IS_MANAGING_PRODUCT_INDEXES_PROPERTY) { indexFile = computeIndexLocation(path, indexURL); if(!updateIndex && !indexFile.exists()) { forceIndexUpdate = true; indexFile = IndexLocation.createIndexLocation(indexURL);
public File getIndexFile() { return this.diskIndex == null ? null : this.diskIndex.indexLocation.getIndexFile(); } public IndexLocation getIndexLocation() {
if (indexLocation.isParticipantIndex() && indexLocation.exists()) { // the index belongs to non-jdt search participant try { IPath container = getParticipantsContainer(indexLocation);
public JrtIndexer(File jrt, SearchParticipant participant, Index index, IPath container, IndexManager indexManager) { this.jrt = jrt; this.participant = (participant != null) ? participant : SearchEngine.getDefaultSearchParticipant(); this.index = index; IndexLocation indexLocation = index.getIndexLocation(); this.indexPath = indexLocation != null ? new Path(indexLocation.getCanonicalFilePath()) : null; this.container = container; this.indexManager = indexManager; }
private synchronized String[] readAllDocumentNames() throws IOException { if (this.numberOfChunks <= 0) return CharOperation.NO_STRINGS; InputStream stream = this.indexLocation.getInputStream(); try { int offset = this.chunkOffsets[0]; stream.skip(offset); this.streamBuffer = new byte[BUFFER_READ_SIZE]; this.bufferIndex = 0; this.bufferEnd = stream.read(this.streamBuffer, 0, this.streamBuffer.length); int lastIndex = this.numberOfChunks - 1; String[] docNames = new String[lastIndex * CHUNK_SIZE + this.sizeOfLastChunk]; for (int i = 0; i < this.numberOfChunks; i++) readChunk(docNames, stream, i * CHUNK_SIZE, i < lastIndex ? CHUNK_SIZE : this.sizeOfLastChunk); return docNames; } finally { stream.close(); this.streamBuffer = null; } } private synchronized HashtableOfObject readCategoryTable(char[] categoryName, boolean readDocNumbers) throws IOException {
synchronized boolean addIndex(IPath containerPath, IndexLocation indexFile) { getIndexStates().put(indexFile, REUSE_STATE); this.indexLocations.put(containerPath, indexFile); Index index = getIndex(containerPath, indexFile, true, false); if (index == null) { indexFile.close(); this.indexLocations.put(containerPath, null); return false; } writeIndexMapFile(); return true; }
private void readIndexMap() { try { char[] indexMaps = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(this.indexNamesMapFile, null); char[][] names = CharOperation.splitOn('\n', indexMaps); if (names.length >= 3) { // First line is DiskIndex signature (see writeIndexMapFile()) String savedSignature = DiskIndex.SIGNATURE; if (savedSignature.equals(new String(names[0]))) { for (int i = 1, l = names.length-1 ; i < l ; i+=2) { IndexLocation indexPath = IndexLocation.createIndexLocation(new URL(new String(names[i]))); if (indexPath == null) continue; this.indexLocations.put(new Path(new String(names[i+1])), indexPath ); this.indexStates.put(indexPath, REUSE_STATE); } } } } catch (IOException ignored) { if (VERBOSE) Util.verbose("Failed to read saved index file names"); //$NON-NLS-1$ } return; } private void readParticipantsIndexNamesFile() {
void initialize(boolean reuseExistingFile) throws IOException { if (this.indexLocation.exists()) { if (reuseExistingFile) { InputStream stream = this.indexLocation.getInputStream(); if (stream == null) { throw new IOException("Failed to use the index file"); //$NON-NLS-1$ this.indexLocation.close(); if (!this.indexLocation.delete()) { if (DEBUG) System.out.println("initialize - Failed to delete index " + this.indexLocation); //$NON-NLS-1$ if (this.indexLocation.createNewFile()) { FileOutputStream stream = new FileOutputStream(this.indexLocation.getIndexFile(), false); try { this.streamBuffer = new byte[BUFFER_READ_SIZE];
if (indexLocation == null) continue; if (indexLocation.startsWith(path)) { Index index = (Index) valueTable[i]; index.monitor = null; locations[count++] = indexLocation; if (this.indexStates.get(indexLocation) == REUSE_STATE) { indexLocation.close(); } else { if (DEBUG) Util.verbose("removing index file " + indexLocation); //$NON-NLS-1$ indexLocation.delete();
indexFile = indexLocation.getIndexFile(); // index is not cached yet, but still want to delete the file if (this.indexStates.get(indexLocation) == REUSE_STATE) { indexLocation.close(); this.indexLocations.put(containerPath, null); } else if (indexFile != null && indexFile.exists()) {
if (indexLocation == null) { if(newIndexURL != null) { indexLocation = IndexLocation.createIndexLocation(newIndexURL); URL existingURL = indexLocation.getUrl(); if (newIndexURL != null) { indexLocation = IndexLocation.createIndexLocation(newIndexURL);
if(IS_MANAGING_PRODUCT_INDEXES_PROPERTY) { indexFile = computeIndexLocation(path, indexURL); if(!updateIndex && !indexFile.exists()) { forceIndexUpdate = true; indexFile = IndexLocation.createIndexLocation(indexURL);
public File getIndexFile() { return this.diskIndex == null ? null : this.diskIndex.indexLocation.getIndexFile(); } public IndexLocation getIndexLocation() {