Interface PqFile
Value of a Parquet column annotated with the FILE logical type: a reference to a range of
bytes, stored inline in the value or in an external object named by a URI.
The factories build only references the format defines:
| Factory | Refers to |
|---|---|
inline(byte[]) |
the given bytes |
external(String) |
the whole object at uri |
external(String, long) |
bytes [0, size) of the object at uri |
external(String, long, long) |
bytes [offset, offset + size) of the object at uri |
withInline(byte[]), withContentType(String) and withChecksum(String) return a copy with one more field set.
PqFile photo = PqFile.external("s3://bucket/bundle.tar", 4096, 51200)
.withContentType("image/png");
A FILE value is not resolved: fetching the object at uri() and verifying checksum()
are left to the caller.
The values the factories and the reader return are immutable: the factories copy the arrays
they are given, and inline() returns a copy on each call. Two such values are equal when
their accessors return equal values, the inline bytes compared by content; neither is equal
to an instance of another implementation. A value the reader returns can be held after the
reader moves on; while it is reachable, the inline bytes of every value in the batch it was
read from stay in memory. A writer checks every value it is given against the format's rules,
whatever implements it.
-
Method Summary
Modifier and TypeMethodDescriptionchecksum()The integrity token for the referenced bytes, as stored, ornullif the reference has none.The media type of the referenced bytes, ornullif the reference has none.static PqFileA reference to the whole object aturi.static PqFileA reference to the firstsizebytes of the object aturi.static PqFileA reference tosizebytes of the object aturi, starting atoffset.booleanWhether the reference stores an offset into the object aturi().booleanhasSize()Whether the reference stores the number of bytes referenced.byte[]inline()A copy of the bytes stored inline, ornullif the reference stores none.static PqFileinline(byte[] bytes) A reference to bytes stored in the value itself.longoffset()The position of the first referenced byte in the object aturi();0when the reference stores no offset.longsize()The number of bytes referenced in the object aturi().uri()The URI of the referenced object, ornullif the reference has none.default PqFilewithChecksum(String token) Returns a copy of this reference with an integrity token for the referenced bytes, of the form<algorithm>:<digest>, such asSHA-256:…or an object store'sETAG:….default PqFilewithContentType(String mediaType) Returns a copy of this reference with the media type of the referenced bytes.default PqFilewithInline(byte[] bytes) Returns a copy of this reference that also storesbytesinline.
-
Method Details
-
inline
A reference to bytes stored in the value itself.- Parameters:
bytes- the referenced bytes, possibly empty- Throws:
NullPointerException- ifbytesisnull
-
external
A reference to the whole object aturi.- Parameters:
uri- an RFC 3986 URI-reference, absolute or relative, stored as given- Throws:
NullPointerException- ifuriisnullIllegalArgumentException- ifuriis empty
-
external
A reference to the firstsizebytes of the object aturi.- Parameters:
uri- an RFC 3986 URI-reference, absolute or relative, stored as givensize- the number of bytes referenced,0for none- Throws:
NullPointerException- ifuriisnullIllegalArgumentException- ifuriis empty orsizeis negative
-
external
A reference tosizebytes of the object aturi, starting atoffset.- Parameters:
uri- an RFC 3986 URI-reference, absolute or relative, stored as givenoffset- the position of the first byte referencedsize- the number of bytes referenced,0for none- Throws:
NullPointerException- ifuriisnullIllegalArgumentException- ifuriis empty, oroffsetorsizeis negative
-
withInline
Returns a copy of this reference that also storesbytesinline. Combined withexternal(String)it records where inline bytes came from; the two are expected to denote the same bytes, which is not checked.- Throws:
NullPointerException- ifbytesisnullIllegalStateException- if this reference already stores bytes inline
-
withContentType
Returns a copy of this reference with the media type of the referenced bytes.- Parameters:
mediaType- an RFC 2046 media type, such asimage/png- Throws:
NullPointerException- ifmediaTypeisnullIllegalArgumentException- ifmediaTypeis emptyIllegalStateException- if this reference already has a content type
-
withChecksum
Returns a copy of this reference with an integrity token for the referenced bytes, of the form<algorithm>:<digest>, such asSHA-256:…or an object store'sETAG:…. The token is stored as given and not verified against any bytes. The writer refuses a token not of that form, and one whose digest forMD5,CRC32,CRC32CorSHA-256is not lowercase hex of that algorithm's length.- Throws:
NullPointerException- iftokenisnullIllegalArgumentException- iftokenis emptyIllegalStateException- if this reference already has a checksum
-
uri
String uri()The URI of the referenced object, ornullif the reference has none. -
hasOffset
boolean hasOffset()Whether the reference stores an offset into the object aturi(). -
offset
long offset()The position of the first referenced byte in the object aturi();0when the reference stores no offset. -
hasSize
boolean hasSize()Whether the reference stores the number of bytes referenced. A reference to a whole object stores none. -
size
long size()The number of bytes referenced in the object aturi().- Throws:
IllegalStateException- if the reference stores no size, whichhasSize()answers
-
contentType
String contentType()The media type of the referenced bytes, ornullif the reference has none. The format states that a reference without one can be assumed to beapplication/octet-stream. -
checksum
String checksum()The integrity token for the referenced bytes, as stored, ornullif the reference has none. -
inline
byte[] inline()A copy of the bytes stored inline, ornullif the reference stores none.
-