• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RefCounted类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



RefCounted类属于org.apache.solr.util包,在下文中一共展示了RefCounted类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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:europeana,项目名称:search,代码行数:20,代码来源:DirectUpdateHandler2.java


示例4: 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()
          .getIndexAnalyzer());
      
      for (Query q : dbqList) {
        writer.deleteDocuments(q);
      }
    } finally {
      iw.decref();
    }
    
    if (ulog != null) ulog.add(cmd, true);
  }
  
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:DirectUpdateHandler2.java


示例5: 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


示例6: newHolder

import org.apache.solr.util.RefCounted; //导入依赖的package包/类
private RefCounted<SolrIndexSearcher> newHolder(SolrIndexSearcher newSearcher, final List<RefCounted<SolrIndexSearcher>> searcherList) {
  RefCounted<SolrIndexSearcher> holder = new RefCounted<SolrIndexSearcher>(newSearcher) {
    @Override
    public void close() {
      try {
        synchronized(searcherLock) {
          // it's possible for someone to get a reference via the _searchers queue
          // and increment the refcount while RefCounted.close() is being called.
          // we check the refcount again to see if this has happened and abort the close.
          // This relies on the RefCounted class allowing close() to be called every
          // time the counter hits zero.
          if (refcount.get() > 0) return;
          searcherList.remove(this);
        }
        resource.close();
      } catch (Exception e) {
        // do not allow decref() operations to fail since they are typically called in finally blocks
        // and throwing another exception would be very unexpected.
        SolrException.log(log, "Error closing searcher:" + this, e);
      }
    }
  };
  holder.incref();  // set ref count to 1 to account for this._searcher
  return holder;
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:SolrCore.java


示例7: waitForNewSearcher

import org.apache.solr.util.RefCounted; //导入依赖的package包/类
boolean waitForNewSearcher(int timeout) {
  long timeoutTime = System.currentTimeMillis() + timeout;
  while (System.currentTimeMillis() < timeoutTime) {
    if (triggered) {
      // check if the new searcher has been registered yet
      RefCounted<SolrIndexSearcher> registeredSearcherH = newSearcher.getCore().getSearcher();
      SolrIndexSearcher registeredSearcher = registeredSearcherH.get();
      registeredSearcherH.decref();
      if (registeredSearcher == newSearcher) return true;
      // log.info("TEST: waiting for searcher " + newSearcher + " to be registered.  current=" + registeredSearcher);
    }

    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {}

  }
  return false;
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:AutoCommitTest.java


示例8: testDocValues

import org.apache.solr.util.RefCounted; //导入依赖的package包/类
public void testDocValues() throws IOException {
  assertU(adoc("id", "1", "floatdv", "4.5", "intdv", "-1", "intdv", "3", "stringdv", "value1", "stringdv", "value2"));
  assertU(commit());
  try (SolrCore core = h.getCoreInc()) {
    final RefCounted<SolrIndexSearcher> searcherRef = core.openNewSearcher(true, true);
    final SolrIndexSearcher searcher = searcherRef.get();
    try {
      final AtomicReader reader = searcher.getAtomicReader();
      assertEquals(1, reader.numDocs());
      final FieldInfos infos = reader.getFieldInfos();
      assertEquals(DocValuesType.SORTED_SET, infos.fieldInfo("stringdv").getDocValuesType());
      assertEquals(DocValuesType.SORTED_SET, infos.fieldInfo("floatdv").getDocValuesType());
      assertEquals(DocValuesType.SORTED_SET, infos.fieldInfo("intdv").getDocValuesType());

      SortedSetDocValues dv = reader.getSortedSetDocValues("stringdv");
      dv.setDocument(0);
      assertEquals(0, dv.nextOrd());
      assertEquals(1, dv.nextOrd());
      assertEquals(SortedSetDocValues.NO_MORE_ORDS, dv.nextOrd());
    } finally {
      searcherRef.decref();
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:DocValuesMultiTest.java


示例9: checkRootNode

import org.apache.solr.util.RefCounted; //导入依赖的package包/类
private void checkRootNode(NamedList<Object> before, SolrCore core, AlfrescoSolrDataModel dataModel)
            throws IOException, org.apache.lucene.queryparser.classic.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,代码行数:23,代码来源:AlfrescoCoreAdminTester.java


示例10: checkDataType

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

        testQuery(dataModel, report, solrIndexSearcher, "d\\:double:\"5.6\"", 1);
        testQuery(dataModel, report, solrIndexSearcher, "d\\:content:\"fox\"", 1);
        testQuery(dataModel, report, solrIndexSearcher, "d\\:content:\"fox\"", 1, Locale.US, null, null);

    }
    finally
    {
        if (refCounted != null)
        {
            refCounted.decref();
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:AlfrescoCoreAdminTester.java


示例11: deleteByTransactionId

import org.apache.solr.util.RefCounted; //导入依赖的package包/类
@Override
public void deleteByTransactionId(Long transactionId) 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_INTXID, NumericEncoder.encode(transactionId)));
        deleteByQuery(solrIndexSearcher, query);
    }
    finally
    {
        if (refCounted != null)
        {
            refCounted.decref();
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:20,代码来源:LegacySolrInformationServer.java


示例12: deleteByNodeId

import org.apache.solr.util.RefCounted; //导入依赖的package包/类
@Override
public void deleteByNodeId(Long nodeId) 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_DBID, NumericEncoder.encode(nodeId)));
        deleteByQuery(solrIndexSearcher, query);
    }
    finally
    {
        if (refCounted != null)
        {
            refCounted.decref();
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:21,代码来源:LegacySolrInformationServer.java


示例13: deleteByAclId

import org.apache.solr.util.RefCounted; //导入依赖的package包/类
@Override
public void deleteByAclId(Long aclId) 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_ACLID, NumericEncoder.encode(aclId)));
        deleteByQuery(solrIndexSearcher, query);
    }
    finally
    {
        if (refCounted != null)
        {
            refCounted.decref();
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:21,代码来源:LegacySolrInformationServer.java


示例14: 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


示例15: 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


示例16: checkQNames

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

        testQuery(dataModel, report, solrIndexSearcher, "QNAME:\"nine\"", 1);
        testQuery(dataModel, report, solrIndexSearcher, "PRIMARYASSOCTYPEQNAME:\"cm:contains\"", 11);
        testQuery(dataModel, report, solrIndexSearcher, "PRIMARYASSOCTYPEQNAME:\"sys:children\"", 4);
        testQuery(dataModel, report, solrIndexSearcher, "ASSOCTYPEQNAME:\"cm:contains\"", 11);
        testQuery(dataModel, report, solrIndexSearcher, "ASSOCTYPEQNAME:\"sys:children\"", 5);
    }
    finally
    {
        if (refCounted != null)
        {
            refCounted.decref();
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:AlfrescoCoreAdminHandler.java


示例17: checkAll

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

        testQuery(dataModel, report, solrIndexSearcher, "ALL:\"fox\"", 1, null, null, null);
        testQuery(dataModel, report, solrIndexSearcher, "ALL:\"fox\"", 0, null, null, new String[] { "@" + ContentModel.PROP_NAME.toString() });
        testQuery(dataModel, report, solrIndexSearcher, "ALL:\"fox\"", 1, null, null,
                new String[] { "@" + ContentModel.PROP_NAME.toString(), "@" + ContentModel.PROP_CONTENT.toString() });
        testQuery(dataModel, report, solrIndexSearcher, "ALL:\"5.6\"", 1, null, null, null);
    }
    finally
    {
        if (refCounted != null)
        {
            refCounted.decref();
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:AlfrescoCoreAdminHandler.java


示例18: checkDataType

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

        testQuery(dataModel, report, solrIndexSearcher, "d\\:double:\"5.6\"", 1);
        testQuery(dataModel, report, solrIndexSearcher, "d\\:content:\"fox\"", 1);
        testQuery(dataModel, report, solrIndexSearcher, "d\\:content:\"fox\"", 1, Locale.US, null, null);

    }
    finally
    {
        if (refCounted != null)
        {
            refCounted.decref();
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:24,代码来源:AlfrescoCoreAdminHandler.java


示例19: checkRanges

import org.apache.solr.util.RefCounted; //导入依赖的package包/类
private void checkRanges(NamedList<Object> before, SolrCore core, AlfrescoSolrDataModel dataModel) throws IOException, org.apache.lucene.queryParser.ParseException
{
    NamedList<Object> report = new SimpleOrderedMap<Object>();
    before.add("Ranges", report);
    RefCounted<SolrIndexSearcher> refCounted = null;
    try
    {
        refCounted = core.getSearcher(false, true, null);
        SolrIndexSearcher solrIndexSearcher = refCounted.get();
        testQuery(dataModel, report, solrIndexSearcher, "\\@" + SearchLanguageConversion.escapeLuceneQuery(orderText.toString()) + ":[a TO b]", 1);
        testQuery(dataModel, report, solrIndexSearcher, "\\@" + SearchLanguageConversion.escapeLuceneQuery(orderText.toString()) + ":[a TO \uFFFF]", 15);
        testQuery(dataModel, report, solrIndexSearcher, "\\@" + SearchLanguageConversion.escapeLuceneQuery(orderText.toString()) + ":[\u0000 TO b]", 2);
        testQuery(dataModel, report, solrIndexSearcher, "\\@" + SearchLanguageConversion.escapeLuceneQuery(orderText.toString()) + ":[d TO \uFFFF]", 12);

    }
    finally
    {
        if (refCounted != null)
        {
            refCounted.decref();
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:24,代码来源:AlfrescoCoreAdminHandler.java


示例20: 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, core.getSchema()
          .getAnalyzer());
      
      for (Query q : dbqList) {
        writer.deleteDocuments(q);
      }
    } finally {
      iw.decref();
    }
    
    if (ulog != null) ulog.add(cmd, true);
  }
  
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:26,代码来源:DirectUpdateHandler2.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HttpContext类代码示例发布时间:2022-05-22
下一篇:
Java IIOPProfileTemplateImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap