Java: Liberator.query() Example Queries

Last Known Value

A query that does not provide any date parameters will return the last known value.

Liberator liberator = new Liberator();
Object query_id = liberator.query(new HashMap<>() );

for (Liberator.QueryResult res : liberator.Generate()) {
    Object res_id = res.GetId();
    Object data = res.GetData();
    if(data instanceof org.apache.arrow.vector.VectorSchemaRoot){
        org.apache.arrow.vector.VectorSchemaRoot recordBatch = (org.apache.arrow.vector.VectorSchemaRoot) data;
        printRecordBatch(recordBatch);
    } else if (data instanceof javax.json.JsonValue) {
        javax.json.JsonValue jsonValue = (javax.json.JsonValue) data;
        System.out.println(jsonValue);
    } 
}

Output

Time Series Queries – Providing Date Parameters

There are two date parameters that you can pass.

Argument

Description

Type

Example

as _of

This value can be any past date so that you can see the data as it was known on the “as of” date.
as_of defaults to now.

String

Format YYYY-MM-DD HH:MM:SS

(HH:MM:SS is optional)

“as_of”:“2020-11-22 19:51:31”

back_to

The date where the return dataset should begin.
This is reading all the data “back to” the specified date.

String

Format YYYY-MM-DD HH:MM:SS

(HH:MM:SS is optional)

“back_to”:“2020-01-01”

💡: Note if as_of and back_to are the same date time, then you will not receive a time series result.

Liberator liberator = new Liberator();
Object query_id = liberator.query(new HashMap<>() );

for (Liberator.QueryResult res : liberator.Generate()) {
    Object res_id = res.GetId();
    Object data = res.GetData();
    if(data instanceof org.apache.arrow.vector.VectorSchemaRoot){
        org.apache.arrow.vector.VectorSchemaRoot recordBatch = (org.apache.arrow.vector.VectorSchemaRoot) data;
        printRecordBatch(recordBatch);
    } else if (data instanceof javax.json.JsonValue) {
        javax.json.JsonValue jsonValue = (javax.json.JsonValue) data;
        System.out.println(jsonValue);
    } 
}