synchronized void store() { if (unsavedQueue.isEmpty()) { return; } long start = System.currentTimeMillis(); StoreQueueEntry entry = unsavedQueue.poll(); while (entry != null) { final CndTextIndexKey key = entry.key; // use unitID+fileID for primary key, otherwise indexed files from different projects overwrite each others IndexDocument doc = IndexManager.createDocument(toPrimaryKey(key)); for (CharSequence id : entry.ids) { doc.addPair(TextIndexStorageManager.FIELD_IDS, id.toString(), true, false); } index.addDocument(doc); entry = unsavedQueue.poll(); } try { index.store(false); } catch (Exception ex) { Exceptions.printStackTrace(ex); } LOG.log(Level.FINE, "Cnd Text Index store took {0}ms", System.currentTimeMillis() - start); }
@Override public TextIndexLayer createLayer(final LayerDescriptor layerDescriptor) { try { File indexRoot = new File(new File(layerDescriptor.getURI().getPath()), INDEX_FOLDER_NAME); final boolean isWritable = layerDescriptor.isWritable(); if (!indexRoot.exists() && isWritable) { indexRoot.mkdirs(); } if (!indexRoot.exists()) { return null; } DocumentIndex index = IndexManager.createDocumentIndex(indexRoot, isWritable); return new DiskTextIndexLayer(layerDescriptor, index); } catch (IOException ex) { Logger.getLogger(DistTextIndexLayerFactory.class.getName()).log(Level.SEVERE, null, ex); } return null; } }
/** Creates a new instance of ClassesAndMembersUQ */ private PersistentClassIndex( final URL root, final File cacheRoot, final Type beforeInitType, final Type finalType) throws IOException, IllegalArgumentException { assert root != null; this.root = root; this.cacheRoot = cacheRoot; this.beforeInitType = beforeInitType; this.finalType = finalType; this.index = IndexManager.createIndex(getReferencesCacheFolder(cacheRoot), DocumentUtil.createAnalyzer()); this.indexPath = new IndexPatch(); }
@Override public void getPackageNames (final String prefix, final boolean directOnly, final Set<String> result) throws InterruptedException, IOException { try { IndexManager.priorityAccess(new IndexManager.Action<Void>() { @Override public Void run () throws IOException, InterruptedException {
result = IndexManager.createMemoryIndex(DocumentUtil.createAnalyzer()); result.store( data,
@Override public void getReferencesFrequences ( @NonNull final Map<String,Integer> typeFreq, @NonNull final Map<String,Integer> pkgFreq) throws IOException, InterruptedException { assert typeFreq != null; assert pkgFreq != null; if (!(index instanceof Index.WithTermFrequencies)) { throw new IllegalStateException("Index does not support frequencies!"); //NOI18N } try { IndexManager.priorityAccess(new IndexManager.Action<Void>() { @Override public Void run() throws IOException, InterruptedException { final Term startTerm = DocumentUtil.referencesTerm("", null, true); //NOI18N final StoppableConvertor<Index.WithTermFrequencies.TermFreq,Void> convertor = new FreqCollector( startTerm, typeFreq, pkgFreq); ((Index.WithTermFrequencies)index).queryTermFrequencies( Collections.<Void>emptyList(), startTerm, convertor, cancel.get()); return null; } }); } catch (IOException ioe) { this.<Void,IOException>handleException(null, ioe, root); } }
final Pair<Convertor<? super Document, T>,Index> ctu = indexPath.getPatch(convertor); try { IndexManager.priorityAccess(new IndexManager.Action<Void>() { @Override public Void run () throws IOException, InterruptedException {
final Pair<Convertor<? super Document, T>,Index> ctu = indexPath.getPatch(convertor); try { IndexManager.priorityAccess(new IndexManager.Action<Void> () { @Override public Void run () throws IOException, InterruptedException {
final ElementKind kind = element.getKind(); if (kind == ElementKind.PACKAGE) { IndexManager.priorityAccess(new IndexManager.Action<Void> () { @Override public Void run () throws IOException, InterruptedException { result); } else { IndexManager.priorityAccess(new IndexManager.Action<Void> () { @Override public Void run () throws IOException, InterruptedException {