当前位置: 首页>>代码示例>>Java>>正文


Java RefCounted.decref方法代码示例

本文整理汇总了Java中org.apache.solr.util.RefCounted.decref方法的典型用法代码示例。如果您正苦于以下问题:Java RefCounted.decref方法的具体用法?Java RefCounted.decref怎么用?Java RefCounted.decref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.util.RefCounted的用法示例。


在下文中一共展示了RefCounted.decref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteAll

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
/** currently for testing only */
public void deleteAll() {
  synchronized (this) {

    try {
      RefCounted<SolrIndexSearcher> holder = uhandler.core.openNewSearcher(true, true);
      holder.decref();
    } catch (Exception e) {
      SolrException.log(log, "Error opening realtime searcher for deleteByQuery", e);
    }

    if (map != null) map.clear();
    if (prevMap != null) prevMap.clear();
    if (prevMap2 != null) prevMap2.clear();

    oldDeletes.clear();
    deleteByQueries.clear();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:UpdateLog.java

示例2: getVersionFromIndex

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
public Long getVersionFromIndex(BytesRef idBytes) {
  // TODO: we could cache much of this and invalidate during a commit.
  // TODO: most DocValues classes are threadsafe - expose which.

  RefCounted<SolrIndexSearcher> newestSearcher = ulog.uhandler.core.getRealtimeSearcher();
  try {
    SolrIndexSearcher searcher = newestSearcher.get();
    long lookup = searcher.lookupId(idBytes);
    if (lookup < 0) return null;

    ValueSource vs = versionField.getType().getValueSource(versionField, null);
    Map context = ValueSource.newContext(searcher);
    vs.createWeight(context, searcher);
    FunctionValues fv = vs.getValues(context, searcher.getTopReaderContext().leaves().get((int)(lookup>>32)));
    long ver = fv.longVal((int)lookup);
    return ver;

  } catch (IOException e) {
    throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error reading version from index", e);
  } finally {
    if (newestSearcher != null) {
      newestSearcher.decref();
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:VersionInfo.java

示例3: prepareCommit

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
public void prepareCommit(CommitUpdateCommand cmd) throws IOException {

    boolean error=true;

    try {
      log.info("start "+cmd);
      RefCounted<IndexWriter> iw = solrCoreState.getIndexWriter(core);
      try {
        final Map<String,String> commitData = new HashMap<>();
        commitData.put(SolrIndexWriter.COMMIT_TIME_MSEC_KEY,
            String.valueOf(System.currentTimeMillis()));
        iw.get().setCommitData(commitData);
        iw.get().prepareCommit();
      } finally {
        iw.decref();
      }

      log.info("end_prepareCommit");

      error=false;
    }
    finally {
      if (error) numErrors.incrementAndGet();
    }
  }
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:DirectUpdateHandler2.java

示例4: checkRootNode

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
/**
 * @param before
 * @throws IOException
 * @throws org.apache.lucene.queryParser.ParseException
 */
private void checkRootNode(NamedList<Object> before, SolrCore core, AlfrescoSolrDataModel dataModel) throws IOException, org.apache.lucene.queryParser.ParseException
{
    NamedList<Object> report = new SimpleOrderedMap<Object>();
    before.add("RootNode", report);
    RefCounted<SolrIndexSearcher> refCounted = null;
    try
    {
        refCounted = core.getSearcher(false, true, null);
        SolrIndexSearcher solrIndexSearcher = refCounted.get();

        testQuery(dataModel, report, solrIndexSearcher, "PATH:\"/\"", 1);
        testQuery(dataModel, report, solrIndexSearcher, "PATH:\"/.\"", 1);
    }
    finally
    {
        if (refCounted != null)
        {
            refCounted.decref();
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:27,代码来源:AlfrescoCoreAdminHandler.java

示例5: addAndDelete

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
/** Add a document execute the deletes as atomically as possible */
private void addAndDelete(AddUpdateCommand cmd, List<Query> dbqList)
    throws IOException {
  Document luceneDocument = cmd.getLuceneDocument();
  Term idTerm = new Term(idField.getName(), cmd.getIndexedId());
  
  // see comment in deleteByQuery
  synchronized (solrCoreState.getUpdateLock()) {
    RefCounted<IndexWriter> iw = solrCoreState.getIndexWriter(core);
    try {
      IndexWriter writer = iw.get();
      writer.updateDocument(idTerm, luceneDocument, cmd.getReq().getSchema()
          .getAnalyzer());
      
      for (Query q : dbqList) {
        writer.deleteDocuments(q);
      }
    } finally {
      iw.decref();
    }
    
    if (ulog != null) ulog.add(cmd, true);
  }
  
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:26,代码来源:DirectUpdateHandler2.java

示例6: delete

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
@Override
public void delete(DeleteUpdateCommand cmd) throws IOException {
  deleteByIdCommands.incrementAndGet();
  deleteByIdCommandsCumulative.incrementAndGet();

  Term deleteTerm = new Term(idField.getName(), cmd.getIndexedId());
  // SolrCore.verbose("deleteDocuments",deleteTerm,writer);
  RefCounted<IndexWriter> iw = solrCoreState.getIndexWriter(core);
  try {
    iw.get().deleteDocuments(deleteTerm);
  } finally {
    iw.decref();
  }
  // SolrCore.verbose("deleteDocuments",deleteTerm,"DONE");

  if (ulog != null) ulog.delete(cmd);

  updateDeleteTrackers(cmd);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:20,代码来源:DirectUpdateHandler2.java

示例7: deleteByAclChangeSetId

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
@Override
public void deleteByAclChangeSetId(Long aclChangeSetId) throws IOException
{
    RefCounted<SolrIndexSearcher> refCounted = null;
    try
    {
        refCounted = core.getSearcher(false, true, null);
        SolrIndexSearcher solrIndexSearcher = refCounted.get();

        Query query = new TermQuery(new Term(QueryConstants.FIELD_INACLTXID, NumericEncoder.encode(aclChangeSetId)));
        deleteByQuery(solrIndexSearcher, query);
    }
    finally
    {
        if (refCounted != null)
        {
            refCounted.decref();
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:21,代码来源:LegacySolrInformationServer.java

示例8: isInIndex

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
@Override
public boolean isInIndex(String fieldType, long id) throws IOException
{
    String target = NumericEncoder.encode(id);
    RefCounted<SolrIndexSearcher> refCounted = null;
    Term term = null;
    try
    {
        refCounted = core.getSearcher(false, true, null);

        TermEnum termEnum = refCounted.get().getReader().terms(new Term(fieldType, target));
        term = termEnum.term();
        termEnum.close();
    }
    finally
    {
        if (refCounted != null)
        {
            refCounted.decref();
        }
        refCounted = null;
    }

    return term != null && target.equals(term.text());
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:26,代码来源:LegacySolrInformationServer.java

示例9: getIndexVersion

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
private long[] getIndexVersion() {
  long version[] = new long[2];
  RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
  try {
    final IndexCommit commit = searcher.get().getIndexReader().getIndexCommit();
    final Map<String,String> commitData = commit.getUserData();
    String commitTime = commitData.get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
    if (commitTime != null) {
      version[0] = Long.parseLong(commitTime);
    }
    version[1] = commit.getGeneration();
  } catch (IOException e) {
    LOG.warn("Unable to get index version : ", e);
  } finally {
    searcher.decref();
  }
  return version;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:19,代码来源:ReplicationHandler.java

示例10: assertNotNRT

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
static void assertNotNRT(int maxDoc) {
  SolrCore core = h.getCore();
  log.info("Checking notNRT & maxDoc=" + maxDoc + " of core=" + core.toString());
  RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
  try {
    SolrIndexSearcher s = searcher.get();
    DirectoryReader ir = s.getIndexReader();
    assertEquals("SOLR-5815? : wrong maxDoc: core=" + core.toString() +" searcher=" + s.toString(),
                 maxDoc, ir.maxDoc());
    assertFalse("SOLR-5815? : expected non-NRT reader, got: " + ir, ir.toString().contains(":nrt"));
  } finally {
    searcher.decref();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:TestNonNRTOpen.java

示例11: deleteAll

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
private void deleteAll() throws IOException {
  SolrCore.log.info(core.getLogId()+"REMOVING ALL DOCUMENTS FROM INDEX");
  RefCounted<IndexWriter> iw = solrCoreState.getIndexWriter(core);
  try {
    iw.get().deleteAll();
  } finally {
    iw.decref();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:DirectUpdateHandler2.java

示例12: testAlternateDistance

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
@Test
public void testAlternateDistance() throws Exception {
  TestSpellChecker checker = new TestSpellChecker();
  NamedList spellchecker = new NamedList();
  spellchecker.add("classname", IndexBasedSpellChecker.class.getName());

  File indexDir = createTempDir();
  spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
  spellchecker.add(AbstractLuceneSpellChecker.FIELD, "title");
  spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, spellchecker);
  spellchecker.add(AbstractLuceneSpellChecker.STRING_DISTANCE, JaroWinklerDistance.class.getName());
  SolrCore core = h.getCore();
  String dictName = checker.init(spellchecker, core);
  assertTrue(dictName + " is not equal to " + SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
          dictName.equals(SolrSpellChecker.DEFAULT_DICTIONARY_NAME) == true);
  RefCounted<SolrIndexSearcher> holder = core.getSearcher();
  SolrIndexSearcher searcher = holder.get();
  try {
  checker.build(core, searcher);
  SpellChecker sc = checker.getSpellChecker();
  assertTrue("sc is null and it shouldn't be", sc != null);
  StringDistance sd = sc.getStringDistance();
  assertTrue("sd is null and it shouldn't be", sd != null);
  assertTrue("sd is not an instance of " + JaroWinklerDistance.class.getName(), sd instanceof JaroWinklerDistance);
  } finally {
    holder.decref();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:IndexBasedSpellCheckerTest.java

示例13: assertCompoundSegments

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
/**
 * Given an SolrCore, asserts that each segment in the (searchable) index 
 * has a compound file status that matches the expected input.
 */
public static void assertCompoundSegments(SolrCore core, boolean compound) {
  RefCounted<SolrIndexSearcher> searcherRef = core.getRegisteredSearcher();
  try {
    assertCompoundSegments(searcherRef.get().getIndexReader(), compound);
  } finally {
    searcherRef.decref();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:TestMergePolicyConfig.java

示例14: getCoreCacheKeys

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
private Set<Object> getCoreCacheKeys() {
  RefCounted<SolrIndexSearcher> searcher = h.getCore().getSearcher();
  Set<Object> set = Collections.newSetFromMap(new IdentityHashMap<Object,Boolean>());
  try {
    DirectoryReader ir = searcher.get().getIndexReader();
    for (AtomicReaderContext context : ir.leaves()) {
      set.add(context.reader().getCoreCacheKey());
    }
  } finally {
    searcher.decref();
  }
  return set;
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:TestNonNRTOpen.java

示例15: getSimilarity

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
/** returns the similarity in use for the field */
protected Similarity getSimilarity(String field) {
  SolrCore core = h.getCore();
  RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
  Similarity sim = searcher.get().getSimilarity();
  searcher.decref();
  while (sim instanceof PerFieldSimilarityWrapper) {
    sim = ((PerFieldSimilarityWrapper)sim).get(field);
  }
  return sim;
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:BaseSimilarityTestCase.java


注:本文中的org.apache.solr.util.RefCounted.decref方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。