Interface Validity
Per-item null bitmap at a ColumnReader scope (a STRUCT /
REPEATED layer or the leaf).
A Validity is one of two shapes:
- No nulls — every item at that scope is non-null in the current
batch. The
NO_NULLSsingleton, returned for the no-nulls fast path; no per-batch allocation. - Backed — a packed
long[]bitmap with set-bit = present polarity: bitiis set iff itemiis present (non-null). Wordwcovers items[w*64, w*64+64), low bit = lowest item.
Consumer-side predicates (isNull(i) / isNotNull(i) / hasNulls())
describe nullability; the storage uses set-bit = present internally
to match Arrow's layout. hasNulls() makes the no-nulls fast path
explicit:
if (!validity.hasNulls()) {
// tight loop, skip per-item check
} else {
// checked loop
}
This API is Experimental: the shape may change in future releases.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasNulls()trueiff at least one item at this scope is null in the current batch.booleanisNotNull(int i) trueiff the item at indexiis not null.booleanisNull(int i) trueiff the item at indexiis null.intnextNotNull(int from, int count) Index of the next non-null item in[from, count), or-1if every item in that range is null.intnextNull(int from, int count) Index of the next null item in[from, count), or-1if every item in that range is non-null.intnullCount(int count) Number of null items in this batch.static Validityof(long[] words) Wraps a packedlong[]bitmap (set-bit = present storage).long[]words()The word array (set-bit = present polarity).
-
Field Details
-
NO_NULLS
Singleton signalling "no item at this scope is null in the current batch." Identity-stable across calls.
-
-
Method Details
-
of
Wraps a packed
long[]bitmap (set-bit = present storage). ReturnsNO_NULLSwhenwordsisnull(the sparse "no nulls" representation produced by the internal pipeline); otherwise returns a fresh backed instance holding the given bitmap. The wrapper does not copy — callers must not mutate the bitmap after handing it to aValidity.The caller is responsible for sizing the array to at least
(count + 63) >>> 6words for anycountthey later pass tonullCount(int)/nextNull(int, int)/nextNotNull(int, int), and for keeping indices intoisNull(int)/isNotNull(int)within the same bound. -
hasNulls
boolean hasNulls()trueiff at least one item at this scope is null in the current batch. O(1). May help on hot loops as a per-batch fast-path gate:if (!validity.hasNulls()) { // tight loop, no per-item check } else { // checked loop } -
isNull
boolean isNull(int i) trueiff the item at indexiis null. -
isNotNull
boolean isNotNull(int i) trueiff the item at indexiis not null. -
nullCount
int nullCount(int count) Number of null items in this batch.countis the total item count at this scope — required because the no-nulls shape has no intrinsic length. -
nextNull
int nextNull(int from, int count) Index of the next null item in[from, count), or-1if every item in that range is non-null. -
nextNotNull
int nextNotNull(int from, int count) Index of the next non-null item in[from, count), or-1if every item in that range is null.countis the total item count at this scope — required because the no-nulls shape has no intrinsic length. -
words
long[] words()The word array (set-bit = present polarity). Returnsnullwhen there are no nulls. Otherwise returns the backing array directly — no copy. Callers must not mutate it; mirroring the inbound contract on [#of(long[])], theValidityowns the bitmap once handed in. Bits at indices>= countare undefined and must not be read.
-