Package com.browseengine.bobo.sort

Examples of com.browseengine.bobo.sort.DocComparator


    public DocComparator getComparator(final IndexReader reader, int docbase)
        throws IOException {
      if (!(reader instanceof BoboIndexReader))
        throw new IllegalStateException("reader must be instance of "+BoboIndexReader.class);
      final FacetDataCache dataCache = _facetHandler.getFacetData((BoboIndexReader)reader);
      return new DocComparator(){
        @Override
        public int compare(ScoreDoc doc1, ScoreDoc doc2) {
          int encoded1=dataCache.orderArray.get(doc1.doc);
          int encoded2=dataCache.orderArray.get(doc2.doc);
          return encoded1-encoded2;
View Full Code Here


    public DocComparator getComparator(final IndexReader reader, int docbase)
        throws IOException {
      if (!(reader instanceof BoboIndexReader)) throw new IllegalStateException("reader must be instance of "+BoboIndexReader.class);
      BoboIndexReader boboReader = (BoboIndexReader)reader;
      final MultiValueFacetDataCache dataCache = _facetHandler.getFacetData(boboReader);
      return new DocComparator(){
       
        @Override
        public int compare(ScoreDoc doc1, ScoreDoc doc2) {
          return dataCache._nestedArray.compare(doc1.doc, doc2.doc);
        }
View Full Code Here

        throws IOException {
      if (!(reader instanceof BoboIndexReader)) throw new IllegalStateException("reader not instance of "+BoboIndexReader.class);
      BoboIndexReader boboReader = (BoboIndexReader)reader;
      final FacetDataCache dataCache = _facetHandler.getFacetData(boboReader);
      final BigSegmentedArray orderArray = dataCache.orderArray;
      return new DocComparator() {
       
        @Override
        public Comparable value(ScoreDoc doc) {
          int index = orderArray.get(doc.doc);
              return dataCache.valArray.get(index);
View Full Code Here

      if (!(reader instanceof BoboSegmentReader)) throw new IllegalStateException(
          "reader not instance of " + BoboSegmentReader.class);
      BoboSegmentReader boboReader = (BoboSegmentReader) reader;
      final FacetDataCache<?> dataCache = _facetHandler.getFacetData(boboReader);
      final BigSegmentedArray orderArray = dataCache.orderArray;
      return new DocComparator() {
        @Override
        public Comparable<?> value(ScoreDoc doc) {
          int index = orderArray.get(doc.doc);
          return dataCache.valArray.getComparableValue(index);
        }
View Full Code Here

    public DocComparator getComparator(final AtomicReader reader, int docbase) throws IOException {
      if (!(reader instanceof BoboSegmentReader)) throw new IllegalStateException(
          "reader must be instance of " + BoboSegmentReader.class);
      BoboSegmentReader boboReader = (BoboSegmentReader) reader;
      final MultiValueFacetDataCache<?> dataCache = cacheBuilder.build(boboReader);
      return new DocComparator() {

        @Override
        public int compare(ScoreDoc doc1, ScoreDoc doc2) {
          return dataCache._nestedArray.compare(doc1.doc, doc2.doc);
        }
View Full Code Here

      if (!(reader instanceof BoboSegmentReader)) throw new IllegalStateException(
          "reader not instance of " + BoboSegmentReader.class);
      BoboSegmentReader boboReader = (BoboSegmentReader) reader;
      final FacetDataCache<?> dataCache = _facetHandler.getFacetData(boboReader);
      final BigSegmentedArray orderArray = dataCache.orderArray;
      return new DocComparator() {
        @Override
        public Comparable<?> value(ScoreDoc doc) {
          int index = orderArray.get(doc.doc);
          return dataCache.valArray.getComparableValue(index);
        }
View Full Code Here

          throws IOException {
        final UIDFacetHandler uidFacetHandler = UIDFacetHandler.this;
        if (reader instanceof BoboIndexReader){
          BoboIndexReader boboReader = (BoboIndexReader)reader;
          final long[] uidArray = uidFacetHandler.getFacetData(boboReader);
          return new DocComparator() {
           
            @Override
            public Comparable value(ScoreDoc doc) {
              int docid = doc.doc;
              return Long.valueOf(uidArray[docid]);
View Full Code Here

    return new DocComparatorSource() {
      @Override
      public DocComparator getComparator(IndexReader reader, int docbase)
          throws IOException {
        final int[] indexes = (int[]) ((BoboIndexReader) reader).getFacetData(_name);
        return new DocComparator() {
          @Override
          public Comparable<Integer> value(ScoreDoc doc) {          
              return indexes[doc.doc] != -1 ? intArray[indexes[doc.doc]] : 0;          
          }

          @Override
          public int compare(ScoreDoc doc1, ScoreDoc doc2) { 
            int val1 = indexes[doc1.doc] != -1 ? intArray[indexes[doc1.doc]] : 0;
            int val2 = indexes[doc2.doc] != -1 ? intArray[indexes[doc2.doc]] : 0;           
            return (val1<val2 ? -1 : (val1==val2 ? 0 : 1));
          }
        };
      }
    };
    if (longArray != null)
        return new DocComparatorSource() {
        @Override
        public DocComparator getComparator(IndexReader reader, int docbase)
            throws IOException {
          final int[] indexes = (int[]) ((BoboIndexReader) reader).getFacetData(_name);
          return new DocComparator() {
            @Override
            public Comparable<Long> value(ScoreDoc doc) {          
                return indexes[doc.doc] != -1 ? longArray[indexes[doc.doc]] : 0;          
            }

            @Override
            public int compare(ScoreDoc doc1, ScoreDoc doc2) { 
              long val1 = indexes[doc1.doc] != -1 ? longArray[indexes[doc1.doc]] : 0;
              long val2 = indexes[doc2.doc] != -1 ? longArray[indexes[doc2.doc]] : 0;           
              return (val1<val2 ? -1 : (val1==val2 ? 0 : 1));
            }
          };
        }
      };
    
      return new DocComparatorSource() {
      @Override
      public DocComparator getComparator(IndexReader reader, int docbase)
          throws IOException {
        final int[] indexes = (int[]) ((BoboIndexReader) reader).getFacetData(_name);
        return new DocComparator() {
          @Override
          public Comparable<Float> value(ScoreDoc doc) {          
              return indexes[doc.doc] != -1 ? floatArray[indexes[doc.doc]] : 0;          
          }
View Full Code Here

  public DocComparatorSource getDocComparatorSource() {
    DocComparatorSource docComparatorSource = SynchronizedActivityRangeFacetHandler.super.getDocComparatorSource();
    return new DocComparatorSource() {
      @Override
      public DocComparator getComparator(IndexReader reader, int docbase) throws IOException {
        final DocComparator comparator = SynchronizedActivityRangeFacetHandler.super.getDocComparatorSource()
            .getComparator(reader, docbase);
        return new DocComparator() {
          @Override
          public Comparable<Integer> value(ScoreDoc doc) {
            synchronized (GLOBAL_ACTIVITY_TEST_LOCK) {
              return comparator.value(doc);
            }
          }
          @Override
          public int compare(ScoreDoc doc1, ScoreDoc doc2) {
            synchronized (GLOBAL_ACTIVITY_TEST_LOCK) {
              return comparator.compare(doc1, doc2);
            }
          }
        };
      }
    };
View Full Code Here

    @Override
    public DocComparator getComparator(final AtomicReader reader, int docbase) throws IOException {
      if (!(reader instanceof BoboSegmentReader)) throw new IllegalStateException(
          "reader must be instance of " + BoboSegmentReader.class);
      final FacetDataCache<?> dataCache = _facetHandler.getFacetData((BoboSegmentReader) reader);
      return new DocComparator() {
        @Override
        public int compare(ScoreDoc doc1, ScoreDoc doc2) {
          int encoded1 = dataCache.orderArray.get(doc1.doc);
          int encoded2 = dataCache.orderArray.get(doc2.doc);
          return encoded1 - encoded2;
View Full Code Here

TOP

Related Classes of com.browseengine.bobo.sort.DocComparator

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.