public class GenericIndexed<T> extends Object implements Indexed<T>, Serializer
V1 Storage Format:
byte 1: version (0x1) byte 2 == 0x1 =>; allowReverseLookup bytes 3-6 =>; numBytesUsed bytes 7-10 =>; numElements bytes 10-((numElements * 4) + 10): integers representing *end* offsets of byte serialized values bytes ((numElements * 4) + 10)-(numBytesUsed + 2): 4-byte integer representing length of value, followed by bytes for value
V2 Storage Format Meta, header and value files are separate and header file stored in native endian byte order. Meta File: byte 1: version (0x2) byte 2 == 0x1 =>; allowReverseLookup bytes 3-6: numberOfElementsPerValueFile expressed as power of 2. That means all the value files contains same number of items except last value file and may have fewer elements. bytes 7-10 =>; numElements bytes 11-14 =>; columnNameLength bytes 15-columnNameLength =>; columnName
Header file name is identified as: StringUtils.format("%s_header", columnName) value files are identified as: StringUtils.format("%s_value_%d", columnName, fileNumber) number of value files == numElements/numberOfElementsPerValueFile
Modifier and Type | Field and Description |
---|---|
static ObjectStrategy<String> |
STRING_STRATEGY |
Modifier and Type | Method and Description |
---|---|
static <T> GenericIndexed<T> |
fromArray(T[] objects,
ObjectStrategy<T> strategy) |
static <T> GenericIndexed<T> |
fromIterable(Iterable<T> objectsIterable,
ObjectStrategy<T> strategy) |
T |
get(int index) |
Class<? extends T> |
getClazz() |
long |
getSerializedSize()
Returns the number of bytes, that this Serializer will write to the output _channel_ (not smoosher) on a
Serializer.writeTo(java.nio.channels.WritableByteChannel, io.druid.java.util.common.io.smoosh.FileSmoosher) call. |
int |
indexOf(T value)
Returns the index of "value" in this GenericIndexed object, or (-(insertion point) - 1) if the value is not
present, in the manner of Arrays.binarySearch.
|
void |
inspectRuntimeShape(RuntimeShapeInspector inspector)
Implementations of this method should call
inspector.visit() with all fields of this class, which meet two
conditions:
1. |
Iterator<T> |
iterator() |
static <T> GenericIndexed<T> |
read(ByteBuffer buffer,
ObjectStrategy<T> strategy) |
static <T> GenericIndexed<T> |
read(ByteBuffer buffer,
ObjectStrategy<T> strategy,
SmooshedFileMapper fileMapper) |
io.druid.segment.data.GenericIndexed.BufferIndexed |
singleThreaded()
Create a non-thread-safe Indexed, which may perform better than the underlying Indexed.
|
int |
size() |
void |
writeTo(WritableByteChannel channel,
FileSmoosher smoosher)
Writes serialized form of this object to the given channel.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public static final ObjectStrategy<String> STRING_STRATEGY
public static <T> GenericIndexed<T> read(ByteBuffer buffer, ObjectStrategy<T> strategy)
public static <T> GenericIndexed<T> read(ByteBuffer buffer, ObjectStrategy<T> strategy, SmooshedFileMapper fileMapper)
public static <T> GenericIndexed<T> fromArray(T[] objects, ObjectStrategy<T> strategy)
public static <T> GenericIndexed<T> fromIterable(Iterable<T> objectsIterable, ObjectStrategy<T> strategy)
public int indexOf(T value)
public long getSerializedSize()
Serializer
Serializer.writeTo(java.nio.channels.WritableByteChannel, io.druid.java.util.common.io.smoosh.FileSmoosher)
call.getSerializedSize
in interface Serializer
public void writeTo(WritableByteChannel channel, FileSmoosher smoosher) throws IOException
Serializer
writeTo
in interface Serializer
IOException
public io.druid.segment.data.GenericIndexed.BufferIndexed singleThreaded()
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
HotLoopCallee
inspector.visit()
with all fields of this class, which meet two
conditions:
1. They are used in methods of this class, annotated with CalledFromHotLoop
2. They are either:
a. Nullable objects
b. Instances of HotLoopCallee
c. Objects, which don't always have a specific class in runtime. For example, a field of type Set
could be HashSet
or TreeSet
in runtime, depending on how
this instance (the instance on which inspectRuntimeShape() is called) is configured.
d. ByteBuffer or similar objects, where byte order matters
e. boolean flags, affecting branch taking
f. Arrays of objects, meeting any of conditions a-e.inspectRuntimeShape
in interface HotLoopCallee
Copyright © 2011–2018. All rights reserved.