Package com.browseengine.bobo.facets.data

Examples of com.browseengine.bobo.facets.data.PrimitiveLongArrayWrapper


      if (groupBy == null) {
        resList = ListMerger.mergeLists(_offset, _count, iterList, MERGE_COMPATATOR);
      } else {
        int rawGroupValueType = 0; // 0: unknown, 1: normal, 2: long[]

        PrimitiveLongArrayWrapper primitiveLongArrayWrapperTmp = new PrimitiveLongArrayWrapper(null);

        Object rawGroupValue = null;

        if (_facetAccessibleLists != null) {
          _groupAccessibles = new CombinedFacetAccessible[_facetAccessibleLists.length];
          for (int i = 0; i < _facetAccessibleLists.length; ++i)
            _groupAccessibles[i] = new CombinedFacetAccessible(new FacetSpec(),
                _facetAccessibleLists[i]);
        }
        resList = new ArrayList<MyScoreDoc>(_count);
        Iterator<MyScoreDoc> mergedIter = ListMerger.mergeLists(iterList, MERGE_COMPATATOR);
        Set<Object> groupSet = new HashSet<Object>(_offset + _count);
        int offsetLeft = _offset;
        while (mergedIter.hasNext()) {
          MyScoreDoc scoreDoc = mergedIter.next();
          Object[] vals = groupBy.getRawFieldValues(scoreDoc.reader, scoreDoc.doc);
          rawGroupValue = null;
          if (vals != null && vals.length > 0) rawGroupValue = vals[0];

          if (rawGroupValueType == 0) {
            if (rawGroupValue != null) {
              if (rawGroupValue instanceof long[]) rawGroupValueType = 2;
              else rawGroupValueType = 1;
            }
          }
          if (rawGroupValueType == 2) {
            primitiveLongArrayWrapperTmp.data = (long[]) rawGroupValue;
            rawGroupValue = primitiveLongArrayWrapperTmp;
          }

          if (!groupSet.contains(rawGroupValue)) {
            if (offsetLeft > 0) --offsetLeft;
            else {
              resList.add(scoreDoc);
              if (resList.size() >= _count) break;
            }
            groupSet.add(new PrimitiveLongArrayWrapper(primitiveLongArrayWrapperTmp.data));
          }
        }
      }
    } else resList = Collections.emptyList();
View Full Code Here


        resList = ListMerger.mergeLists(_offset, _count, iterList, MERGE_COMPATATOR);
      }
      else {
        int rawGroupValueType = 0// 0: unknown, 1: normal, 2: long[]

        PrimitiveLongArrayWrapper primitiveLongArrayWrapperTmp = new PrimitiveLongArrayWrapper(null);

        Object rawGroupValue = null;

        //if (_facetCountCollector != null)
        //{
          //collectTotalGroups();
          //_facetCountCollector = null;
        //}
        if (_facetAccessibleLists != null) {
          _groupAccessibles = new CombinedFacetAccessible[_facetAccessibleLists.length];
          for (int i=0; i<_facetAccessibleLists.length; ++i)
            _groupAccessibles[i] = new CombinedFacetAccessible(new FacetSpec(), _facetAccessibleLists[i]);
        }
        resList = new ArrayList<MyScoreDoc>(_count);
        Iterator<MyScoreDoc> mergedIter = ListMerger.mergeLists(iterList, MERGE_COMPATATOR);
        Set<Object> groupSet = new HashSet<Object>(_offset+_count);
        int offsetLeft = _offset;
        while(mergedIter.hasNext())
        {
          MyScoreDoc scoreDoc = mergedIter.next();
          Object[] vals = groupBy.getRawFieldValues(scoreDoc.reader, scoreDoc.doc);
          rawGroupValue = null;
          if (vals != null && vals.length > 0)
            rawGroupValue = vals[0];

          if (rawGroupValueType == 0) {
            if (rawGroupValue != null)
            {
              if (rawGroupValue instanceof long[])
                rawGroupValueType = 2;
              else
                rawGroupValueType = 1;
            }
          }
          if (rawGroupValueType == 2)
          {
            primitiveLongArrayWrapperTmp.data = (long[])rawGroupValue;
            rawGroupValue = primitiveLongArrayWrapperTmp;
          }

          if (!groupSet.contains(rawGroupValue))
          {
            if (offsetLeft > 0)
              --offsetLeft;
            else
            {
              resList.add(scoreDoc);
              if (resList.size() >= _count)
                break;
            }
            groupSet.add(new PrimitiveLongArrayWrapper(primitiveLongArrayWrapperTmp.data));
          }
        }
      }
    }
    else
View Full Code Here

        resList = ListMerger.mergeLists(_offset, _count, iterList, MERGE_COMPATATOR);
      }
      else {
        int rawGroupValueType = 0// 0: unknown, 1: normal, 2: long[]

        PrimitiveLongArrayWrapper primitiveLongArrayWrapperTmp = new PrimitiveLongArrayWrapper(null);

        Object rawGroupValue = null;

        if (_facetCountCollector != null)
        {
          collectTotalGroups();
          _facetCountCollector = null;
        }
        _groupAccessible = new CombinedFacetAccessible(new FacetSpec(), _facetAccessibles);
        resList = new ArrayList<MyScoreDoc>(_count);
        Iterator<MyScoreDoc> mergedIter = ListMerger.mergeLists(iterList, MERGE_COMPATATOR);
        Set<Object> groupSet = new HashSet<Object>(_offset+_count);
        int offsetLeft = _offset;
        while(mergedIter.hasNext())
        {
          MyScoreDoc scoreDoc = mergedIter.next();
          Object[] vals = groupBy.getRawFieldValues(scoreDoc.reader, scoreDoc.doc);
          rawGroupValue = null;
          if (vals != null && vals.length > 0)
            rawGroupValue = vals[0];

          if (rawGroupValueType == 0) {
            if (rawGroupValue != null)
            {
              if (rawGroupValue instanceof long[])
                rawGroupValueType = 2;
              else
                rawGroupValueType = 1;
            }
          }
          if (rawGroupValueType == 2)
          {
            primitiveLongArrayWrapperTmp.data = (long[])rawGroupValue;
            rawGroupValue = primitiveLongArrayWrapperTmp;
          }

          if (!groupSet.contains(rawGroupValue))
          {
            if (offsetLeft > 0)
              --offsetLeft;
            else
            {
              resList.add(scoreDoc);
              if (resList.size() >= _count)
                break;
            }
            groupSet.add(new PrimitiveLongArrayWrapper(primitiveLongArrayWrapperTmp.data));
          }
        }
      }
    }
    else
View Full Code Here

      if (groupBy == null) {
        resList = ListMerger.mergeLists(_offset, _count, iterList, MERGE_COMPATATOR);
      } else {
        int rawGroupValueType = 0; // 0: unknown, 1: normal, 2: long[]

        PrimitiveLongArrayWrapper primitiveLongArrayWrapperTmp = new PrimitiveLongArrayWrapper(null);

        Object rawGroupValue = null;

        if (_facetAccessibleLists != null) {
          _groupAccessibles = new CombinedFacetAccessible[_facetAccessibleLists.length];
          for (int i = 0; i < _facetAccessibleLists.length; ++i)
            _groupAccessibles[i] = new CombinedFacetAccessible(new FacetSpec(),
                _facetAccessibleLists[i]);
        }
        resList = new ArrayList<MyScoreDoc>(_count);
        Iterator<MyScoreDoc> mergedIter = ListMerger.mergeLists(iterList, MERGE_COMPATATOR);
        Set<Object> groupSet = new HashSet<Object>(_offset + _count);
        int offsetLeft = _offset;
        while (mergedIter.hasNext()) {
          MyScoreDoc scoreDoc = mergedIter.next();
          Object[] vals = groupBy.getRawFieldValues(scoreDoc.reader, scoreDoc.doc);
          rawGroupValue = null;
          if (vals != null && vals.length > 0) rawGroupValue = vals[0];

          if (rawGroupValueType == 0) {
            if (rawGroupValue != null) {
              if (rawGroupValue instanceof long[]) rawGroupValueType = 2;
              else rawGroupValueType = 1;
            }
          }
          if (rawGroupValueType == 2) {
            primitiveLongArrayWrapperTmp.data = (long[]) rawGroupValue;
            rawGroupValue = primitiveLongArrayWrapperTmp;
          }

          if (!groupSet.contains(rawGroupValue)) {
            if (offsetLeft > 0) --offsetLeft;
            else {
              resList.add(scoreDoc);
              if (resList.size() >= _count) break;
            }
            groupSet.add(new PrimitiveLongArrayWrapper(primitiveLongArrayWrapperTmp.data));
          }
        }
      }
    } else resList = Collections.emptyList();
View Full Code Here

      this.hasSortCollector = hasSortCollector;
      this.hits = hits;
      this.rawGroupValueType = rawGroupValueType;
      this.primitiveLongArrayWrapperTmp = primitiveLongArrayWrapperTmp;
      this.distinctValueType = new int[distinctLength];
      this.distinctPrimitiveLongArrayWrapperTmp = new PrimitiveLongArrayWrapper(null);

      groupMaps = new Map[req.getGroupBy().length];
      for (int i=0; i< groupMaps.length; ++i)
      {
        groupMaps[i] = new HashMap<Object, HitWithGroupQueue>(hits.length*2);
 
View Full Code Here

        rawGroupValue = extractRawGroupValue(rawGroupValueType, hit.getGroupPosition(),
            primitiveLongArrayWrapperTmp, rawGroupValue);

        if (rawGroupValueType[hit.getGroupPosition()] == LONG_ARRAY_GROUP_VALUE_TYPE)
        {
          groupMaps[hit.getGroupPosition()].put(new PrimitiveLongArrayWrapper(primitiveLongArrayWrapperTmp.data),
              new HitWithGroupQueue(hit,
                  maxPerGroup,
                  distinctLength));
        }
        else
View Full Code Here

    }
    else
    {
      int[] rawGroupValueType = new int[req.getGroupBy().length]// 0: unknown, 1: normal, 2: long[]

      PrimitiveLongArrayWrapper primitiveLongArrayWrapperTmp = new PrimitiveLongArrayWrapper(null);

      Iterator<SenseiHit> mergedIter = ListMerger.mergeLists(hitLists, comparator);

      List<SenseiHit> hitsList = null;
      if (!hasSortCollector)
      {
        hitsList = buildHitsListNoSortCollector(req, topHits, rawGroupValueType, mergedIter, req.getOffset());
        //numGroups = (int)(numGroups*(groupHitMap.size()/(float)preGroups));
      }
      else
      {
        int offsetLeft = req.getOffset();

        MyScoreDoc pre = null;

        if (topHits > 0 && groupAccessibles != null && groupAccessibles.length != 0)
        {
          hitsList = buildHitsList(req, results, topHits, groupAccessibles, rawGroupValueType, primitiveLongArrayWrapperTmp);
        }
        else
        {
          hitsList = buildHitsListNoGroupAccessibles(req, topHits, rawGroupValueType, primitiveLongArrayWrapperTmp, mergedIter, offsetLeft);
        }
        //for (int i=0; i<combinedFacetAccessibles.length; ++i) combinedFacetAccessibles[i].close();
      }
      hits = hitsList.toArray(new SenseiHit[hitsList.size()]);

      primitiveLongArrayWrapperTmp = new PrimitiveLongArrayWrapper(null);

      PrepareGroupMappings prepareGroupMappings = new PrepareGroupMappings(req, results, hasSortCollector, hits, rawGroupValueType, primitiveLongArrayWrapperTmp).invoke();
      Map<Object, HitWithGroupQueue>[] groupMaps = prepareGroupMappings.getGroupMaps();
      totalDocs = prepareGroupMappings.getTotalDocs();

      if (hasSortCollector)
      {
        // Fix group position
        for (SenseiHit hit : hits)
        {
          if (hit.getGroupHitsCount() <= 1)
          {
            hit.setGroupPosition(0);
            hit.setGroupField(req.getGroupBy()[0]);
            hit.setGroupValue(hit.getField(req.getGroupBy()[0]));
            hit.setRawGroupValue(hit.getRawField(req.getGroupBy()[0]));
          }
        }

        for (Map<Object, HitWithGroupQueue> map : groupMaps)
        {
          for (HitWithGroupQueue hwg : map.values())
          {
            if (hwg.queue == null) continue;
            int index = hwg.queue.size - 1;
            if (index >= 0)
            {
              SenseiHit[] groupHits = new SenseiHit[index+1];
              while (index >=0)
              {
                groupHits[index] = ((MyScoreDoc)hwg.queue.pop()).getSenseiHit(req);
                --index;
              }
              hwg.hit.setGroupHits(groupHits);
            }
          }
        }
      }
      else
      {
        Set<Object>[] distinctSets = null;
        Object[] distinctValues = null;
        int[] distinctValueType = null;
        if (req.getDistinct() != null && req.getDistinct().length != 0)
        {
          distinctSets = new Set[req.getDistinct().length];
          for (int i = 0; i < distinctSets.length; ++i)
          {
            distinctSets[i] = new HashSet<Object>(req.getMaxPerGroup());
          }
          distinctValues = new Object[distinctSets.length];
          distinctValueType = new int[distinctSets.length];
          primitiveLongArrayWrapperTmp = new PrimitiveLongArrayWrapper(null);
        }
        for (Map<Object, HitWithGroupQueue> map : groupMaps)
        {
          for (HitWithGroupQueue hwg : map.values())
          {
View Full Code Here

      if (distinctSets[i].contains(distinctValues[i])) return true;
    }
    for (int i = 0; i < distinctValues.length; ++i)
    {
      if (distinctValueType[i] == LONG_ARRAY_GROUP_VALUE_TYPE)
        distinctSets[i].add(new PrimitiveLongArrayWrapper(((PrimitiveLongArrayWrapper)distinctValues[i]).data));
      else
        distinctSets[i].add(distinctValues[i]);
    }
    return false;
  }
View Full Code Here

          hitsList.add(hit);
          if (hitsList.size() >= req.getCount())
            break;
        }
        if (rawGroupValueType[i] == LONG_ARRAY_GROUP_VALUE_TYPE)
          groupSets[i].add(new PrimitiveLongArrayWrapper(primitiveLongArrayWrapperTmp.data));
        else
          groupSets[i].add(rawGroupValue);
      }
    }
View Full Code Here

                  {
                    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);
                  }
                }
              }
            }
View Full Code Here

TOP

Related Classes of com.browseengine.bobo.facets.data.PrimitiveLongArrayWrapper

Copyright © 2018 www.massapicom. 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.