Interface PqList
Type-safe list interface for reading Parquet list values.
Provides type-specific accessor methods for iterating over list elements.
Primitive int/long/double element lists surface as the dedicated
PqIntList / PqLongList / PqDoubleList types (with PrimitiveIterator.OfInt
and friends — no boxing). All other typed accessors return List.
A PqList is a flyweight over the underlying read batch — its get(int) and
the lazy List views returned by the typed accessors resolve to column data
on each call. The flyweight is valid for as long as the batch it was obtained
from is current; it is not safe to hold across rowReader.next() calls.
// String list
PqList tags = rowReader.getList("tags");
for (String tag : tags.strings()) {
System.out.println(tag);
}
// Nested struct list
PqList items = rowReader.getList("items");
for (PqStruct item : items.structs()) {
String name = item.getString("name");
}
// Primitive int list — no boxing
PqList scores = rowReader.getList("scores");
PqIntList ints = scores.ints();
for (var it = ints.iterator(); it.hasNext(); ) {
int v = it.nextInt();
}
// Nested list (2D matrix)
PqList matrix = rowReader.getList("matrix");
for (PqList row : matrix.lists()) {
PqIntList ints = row.ints();
for (var it = ints.iterator(); it.hasNext(); ) {
int value = it.nextInt();
}
}
// Triple nested list (3D cube)
PqList cube = rowReader.getList("cube");
for (PqList plane : cube.lists()) {
for (PqList row : plane.lists()) {
PqIntList ints = row.ints();
// ...
}
}
-
Method Summary
Modifier and TypeMethodDescriptionList<byte[]> binaries()View the elements as aListof binary (byte[]) values.booleans()View the elements as aListof boolean values.dates()decimals()View the elements as aListofBigDecimalvalues.doubles()View the elements as aPqDoubleList(no boxing).floats()View the elements as aListof float values.get(int index) Get an element by index, decoded to its logical-type representation.getRaw(int index) Get an element by index in its underlying physical form, mirroring thegetRawValueaccessors onRowReader/PqStruct/PqMap.Entry.View the elements as aListofPqIntervalvalues.ints()View the elements as aPqIntList(no boxing).booleanisEmpty()Check if this list is empty.booleanisNull(int index) Check if an element is null by index.lists()View the elements as aListof nested lists.longs()View the elements as aPqLongList(no boxing).maps()View the elements as aListof nested maps.View the elements as aListin their underlying physical form, as ingetRaw(int).intsize()Get the number of elements in this list.strings()View the elements as aListof String values.structs()View the elements as aListof nested structs.times()uuids()values()View the elements as aList, each decoded to its logical-type representation.variants()
-
Method Details
-
size
int size()Get the number of elements in this list.- Returns:
- the element count
-
isEmpty
boolean isEmpty()Check if this list is empty.- Returns:
- true if the list has no elements
-
get
Get an element by index, decoded to its logical-type representation.
Returns the value in the same form as the typed accessors below:
Integer/Long/Float/Double/Booleanfor primitives,Stringfor STRING,LocalDatefor DATE,LocalTimefor TIME,Instantfor TIMESTAMP,BigDecimalfor DECIMAL,UUIDfor UUID,PqIntervalfor INTERVAL, andbyte[]for BYTE_ARRAY / FIXED_LEN_BYTE_ARRAY with no logical-type annotation. Nested groups surface asPqStruct/PqList/PqMap.- Parameters:
index- the element index (0-based)- Returns:
- the decoded element value, or null if the element is null
- Throws:
IndexOutOfBoundsException- if index is out of range
-
isNull
boolean isNull(int index) Check if an element is null by index.- Parameters:
index- the element index (0-based)- Returns:
- true if the element is null
-
values
View the elements as a
List, each decoded to its logical-type representation.Element types match
get(int):Integer/String/LocalDate/Instant/BigDecimal/UUID/PqInterval/ etc., withbyte[]for un-annotated BYTE_ARRAY / FIXED_LEN_BYTE_ARRAY columns andPqStruct/PqList/PqMapfor nested groups. The returned list is a live view: eachget(int)decodes lazily on demand. -
getRaw
Get an element by index in its underlying physical form, mirroring the
getRawValueaccessors onRowReader/PqStruct/PqMap.Entry.Returns
Integer/Long/Float/Double/Boolean/byte[]for the physical storage type —Longmicros instead ofInstantfor TIMESTAMP(MICROS), unscaledbyte[]instead ofBigDecimalfor DECIMAL,byte[]instead ofStringfor STRING / JSON, etc. Nested groups have no distinct raw form and surface as the samePqStruct/PqList/PqMapflyweight returned byget(int).- Parameters:
index- the element index (0-based)- Returns:
- the raw element value, or null if the element is null
- Throws:
IndexOutOfBoundsException- if index is out of range
-
rawValues
View the elements as aListin their underlying physical form, as ingetRaw(int). -
ints
-
longs
PqLongList longs()View the elements as aPqLongList(no boxing). -
floats
-
doubles
PqDoubleList doubles()View the elements as aPqDoubleList(no boxing). -
booleans
-
strings
-
binaries
-
dates
-
times
-
timestamps
-
decimals
List<BigDecimal> decimals()View the elements as aListofBigDecimalvalues. -
uuids
-
intervals
List<PqInterval> intervals()View the elements as aListofPqIntervalvalues. -
structs
-
lists
-
maps
-
variants
View the elements as a
ListofPqVariantvalues.Only unshredded variants are supported in repeated contexts today; iterating a list of shredded variants throws
UnsupportedOperationExceptionon first access.
-