Java 类org.apache.lucene.search.ReferenceManager 实例源码

项目:elasticsearch_my    文件:EngineConfig.java   
/**
 * Creates a new {@link org.elasticsearch.index.engine.EngineConfig}
 */
public EngineConfig(OpenMode openMode, ShardId shardId, ThreadPool threadPool,
                    IndexSettings indexSettings, Engine.Warmer warmer, Store store, SnapshotDeletionPolicy deletionPolicy,
                    MergePolicy mergePolicy, Analyzer analyzer,
                    Similarity similarity, CodecService codecService, Engine.EventListener eventListener,
                    TranslogRecoveryPerformer translogRecoveryPerformer, QueryCache queryCache, QueryCachingPolicy queryCachingPolicy,
                    TranslogConfig translogConfig, TimeValue flushMergesAfter, ReferenceManager.RefreshListener refreshListeners,
                    long maxUnsafeAutoIdTimestamp) {
    if (openMode == null) {
        throw new IllegalArgumentException("openMode must not be null");
    }
    this.shardId = shardId;
    this.indexSettings = indexSettings;
    this.threadPool = threadPool;
    this.warmer = warmer == null ? (a) -> {} : warmer;
    this.store = store;
    this.deletionPolicy = deletionPolicy;
    this.mergePolicy = mergePolicy;
    this.analyzer = analyzer;
    this.similarity = similarity;
    this.codecService = codecService;
    this.eventListener = eventListener;
    codecName = indexSettings.getValue(INDEX_CODEC_SETTING);
    // We give IndexWriter a "huge" (256 MB) buffer, so it won't flush on its own unless the ES indexing buffer is also huge and/or
    // there are not too many shards allocated to this node.  Instead, IndexingMemoryController periodically checks
    // and refreshes the most heap-consuming shards when total indexing heap usage across all shards is too high:
    indexingBufferSize = new ByteSizeValue(256, ByteSizeUnit.MB);
    this.translogRecoveryPerformer = translogRecoveryPerformer;
    this.queryCache = queryCache;
    this.queryCachingPolicy = queryCachingPolicy;
    this.translogConfig = translogConfig;
    this.flushMergesAfter = flushMergesAfter;
    this.openMode = openMode;
    this.refreshListeners = refreshListeners;
    assert maxUnsafeAutoIdTimestamp >= IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP :
        "maxUnsafeAutoIdTimestamp must be >= -1 but was " + maxUnsafeAutoIdTimestamp;
    this.maxUnsafeAutoIdTimestamp = maxUnsafeAutoIdTimestamp;
}
项目:elasticsearch_my    文件:LiveVersionMap.java   
/** Sync'd because we replace old mgr. */
synchronized void setManager(ReferenceManager<?> newMgr) {
    if (mgr != null) {
        mgr.removeListener(this);
    }
    mgr = newMgr;

    // In case InternalEngine closes & opens a new IndexWriter/SearcherManager, all deletes are made visible, so we clear old and
    // current here.  This is safe because caller holds writeLock here (so no concurrent adds/deletes can be happeninge):
    maps = new Maps();

    // So we are notified when reopen starts and finishes
    mgr.addListener(this);
}
项目:Elasticsearch    文件:LiveVersionMap.java   
/** Sync'd because we replace old mgr. */
synchronized void setManager(ReferenceManager newMgr) {
    if (mgr != null) {
        mgr.removeListener(this);
    }
    mgr = newMgr;

    // In case InternalEngine closes & opens a new IndexWriter/SearcherManager, all deletes are made visible, so we clear old and
    // current here.  This is safe because caller holds writeLock here (so no concurrent adds/deletes can be happeninge):
    maps = new Maps();

    // So we are notified when reopen starts and finishes
    mgr.addListener(this);
}
项目:search    文件:TestSearcherTaxonomyManager.java   
public IndexerThread(IndexWriter w, FacetsConfig config, TaxonomyWriter tw,
    ReferenceManager<SearcherAndTaxonomy> mgr, int ordLimit, AtomicBoolean stop) {
  this.w = w;
  this.config = config;
  this.tw = tw;
  this.mgr = mgr;
  this.ordLimit = ordLimit;
  this.stop = stop;
}
项目:neo4j-lucene5-index    文件:SearcherManagerFactories.java   
public static SearcherManagerFactory standard()
{
    return new SearcherManagerFactory()
    {
        @Override
        public ReferenceManager<IndexSearcher> create( LuceneIndexWriter indexWriter ) throws IOException
        {
            return indexWriter.createSearcherManager();
        }
    };
}
项目:perecoder    文件:FieldService.java   
@Override
public boolean isFieldsUnique(String metaFieldId) {
    // Проверяем, что поля существуют
    final LuceneCriteriaHolder criteria = criteriaBuilder.createCriteria(
            retrieveTargetClass(),
            createCriteriaByIDs(Field.META_FIELD_ID, metaFieldId).injectSort(Field.VALUE, SortOrder.ASCENDING)
    );
    final int totalCount = queryProvider.executeCountByCriteria(criteria);
    if (totalCount <= 0) {
        return true;
    }
    // Выполняем итерирование значений полей пока не дойдем до конца или не встретим дублирующегося значения
    UniqueFieldHandler uniqueFieldHandler = new UniqueFieldHandler();
    try {
        LuceneQueryUtil.query(
                binderTransformer,
                new LuceneQueryCallback() {
                    @Override
                    public ReferenceManager<IndexSearcher> getSearcherManager() {
                        return refreshSearcherManager(false);
                    }

                    @Override
                    public LuceneQueryDescriptor getQueryDescriptor() {
                        return new LuceneQueryDescriptor(criteria.buildQuery(), criteria.buildSort(), criteria.buildFilter(), 0, totalCount);
                    }

                    @Override
                    public DocumentStoredFieldVisitor createStoredFieldVisitor() {
                        return new DocumentStoredFieldVisitor();
                    }
                },
                uniqueFieldHandler
        );
        return uniqueFieldHandler.isUnique();
    } catch (IOException ex) {
        throw new RuntimeException(String.format("Can't find unique fields '%s' index. Cause by: %s", retrieveTargetClassName(), ex.getMessage()), ex);
    }
}
项目:elasticsearch_my    文件:EngineConfig.java   
/**
 * {@linkplain ReferenceManager.RefreshListener} instance to configure.
 */
public ReferenceManager.RefreshListener getRefreshListeners() {
    return refreshListeners;
}
项目:elasticsearch_my    文件:InternalEngineTests.java   
public EngineConfig config(IndexSettings indexSettings, Store store, Path translogPath, MergePolicy mergePolicy,
                           long maxUnsafeAutoIdTimestamp, ReferenceManager.RefreshListener refreshListener) {
    return config(indexSettings, store, translogPath, mergePolicy, createSnapshotDeletionPolicy(),
                  maxUnsafeAutoIdTimestamp, refreshListener);
}
项目:search    文件:TestTryDelete.java   
public void testTryDeleteDocument ()
  throws IOException
{
  Directory directory = createIndex();

  IndexWriter writer = getWriter(directory);

  ReferenceManager<IndexSearcher> mgr = new SearcherManager(writer,
                                                            true,
                                                            new SearcherFactory());

  TrackingIndexWriter mgrWriter = new TrackingIndexWriter(writer);

  IndexSearcher searcher = mgr.acquire();

  TopDocs topDocs = searcher.search(new TermQuery(new Term("foo", "0")),
                                    100);
  assertEquals(1, topDocs.totalHits);

  long result;
  if (random().nextBoolean()) {
    IndexReader r = DirectoryReader.open(writer, true);
    result = mgrWriter.tryDeleteDocument(r, 0);
    r.close();
  } else {
    result = mgrWriter.tryDeleteDocument(searcher.getIndexReader(), 0);
  }

  // The tryDeleteDocument should have succeeded:
  assertTrue(result != -1);

  assertTrue(writer.hasDeletions());

  if (random().nextBoolean()) {
    writer.commit();
  }

  assertTrue(writer.hasDeletions());

  mgr.maybeRefresh();

  searcher = mgr.acquire();

  topDocs = searcher.search(new TermQuery(new Term("foo", "0")), 100);

  assertEquals(0, topDocs.totalHits);
}
项目:neo4j-lucene5-index    文件:LuceneIndexAccessor.java   
Wrap( ReferenceManager<G> delegate )
{

    this.delegate = delegate;
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestTryDelete.java   
public void testTryDeleteDocument ()
  throws IOException
{
  Directory directory = createIndex();

  IndexWriter writer = getWriter(directory);

  ReferenceManager<IndexSearcher> mgr = new SearcherManager(writer,
                                                            true,
                                                            new SearcherFactory());

  TrackingIndexWriter mgrWriter = new TrackingIndexWriter(writer);

  IndexSearcher searcher = mgr.acquire();

  TopDocs topDocs = searcher.search(new TermQuery(new Term("foo", "0")),
                                    100);
  assertEquals(1, topDocs.totalHits);

  long result;
  if (random().nextBoolean()) {
    IndexReader r = DirectoryReader.open(writer, true);
    result = mgrWriter.tryDeleteDocument(r, 0);
    r.close();
  } else {
    result = mgrWriter.tryDeleteDocument(searcher.getIndexReader(), 0);
  }

  // The tryDeleteDocument should have succeeded:
  assertTrue(result != -1);

  assertTrue(writer.hasDeletions());

  if (random().nextBoolean()) {
    writer.commit();
  }

  assertTrue(writer.hasDeletions());

  mgr.maybeRefresh();

  searcher = mgr.acquire();

  topDocs = searcher.search(new TermQuery(new Term("foo", "0")), 100);

  assertEquals(0, topDocs.totalHits);
}
项目:search    文件:TestTryDelete.java   
public void testDeleteDocuments ()
  throws IOException
{
  Directory directory = createIndex();

  IndexWriter writer = getWriter(directory);

  ReferenceManager<IndexSearcher> mgr = new SearcherManager(writer,
                                                            true,
                                                            new SearcherFactory());

  IndexSearcher searcher = mgr.acquire();

  TopDocs topDocs = searcher.search(new TermQuery(new Term("foo", "0")),
                                    100);
  assertEquals(1, topDocs.totalHits);

  TrackingIndexWriter mgrWriter = new TrackingIndexWriter(writer);
  long result = mgrWriter.deleteDocuments(new TermQuery(new Term("foo",
                                                                 "0")));

  assertEquals(1, result);

  // writer.commit();

  assertTrue(writer.hasDeletions());

  mgr.maybeRefresh();

  searcher = mgr.acquire();

  topDocs = searcher.search(new TermQuery(new Term("foo", "0")), 100);

  assertEquals(0, topDocs.totalHits);
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestTryDelete.java   
public void testDeleteDocuments ()
  throws IOException
{
  Directory directory = createIndex();

  IndexWriter writer = getWriter(directory);

  ReferenceManager<IndexSearcher> mgr = new SearcherManager(writer,
                                                            true,
                                                            new SearcherFactory());

  IndexSearcher searcher = mgr.acquire();

  TopDocs topDocs = searcher.search(new TermQuery(new Term("foo", "0")),
                                    100);
  assertEquals(1, topDocs.totalHits);

  TrackingIndexWriter mgrWriter = new TrackingIndexWriter(writer);
  long result = mgrWriter.deleteDocuments(new TermQuery(new Term("foo",
                                                                 "0")));

  assertEquals(1, result);

  // writer.commit();

  assertTrue(writer.hasDeletions());

  mgr.maybeRefresh();

  searcher = mgr.acquire();

  topDocs = searcher.search(new TermQuery(new Term("foo", "0")), 100);

  assertEquals(0, topDocs.totalHits);
}
项目:search    文件:TestTryDelete.java   
public void testTryDeleteDocumentCloseAndReopen ()
  throws IOException
{
  Directory directory = createIndex();

  IndexWriter writer = getWriter(directory);

  ReferenceManager<IndexSearcher> mgr = new SearcherManager(writer,
                                                            true,
                                                            new SearcherFactory());

  IndexSearcher searcher = mgr.acquire();

  TopDocs topDocs = searcher.search(new TermQuery(new Term("foo", "0")),
                                    100);
  assertEquals(1, topDocs.totalHits);

  TrackingIndexWriter mgrWriter = new TrackingIndexWriter(writer);
  long result = mgrWriter.tryDeleteDocument(DirectoryReader.open(writer,
                                                                 true), 0);

  assertEquals(1, result);

  writer.commit();

  assertTrue(writer.hasDeletions());

  mgr.maybeRefresh();

  searcher = mgr.acquire();

  topDocs = searcher.search(new TermQuery(new Term("foo", "0")), 100);

  assertEquals(0, topDocs.totalHits);

  writer.close();

  searcher = new IndexSearcher(DirectoryReader.open(directory));

  topDocs = searcher.search(new TermQuery(new Term("foo", "0")), 100);

  assertEquals(0, topDocs.totalHits);

}
项目:Maskana-Gestor-de-Conocimiento    文件:TestTryDelete.java   
public void testTryDeleteDocumentCloseAndReopen ()
  throws IOException
{
  Directory directory = createIndex();

  IndexWriter writer = getWriter(directory);

  ReferenceManager<IndexSearcher> mgr = new SearcherManager(writer,
                                                            true,
                                                            new SearcherFactory());

  IndexSearcher searcher = mgr.acquire();

  TopDocs topDocs = searcher.search(new TermQuery(new Term("foo", "0")),
                                    100);
  assertEquals(1, topDocs.totalHits);

  TrackingIndexWriter mgrWriter = new TrackingIndexWriter(writer);
  long result = mgrWriter.tryDeleteDocument(DirectoryReader.open(writer,
                                                                 true), 0);

  assertEquals(1, result);

  writer.commit();

  assertTrue(writer.hasDeletions());

  mgr.maybeRefresh();

  searcher = mgr.acquire();

  topDocs = searcher.search(new TermQuery(new Term("foo", "0")), 100);

  assertEquals(0, topDocs.totalHits);

  writer.close();

  searcher = new IndexSearcher(DirectoryReader.open(directory));

  topDocs = searcher.search(new TermQuery(new Term("foo", "0")), 100);

  assertEquals(0, topDocs.totalHits);

}
项目:neo4j-lucene5-index    文件:SearcherManagerFactory.java   
ReferenceManager<IndexSearcher> create( LuceneIndexWriter indexWriter ) throws IOException;