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


Java RefCounted类代码示例

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


RefCounted类属于org.apache.solr.util包,在下文中一共展示了RefCounted类的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: 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


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