org.apache.lucene.index
Class DocValues.SortedSource

java.lang.Object
  extended by org.apache.lucene.index.DocValues.Source
      extended by org.apache.lucene.index.DocValues.SortedSource
Enclosing class:
DocValues

public abstract static class DocValues.SortedSource
extends DocValues.Source

A sorted variant of DocValues.Source for byte[] values per document.


Field Summary
 
Fields inherited from class org.apache.lucene.index.DocValues.Source
type
 
Constructor Summary
protected DocValues.SortedSource(DocValues.Type type, Comparator<BytesRef> comparator)
          Sole constructor.
 
Method Summary
 DocValues.SortedSource asSortedSource()
          If this DocValues.Source is sorted this method will return an instance of DocValues.SortedSource otherwise UOE
abstract  BytesRef getByOrd(int ord, BytesRef result)
          Returns value for specified ord.
 BytesRef getBytes(int docID, BytesRef bytesRef)
          Returns a BytesRef for the given document id or throws an UnsupportedOperationException if this source doesn't support byte[] values.
 Comparator<BytesRef> getComparator()
          Returns the comparator used to order the BytesRefs.
abstract  PackedInts.Reader getDocToOrd()
          Returns the PackedInts.Reader impl that maps document to ord.
 int getOrdByValue(BytesRef value, BytesRef spare)
          Lookup ord by value.
abstract  int getValueCount()
          Returns the number of unique values in this sorted source
 boolean hasPackedDocToOrd()
          Return true if it's safe to call getDocToOrd().
abstract  int ord(int docID)
          Returns ord for specified docID.
 
Methods inherited from class org.apache.lucene.index.DocValues.Source
getArray, getFloat, getInt, getType, hasArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocValues.SortedSource

protected DocValues.SortedSource(DocValues.Type type,
                                 Comparator<BytesRef> comparator)
Sole constructor. (For invocation by subclass constructors, typically implicit.)

Method Detail

getBytes

public BytesRef getBytes(int docID,
                         BytesRef bytesRef)
Description copied from class: DocValues.Source
Returns a BytesRef for the given document id or throws an UnsupportedOperationException if this source doesn't support byte[] values.

Overrides:
getBytes in class DocValues.Source

ord

public abstract int ord(int docID)
Returns ord for specified docID. Ord is dense, ie, starts at 0, then increments by 1 for the next (as defined by Comparator value.


getByOrd

public abstract BytesRef getByOrd(int ord,
                                  BytesRef result)
Returns value for specified ord.


hasPackedDocToOrd

public boolean hasPackedDocToOrd()
Return true if it's safe to call getDocToOrd().


getDocToOrd

public abstract PackedInts.Reader getDocToOrd()
Returns the PackedInts.Reader impl that maps document to ord.


getComparator

public Comparator<BytesRef> getComparator()
Returns the comparator used to order the BytesRefs.


getOrdByValue

public int getOrdByValue(BytesRef value,
                         BytesRef spare)
Lookup ord by value.

Parameters:
value - the value to look up
spare - a spare BytesRef instance used to compare internal values to the given value. Must not be null
Returns:
the given values ordinal if found or otherwise (-(ord)-1), defined as the ordinal of the first element that is greater than the given value (the insertion point). This guarantees that the return value will always be >= 0 if the given value is found.

asSortedSource

public DocValues.SortedSource asSortedSource()
Description copied from class: DocValues.Source
If this DocValues.Source is sorted this method will return an instance of DocValues.SortedSource otherwise UOE

Overrides:
asSortedSource in class DocValues.Source

getValueCount

public abstract int getValueCount()
Returns the number of unique values in this sorted source



Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.