Examples of CollectorContext


Examples of com.browseengine.bobo.sort.SortCollector.CollectorContext

        {
          SortCollector sortCollector = res.getSortCollector();
          if (sortCollector == null) continue;
          int end = (res.getNumHits() % SortCollector.BLOCK_SIZE) - 1;
          Iterator<CollectorContext> contextIter = sortCollector.contextList.descendingIterator();
          CollectorContext currentContext = null;
          int contextLeft = 0;
          FacetDataCache[] dataCaches = new FacetDataCache[sortCollector.groupByMulti.length];
          FacetDataCache[] distinctDataCaches = new FacetDataCache[distinctLength];
          while (contextIter.hasNext()) {
            currentContext = contextIter.next();
            currentContext.restoreRuntimeFacets();
            contextLeft = currentContext.length;
            if (contextLeft > 0)
            {
              for (j=0; j<sortCollector.groupByMulti.length; ++j)
              {
                dataCaches[j] = (FacetDataCache)sortCollector.groupByMulti[j].getFacetData(currentContext.reader);
              }
              for (j=0; j<distinctLength; ++j)
              {
                distinctDataCaches[j] = (FacetDataCache)currentContext.
                    reader.
                    getFacetHandler(req.getDistinct()[j]).
                    getFacetData(currentContext.reader);
              }
              break;
            }
          }

          Iterator<float[]> scoreArrayIter = sortCollector.scorearraylist != null ? sortCollector.scorearraylist.descendingIterator():null;
          if (contextLeft > 0)
          {
            Iterator<int[]> docArrayIter = sortCollector.docidarraylist.descendingIterator();
            while (docArrayIter.hasNext())
            {
              int[] docs = docArrayIter.next();
              float[] scores = scoreArrayIter != null ? scoreArrayIter.next():null;
              for (i = end; i >= 0; --i)
              {
                doc = docs[i];
                score = scores != null ? scores[i]:0.0f;
                for (j=0; j<sortCollector.groupByMulti.length; ++j)
                {
                  rawGroupValue = extractRawGroupValue(rawGroupValueType, j, primitiveLongArrayWrapperTmp,
                      dataCaches[j].valArray.getRawValue(dataCaches[j].orderArray.get(doc)));

                  hitWithGroupQueue = groupMaps[j].get(rawGroupValue);
                  if (hitWithGroupQueue != null)
                  {
                    hitWithGroupQueue.hit.setGroupHitsCount(hitWithGroupQueue.hit.getGroupHitsCount() + 1);
                    if (hitWithGroupQueue.queue == null) break;
                    // Collect this hit.
                    if (tmpScoreDoc == null)
                      tmpScoreDoc = new MyScoreDoc(doc, score, currentContext.base + totalDocs + doc, currentContext.reader);
                    else
                    {
                      tmpScoreDoc.doc = doc;
                      tmpScoreDoc.score = score;
                      tmpScoreDoc.finalDoc = currentContext.base + totalDocs + doc;
                      tmpScoreDoc.reader = currentContext.reader;
                    }
                    tmpScoreDoc.sortValue = currentContext.comparator.value(tmpScoreDoc);
                    tmpScoreDoc.groupPos = j;
                    if (distinctLength > 0)
                    {
                      tmpScoreDoc.distinctValues = new Object[distinctLength];
                    }

                    if (hitWithGroupQueue.queue.size < maxPerGroup ||
                        tmpScoreDoc.sortValue.compareTo(((MyScoreDoc)hitWithGroupQueue.queue.top()).sortValue) < 0)
                    {
                      pre = null;
                      for (k = 0; k < distinctLength; ++k)
                      {
                        tmpScoreDoc.distinctValues[k] = extractRawGroupValue(distinctValueType,
                            k,
                            distinctPrimitiveLongArrayWrapperTmp,
                            distinctDataCaches[k].valArray.getRawValue(
                                distinctDataCaches[k].orderArray.get(doc)
                            ));
                        if (pre == null)
                          pre = hitWithGroupQueue.distinctMap[k].get(tmpScoreDoc.distinctValues[k]);
                      }
                      if (pre != null)
                      {
                        if (tmpScoreDoc.sortValue.compareTo(pre.sortValue) < 0)
                        {
                          hitWithGroupQueue.queue.replace(tmpScoreDoc, pre);
                          for (k = 0; k < distinctLength; ++k)
                          {
                            hitWithGroupQueue.distinctMap[k].remove(pre.distinctValues[k]);
                            hitWithGroupQueue.distinctMap[k].put(tmpScoreDoc.distinctValues[k], tmpScoreDoc);
                          }
                          tmpScoreDoc = pre;
                        }
                      }
                      else
                      {
                        if (hitWithGroupQueue.queue.size >= maxPerGroup) // queue full
                        {
                          pre = (MyScoreDoc)hitWithGroupQueue.queue.top();
                          hitWithGroupQueue.queue.replace(tmpScoreDoc);
                          for (k = 0; k < distinctLength; ++k)
                          {
                            hitWithGroupQueue.distinctMap[k].remove(pre.distinctValues[k]);
                            hitWithGroupQueue.distinctMap[k].put(tmpScoreDoc.distinctValues[k], tmpScoreDoc);
                          }
                          tmpScoreDoc = pre;
                        }
                        else
                        {
                          hitWithGroupQueue.queue.add(tmpScoreDoc);
                          for (k = 0; k < distinctLength; ++k)
                          {
                            hitWithGroupQueue.distinctMap[k].put(tmpScoreDoc.distinctValues[k], tmpScoreDoc);
                          }
                          tmpScoreDoc = null;
                        }
                      }
                    }
                    break;
                  }
                }
                --contextLeft;
                if (contextLeft <= 0)
                {
                  while (contextIter.hasNext()) {
                    currentContext = contextIter.next();
                    currentContext.restoreRuntimeFacets();
                    contextLeft = currentContext.length;
                    if (contextLeft > 0)
                    {
                      for (j=0; j<sortCollector.groupByMulti.length; ++j)
                      {
View Full Code Here

Examples of com.browseengine.bobo.sort.SortCollector.CollectorContext

      int end = (res.getNumHits() % SortCollector.BLOCK_SIZE) - 1;

      Iterator<CollectorContext> contextIter = sortCollector.contextList.descendingIterator();

      // Populate dataCaches and contextLeft
      CollectorContext currentContext = null;
      int contextLeft = 0;
      FacetDataCache[] dataCaches = new FacetDataCache[sortCollector.groupByMulti.length];
      while (contextIter.hasNext()) {
        currentContext = contextIter.next();
        currentContext.restoreRuntimeFacets();
        contextLeft = currentContext.length;
        if (contextLeft > 0)
        {
          for (int j=0; j<sortCollector.groupByMulti.length; ++j)
            dataCaches[j] = (FacetDataCache)sortCollector.groupByMulti[j].getFacetData(currentContext.reader);
          break;
        }
      }

      Iterator<float[]> scoreArrayIter = sortCollector.scorearraylist != null ? sortCollector.scorearraylist.descendingIterator():null;

      if (contextLeft > 0)
      {
        Iterator<int[]> docArrayIter = sortCollector.docidarraylist.descendingIterator();
        while (docArrayIter.hasNext())
        {
          int[] docs = docArrayIter.next();
          float[] scores = scoreArrayIter != null ? scoreArrayIter.next():null;

          for (int i = end; i >= 0; --i)
          {
            tmpScoreDoc.doc = docs[i];
            tmpScoreDoc.score = scores != null ? scores[i] : 0.0f;
            tmpScoreDoc.finalDoc = currentContext.base + totalDocs + tmpScoreDoc.doc;
            tmpScoreDoc.reader = currentContext.reader;
            tmpScoreDoc.sortValue = currentContext.comparator.value(tmpScoreDoc);

            int j=0;

            if (!queueFull || tmpScoreDoc.sortValue.compareTo(bottom.sortValue) < 0)
            {
              for (;; ++j)
              {
                rawGroupValue = dataCaches[j].valArray.getRawValue(dataCaches[j].orderArray.get(tmpScoreDoc.doc));

                rawGroupValue = extractRawGroupValue(rawGroupValueType, j,
                    primitiveLongArrayWrapperTmp, rawGroupValue);

                pre = valueDocMaps[j].get(rawGroupValue);
                if (pre != null)
                {
                  j = -1;
                  break;
                }

                if (j >= combinedFacetAccessibles.length) break;

                if (rawGroupValueType[j] == LONG_ARRAY_GROUP_VALUE_TYPE)
                {
                  if (combinedFacetAccessibles[j].getCappedFacetCount(primitiveLongArrayWrapperTmp.data, 2) != 1)
                    break;
                }
                else
                {
                  if (combinedFacetAccessibles[j].getCappedFacetCount(rawGroupValue, 2) != 1)
                    break;
                }
              }
              if (j < 0)
              {
                if (tmpScoreDoc.sortValue.compareTo(pre.sortValue) < 0)
                {
                  tmpScoreDoc.groupPos = pre.groupPos;
                  tmpScoreDoc.rawGroupValue = pre.rawGroupValue;

                  // Pre has a higher score. Pop it in the queue!
                  bottom = (MyScoreDoc)docQueue.replace(tmpScoreDoc, pre);
                  valueDocMaps[tmpScoreDoc.groupPos].put(tmpScoreDoc.rawGroupValue, tmpScoreDoc);
                  tmpScoreDoc = pre;
                }
              }
              else
              {
                if (queueFull)
                {
                  tmpScoreDoc.groupPos = j;
                  tmpScoreDoc.rawGroupValue = rawGroupValue;
                  MyScoreDoc tmp = bottom;

                  valueDocMaps[tmp.groupPos].remove(tmp.rawGroupValue);

                  bottom = (MyScoreDoc)docQueue.replace(tmpScoreDoc);
                  valueDocMaps[j].put(rawGroupValue, tmpScoreDoc);
                  tmpScoreDoc = tmp;
                  if (rawGroupValueType[tmpScoreDoc.groupPos] == LONG_ARRAY_GROUP_VALUE_TYPE)
                  {
                    primitiveLongArrayWrapperTmp = (PrimitiveLongArrayWrapper)tmpScoreDoc.rawGroupValue;
                  }
                  else
                  {
                    primitiveLongArrayWrapperTmp = new PrimitiveLongArrayWrapper(null);
                  }
                }
                else
                {
                  MyScoreDoc tmp = new MyScoreDoc(tmpScoreDoc.doc, tmpScoreDoc.score, currentContext.base + totalDocs + tmpScoreDoc.doc, currentContext.reader);
                  tmp.groupPos = j;
                  tmp.rawGroupValue = rawGroupValue;
                  tmp.sortValue = tmpScoreDoc.sortValue;
                  bottom = (MyScoreDoc)docQueue.add(tmp);
                  valueDocMaps[j].put(rawGroupValue, tmp);
                  queueFull = (docQueue.size >= topHits);
                  if (rawGroupValueType[j] == LONG_ARRAY_GROUP_VALUE_TYPE)
                  {
                    primitiveLongArrayWrapperTmp = new PrimitiveLongArrayWrapper(null);
                  }
                }
              }
            }

            --contextLeft;
            if (contextLeft <= 0)
            {
              while (contextIter.hasNext())
              {
                currentContext = contextIter.next();
                currentContext.restoreRuntimeFacets();
                contextLeft = currentContext.length;
                if (contextLeft > 0)
                {
                  for (j=0; j<sortCollector.groupByMulti.length; ++j)
                    dataCaches[j] = (FacetDataCache)sortCollector.groupByMulti[j].getFacetData(currentContext.reader);
View Full Code Here

Examples of io.crate.operation.collect.files.CollectorContext

import static org.junit.Assert.assertNull;

public class LineContextTest {
    @Test
    public void testGet() throws Exception {
        LineContext context = new LineContext(new CollectorContext());

        String source = "{\"name\": \"foo\", \"details\": {\"age\": 43}}";
        context.rawSource(source.getBytes());

        assertNull(context.get(new ColumnIdent("invalid", "column")));
View Full Code Here

Examples of io.crate.operation.reference.doc.lucene.CollectorContext

        request.types(new String[]{Constants.DEFAULT_MAPPING_TYPE});

        SearchContext searchContext = mock(SearchContext.class);
        when(searchContext.mapperService()).thenReturn(mapperService);
        when(searchContext.fieldData()).thenReturn(ifd);
        ctx = new CollectorContext().searchContext(searchContext);
    }
View Full Code Here

Examples of io.crate.operation.reference.doc.lucene.CollectorContext

        private final CollectorContext context;
        private final Boolean nullFirst;

        public SortSymbolContext(SearchContext searchContext, boolean reverseFlag, Boolean nullFirst) {
            this.nullFirst = nullFirst;
            this.context = new CollectorContext();
            this.context.searchContext(searchContext);
            this.reverseFlag = reverseFlag;
        }
View Full Code Here

Examples of io.crate.operation.reference.doc.lucene.CollectorContext

    }

    @Override
    public void doCollect() throws Exception {
        // start collect
        CollectorContext collectorContext = new CollectorContext()
                .searchContext(searchContext)
                .visitor(fieldsVisitor);
        for (LuceneCollectorExpression<?> collectorExpression : collectorExpressions) {
            collectorExpression.startCollect(collectorContext);
        }
View Full Code Here

Examples of io.crate.operation.reference.doc.lucene.CollectorContext

            assert ctx.topLevelInputs().size() == 1;
            @SuppressWarnings("unchecked")
            final Input<Boolean> condition = (Input<Boolean>) ctx.topLevelInputs().get(0);
            @SuppressWarnings("unchecked")
            final List<LuceneCollectorExpression> expressions = ctx.docLevelExpressions();
            final CollectorContext collectorContext = new CollectorContext();
            collectorContext.searchContext(searchContext);
            collectorContext.visitor(new LuceneDocCollector.CollectorFieldsVisitor(expressions.size()));

            for (LuceneCollectorExpression expression : expressions) {
                expression.startCollect(collectorContext);
            }
            Filter filter = new Filter() {
                @Override
                public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException {
                    for (LuceneCollectorExpression expression : expressions) {
                        expression.setNextReader(context);
                    }
                    return BitsFilteredDocIdSet.wrap(
                            new FunctionDocSet(
                                    context.reader(),
                                    collectorContext.visitor(),
                                    condition,
                                    expressions,
                                    context.reader().maxDoc(),
                                    acceptDocs
                            ),
View Full Code Here

Examples of org.mmtk.plan.CollectorContext

   * <code>TRIGGER_REASONS - 1</code>.
   */
  public final void triggerCollection(int why) throws InterruptiblePragma {
      //System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Collection.triggerCollection() -2- has been called why = " + why);
      //VM.assertions._assert(false);
      CollectorContext cc = SelectedPlan.ap.collector();
      cc.collect();
  }
View Full Code Here

Examples of org.mmtk.plan.CollectorContext

          //System.out.println("slot_24 = " + Integer.toHexString(slot_24) );
          objSize = slot_24;
      }
      //System.out.println("ObjectModel.copy(), allocator = " + allocator);
      //VM.assertions._assert(allocator == 0);
      CollectorContext cc = SelectedPlan.ap.collector();
      Address addrTo = cc.allocCopy(from, objSize,
          0, /*int align,*/  0, /*int offset,*/ allocator) ;
      Address addrFrom = from.toAddress();
            //System.out.println("ObjectModel.copy(), objSize = " + objSize + " addrFrom = " +
                //Integer.toHexString(addrFrom.toInt()) + " addrTo = " + Integer.toHexString(addrTo.toInt()) );
      Address addrCursor = addrTo;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.