org.apache.lucene.codecs
Class PerDocProducerBase

java.lang.Object
  extended by org.apache.lucene.codecs.PerDocProducer
      extended by org.apache.lucene.codecs.PerDocProducerBase
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
Lucene40DocValuesProducer

public abstract class PerDocProducerBase
extends PerDocProducer

Abstract base class for PerDocProducer implementations

WARNING: This API is experimental and might change in incompatible ways in the next release.

Constructor Summary
protected PerDocProducerBase()
          Sole constructor.
 
Method Summary
protected  boolean anyDocValuesFields(FieldInfos infos)
          Returns true if any fields indexed doc values.
protected  boolean canLoad(FieldInfo info)
          Returns true if this field indexed doc values.
 void close()
           
protected abstract  void closeInternal(Collection<? extends Closeable> closeables)
          Closes provided Closables.
protected abstract  Map<String,DocValues> docValues()
          Returns a map, mapping field names to doc values.
 DocValues docValues(String field)
          Returns DocValues for the current field.
static String docValuesId(String segmentsName, int fieldId)
          Returns the unique segment and field id for any per-field files this implementation needs to write.
 Comparator<BytesRef> getComparator()
          Returns the comparator used to sort BytesRef values.
protected  DocValues.Type getDocValuesType(FieldInfo info)
          Returns the doc values type for this field.
protected  TreeMap<String,DocValues> load(FieldInfos fieldInfos, String segment, int docCount, Directory dir, IOContext context)
          Only opens files...
protected abstract  DocValues loadDocValues(int docCount, Directory dir, String id, DocValues.Type type, IOContext context)
          Loads a DocValues instance depending on the given DocValues.Type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerDocProducerBase

protected PerDocProducerBase()
Sole constructor. (For invocation by subclass constructors, typically implicit.)

Method Detail

closeInternal

protected abstract void closeInternal(Collection<? extends Closeable> closeables)
                               throws IOException
Closes provided Closables.

Throws:
IOException

docValues

protected abstract Map<String,DocValues> docValues()
Returns a map, mapping field names to doc values.


close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class PerDocProducer
Throws:
IOException

docValues

public DocValues docValues(String field)
                    throws IOException
Description copied from class: PerDocProducer
Returns DocValues for the current field.

Specified by:
docValues in class PerDocProducer
Parameters:
field - the field name
Returns:
the DocValues for this field or null if not applicable.
Throws:
IOException - If an I/O error occurs

getComparator

public Comparator<BytesRef> getComparator()
                                   throws IOException
Returns the comparator used to sort BytesRef values.

Throws:
IOException

load

protected TreeMap<String,DocValues> load(FieldInfos fieldInfos,
                                         String segment,
                                         int docCount,
                                         Directory dir,
                                         IOContext context)
                                  throws IOException
Only opens files... doesn't actually load any values.

Throws:
IOException

canLoad

protected boolean canLoad(FieldInfo info)
Returns true if this field indexed doc values.


getDocValuesType

protected DocValues.Type getDocValuesType(FieldInfo info)
Returns the doc values type for this field.


anyDocValuesFields

protected boolean anyDocValuesFields(FieldInfos infos)
Returns true if any fields indexed doc values.


docValuesId

public static String docValuesId(String segmentsName,
                                 int fieldId)
Returns the unique segment and field id for any per-field files this implementation needs to write.


loadDocValues

protected abstract DocValues loadDocValues(int docCount,
                                           Directory dir,
                                           String id,
                                           DocValues.Type type,
                                           IOContext context)
                                    throws IOException
Loads a DocValues instance depending on the given DocValues.Type. Codecs that use different implementations for a certain DocValues.Type can simply override this method and return their custom implementations.

Parameters:
docCount - number of documents in the segment
dir - the Directory to load the DocValues from
id - the unique file ID within the segment
type - the type to load
Returns:
a DocValues instance for the given type
Throws:
IOException - if an IOException occurs
IllegalArgumentException - if the given DocValues.Type is not supported


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