skipcheck

TM1 client · Docs · Queries

ODataCollectionDecoder

import io.skipcheck.tm1.client.odata.ODataCollectionDecoder;

Decodes an OData collection response, {"@odata.context":..., "value":[...]}, item by item as the bytes arrive, without ever holding the whole response.

TM1 doesn't page its responses (odata.maxpagesize is ignored), so a collection such as a large dimension's elements arrives as one body of any size. This decoder feeds Jackson's non-blocking parser with each buffer as it comes, and emits each item of value as soon as it's complete. Demand is respected: buffers are only requested as items are consumed.

Top-level control information (@odata.nextLink, @odata.count, @odata.deltaLink and so on) is emitted as ODataCollectionDecoder.Event.Control events, wherever it appears in the body. follow uses @odata.nextLink to fetch further pages.

A body that turns out to be an error, or that ends before the collection is complete, fails with a Tm1ProtocolException, even if items were already emitted (OData Part 1 §9.5).

Bytes that aren't UTF-8 are read as U+FFFD rather than failing the response: TM1 (11.8) sends them in the transaction log (Utf8Repair).

Members

decode staticDecodes one response body.
items staticJust the items of one response body.
follow staticThe items of a collection across all its pages.

decode

static
static <T> Flux<ODataCollectionDecoder.Event<T>> decode(Flux<DataBuffer> body, ObjectMapper mapper, Class<T> itemType, String method, String url)

Decodes one response body.

Parameters

body
the response body; each buffer is released once read
mapper
the mapper to read items with
itemType
the type to read each item as
method
the request's method, for error messages
url
the request's URL, for error messages

Returns

the items and control information, in the order they appear in the body

items

static
static <T> Flux<T> items(Flux<DataBuffer> body, ObjectMapper mapper, Class<T> itemType, String method, String url)

Just the items of one response body. Null members (possible in a collection of primitive values) are skipped, since a Reactor stream can't carry nulls; use decode to see them.

Parameters

body
the response body; each buffer is released once read
mapper
the mapper to read items with
itemType
the type to read each item as
method
the request's method, for error messages
url
the request's URL, for error messages

Returns

the non-null items, in order

follow

static
static <T> Flux<T> follow(Flux<DataBuffer> firstPage, Function<String,Flux<DataBuffer>> fetch, ObjectMapper mapper, Class<T> itemType, String method, String url)

The items of a collection across all its pages: decodes firstPage, then, if it had an @odata.nextLink, the page fetch returns for that link, and so on. Next links are opaque: they're passed to fetch exactly as received (OData Part 1 §11.2.6.7).

Parameters

firstPage
the first page's response body; each buffer is released once read
fetch
fetches the page at a next link, returning its response body
mapper
the mapper to read items with
itemType
the type to read each item as
method
the request's method, for error messages
url
the first request's URL, for error messages; later pages use their next link

Returns

the non-null items of every page, in order

Also in the Javadoc.