org.apache.lucene.codecs.lucene40.values
Class Bytes

java.lang.Object
  extended by org.apache.lucene.codecs.lucene40.values.Bytes

public final class Bytes
extends Object

Provides concrete Writer/Reader implementations for byte[] value per document. There are 6 package-private default implementations of this, for all combinations of Bytes.Mode.DEREF/Bytes.Mode.STRAIGHT x fixed-length/variable-length.

NOTE: Currently the total amount of byte[] data stored (across a single segment) cannot exceed 2GB.

NOTE: Each byte[] must be <= 32768 bytes in length

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

Nested Class Summary
static class Bytes.Mode
          Defines the Writers store mode.
 
Method Summary
static DocValues getValues(Directory dir, String id, Bytes.Mode mode, boolean fixedSize, int maxDoc, Comparator<BytesRef> sortComparator, IOContext context)
          Creates a new DocValues instance that provides either memory resident or iterative access to a per-document stored byte[] value.
static DocValuesConsumer getWriter(Directory dir, String id, Bytes.Mode mode, boolean fixedSize, Comparator<BytesRef> sortComparator, Counter bytesUsed, IOContext context, float acceptableOverheadRatio)
          Creates a new byte[] Writer instances for the given directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getWriter

public static DocValuesConsumer getWriter(Directory dir,
                                          String id,
                                          Bytes.Mode mode,
                                          boolean fixedSize,
                                          Comparator<BytesRef> sortComparator,
                                          Counter bytesUsed,
                                          IOContext context,
                                          float acceptableOverheadRatio)
Creates a new byte[] Writer instances for the given directory.

Parameters:
dir - the directory to write the values to
id - the id used to create a unique file name. Usually composed out of the segment name and a unique id per segment.
mode - the writers store mode
fixedSize - true if all bytes subsequently passed to the Writer will have the same length
sortComparator - BytesRef comparator used by sorted variants. If null BytesRef.getUTF8SortedAsUnicodeComparator() is used instead
bytesUsed - an AtomicLong instance to track the used bytes within the Writer. A call to DocValuesConsumer.finish(int) will release all internally used resources and frees the memory tracking reference.
acceptableOverheadRatio - how to trade space for speed. This option is only applicable for docvalues of type DocValues.Type.BYTES_FIXED_SORTED and DocValues.Type.BYTES_VAR_SORTED.
context - I/O Context
Returns:
a new Writer instance
See Also:
PackedInts.getReader(org.apache.lucene.store.DataInput)

getValues

public static DocValues getValues(Directory dir,
                                  String id,
                                  Bytes.Mode mode,
                                  boolean fixedSize,
                                  int maxDoc,
                                  Comparator<BytesRef> sortComparator,
                                  IOContext context)
                           throws IOException
Creates a new DocValues instance that provides either memory resident or iterative access to a per-document stored byte[] value. The returned DocValues instance will be initialized without consuming a significant amount of memory.

Parameters:
dir - the directory to load the DocValues from.
id - the file ID in the Directory to load the values from.
mode - the mode used to store the values
fixedSize - true iff the values are stored with fixed-size, otherwise false
maxDoc - the number of document values stored for the given ID
sortComparator - BytesRef comparator used by sorted variants. If null BytesRef.getUTF8SortedAsUnicodeComparator() is used instead
Returns:
an initialized DocValues instance.
Throws:
IOException - if an IOException occurs


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