Class ODataCollectionDecoder
{"@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(Flux, Function, ObjectMapper, Class, String, String) 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).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAn item or a piece of control information from a collection response. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> reactor.core.publisher.Flux<ODataCollectionDecoder.Event<T>> decode(reactor.core.publisher.Flux<DataBuffer> body, tools.jackson.databind.ObjectMapper mapper, Class<T> itemType, String method, String url) Decodes one response body.static <T> reactor.core.publisher.Flux<T> follow(reactor.core.publisher.Flux<DataBuffer> firstPage, Function<String, reactor.core.publisher.Flux<DataBuffer>> fetch, tools.jackson.databind.ObjectMapper mapper, Class<T> itemType, String method, String url) The items of a collection across all its pages: decodesfirstPage, then, if it had an@odata.nextLink, the pagefetchreturns for that link, and so on.static <T> reactor.core.publisher.Flux<T> items(reactor.core.publisher.Flux<DataBuffer> body, tools.jackson.databind.ObjectMapper mapper, Class<T> itemType, String method, String url) Just the items of one response body.
-
Method Details
-
decode
public static <T> reactor.core.publisher.Flux<ODataCollectionDecoder.Event<T>> decode(reactor.core.publisher.Flux<DataBuffer> body, tools.jackson.databind.ObjectMapper mapper, Class<T> itemType, String method, String url) Decodes one response body.- Type Parameters:
T- the type of the collection's items- Parameters:
body- the response body; each buffer is released once readmapper- the mapper to read items withitemType- the type to read each item asmethod- the request's method, for error messagesurl- the request's URL, for error messages- Returns:
- the items and control information, in the order they appear in the body
-
items
public static <T> reactor.core.publisher.Flux<T> items(reactor.core.publisher.Flux<DataBuffer> body, tools.jackson.databind.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; usedecode(Flux, ObjectMapper, Class, String, String)to see them.- Type Parameters:
T- the type of the collection's items- Parameters:
body- the response body; each buffer is released once readmapper- the mapper to read items withitemType- the type to read each item asmethod- the request's method, for error messagesurl- the request's URL, for error messages- Returns:
- the non-null items, in order
-
follow
public static <T> reactor.core.publisher.Flux<T> follow(reactor.core.publisher.Flux<DataBuffer> firstPage, Function<String, reactor.core.publisher.Flux<DataBuffer>> fetch, tools.jackson.databind.ObjectMapper mapper, Class<T> itemType, String method, String url) The items of a collection across all its pages: decodesfirstPage, then, if it had an@odata.nextLink, the pagefetchreturns for that link, and so on. Next links are opaque: they're passed tofetchexactly as received (OData Part 1 §11.2.6.7).- Type Parameters:
T- the type of the collection's items- Parameters:
firstPage- the first page's response body; each buffer is released once readfetch- fetches the page at a next link, returning its response bodymapper- the mapper to read items withitemType- the type to read each item asmethod- the request's method, for error messagesurl- the first request's URL, for error messages; later pages use their next link- Returns:
- the non-null items of every page, in order
-