public abstract class AbstractFixedWidthWriter extends BaseScalarWriter
Fixed-width writers provide default values for empty (unused) slots. Suppose a client writes to slot 0, skips a few rows, then writes to slot 5. We could leave the intermediate values unwritten. But, since Drill reuses buffers, the slots may contain garbage. Instead, we implement "fill empties" logic. When we write to slot 5, we notice that the last slot written was 0, and we fill in slots 1, 2, 3 and 4 with values.
The fill value defaults to 0, and is defined as a block of zero-bytes (at least) the same length as each data value. Derived classes also allow setting a default value. In this case, the default value is encoded into a byte array, and that array is copied to each slot as the fill value.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractFixedWidthWriter.BaseFixedWidthWriter |
static class |
AbstractFixedWidthWriter.BaseIntWriter
Base class for writers that use the Java int type as their native
type.
|
AbstractScalarWriterImpl.ScalarObjectWriter
WriterEvents.ColumnWriterListener, WriterEvents.State
Modifier and Type | Field and Description |
---|---|
protected int |
lastWriteIndex
The largest position to which the writer has written data.
|
capacity, drillBuf, emptyValue, listener, MIN_BUFFER_SIZE
schema, vectorIndex
Constructor and Description |
---|
AbstractFixedWidthWriter() |
Modifier and Type | Method and Description |
---|---|
void |
dump(HierarchicalFormatter format) |
void |
endWrite()
End a batch: finalize any vector values.
|
protected abstract void |
fillEmpties(int writeIndex) |
int |
lastWriteIndex()
Return the last write position in the vector.
|
protected void |
mandatoryResize(int writeIndex) |
void |
postRollover()
The vectors backing this writer rolled over.
|
void |
preRollover()
The vectors backing this vector are about to roll over.
|
protected int |
resize(int writeIndex) |
void |
restartRow()
During a writer to a row, rewind the the current index position to
restart the row.
|
protected void |
setBuffer()
All change of buffer comes through this function to allow capturing
the buffer address and capacity.
|
void |
setLastWriteIndex(int index)
For internal use only to update the write position on those
very rare occasions in which the vector is written to outside
of this writer framework.
|
void |
setValueCount(int valueCount) |
void |
skipNulls() |
void |
startWrite()
Start a write (batch) operation.
|
abstract int |
width() |
appendBytes, bindListener, bindSchema, canExpand, nullable, overflowed, realloc, setBoolean, setBytes, setDate, setDecimal, setDouble, setFloat, setInt, setLong, setNull, setPeriod, setString, setTime, setTimestamp
bindIndex, endArrayValue, isProjected, rowStartIndex, saveRow, schema, startRow, type, vector, writeIndex
conversionError, extendedType, setObject, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
setDefaultValue, valueType
copy
setValue
protected int lastWriteIndex
public void startWrite()
WriterEvents
startWrite
in interface WriterEvents
startWrite
in class AbstractScalarWriterImpl
public abstract int width()
protected final void setBuffer()
BaseScalarWriter
setBuffer
in class BaseScalarWriter
protected final void mandatoryResize(int writeIndex)
protected final int resize(int writeIndex)
public int lastWriteIndex()
WriterPosition
public void setLastWriteIndex(int index)
index
- new last write indexpublic void skipNulls()
skipNulls
in class BaseScalarWriter
public void restartRow()
WriterEvents
public void preRollover()
WriterEvents
public void postRollover()
WriterEvents
public void endWrite()
WriterEvents
protected abstract void fillEmpties(int writeIndex)
public void setValueCount(int valueCount)
public void dump(HierarchicalFormatter format)
dump
in interface WriterEvents
dump
in class BaseScalarWriter
Copyright © 1970 The Apache Software Foundation. All rights reserved.