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 batch of rows it was read from: its get(int) and
the lazy List views returned by the typed accessors read the column data on each
call. The list and its views can be held after the reader moves on and keep reading
their own row; while one is reachable, the values of every projected column in that
batch stay in memory. To keep a few lists of many rows, copy their elements out
instead.
// 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).files()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.View the elements as aListofLocalDateTime(local-wall-clock timestamp) values.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, decoded from UTF-8.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 / ENUM / JSON,LocalDatefor DATE,LocalTimefor TIME,Instantfor TIMESTAMP,BigDecimalfor DECIMAL,UUIDfor UUID,PqIntervalfor INTERVAL,PqFilefor FILE, 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 / ENUM / JSON, etc. Nested groups have no distinct raw form and surface as the samePqStruct/PqList/PqMapflyweight returned byget(int); a FILE element surfaces as thePqStructof its children.- 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
View the elements as aListof String values, decoded from UTF-8.- Throws:
IllegalArgumentException- if the element does not hold text, asFieldAccessor.getString(String)describes
-
binaries
-
dates
-
times
-
timestamps
View the elements as aListofInstant(timestamp) values. The element column must be a UTC-adjusted TIMESTAMP. For local-wall-clock element columns uselocalTimestamps().- Throws:
IllegalStateException- if the element column is a local-wall-clock TIMESTAMP
-
localTimestamps
List<LocalDateTime> localTimestamps()View the elements as aListofLocalDateTime(local-wall-clock timestamp) values. The element column must be a local-wall-clock TIMESTAMP (isAdjustedToUTC = false). For UTC-adjusted element columns usetimestamps().- Throws:
IllegalStateException- if the element column is a UTC-adjusted TIMESTAMP
-
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. -
files
View the elements as aListofPqFilereferences, for a list whose element is a group annotatedFILE. Reading an element that is not a valid reference throwsParquetReadException, asStructAccessor.getFile(String)does.
-