use of io.deephaven.web.client.api.filter.FilterCondition in project deephaven-core by deephaven.
the class JsTable method applyFilter.
@JsMethod
@SuppressWarnings("unusable-by-js")
public JsArray<FilterCondition> applyFilter(FilterCondition[] filter) {
final List<FilterCondition> newFilter = Arrays.asList(filter);
// take a look at the current filter so we can return it
final ClientTableState current = state();
List<FilterCondition> currentFilter = current.getFilters();
// try to skip work (TODO refactor this into a private method)
if (!currentFilter.equals(newFilter)) {
if (batchDepth > 0) {
// when batching, just record what the user requested, but don't compute anything
// until the batch is complete.
workerConnection.getBatcher(this).filter(newFilter);
} else {
// we use the batch mechanism to handle unwinding / building table states
batch(batcher -> {
batcher.customColumns(current.getCustomColumns());
batcher.filter(newFilter);
batcher.sort(current.getSorts());
}).catch_(logError(() -> "Failed to apply filters: " + Arrays.toString(filter)));
}
}
return JsItr.slice(currentFilter);
}
use of io.deephaven.web.client.api.filter.FilterCondition in project deephaven-core by deephaven.
the class JsTreeTable method buildQuery.
/**
* Creates a request object based on the current state of request info. We don't presently build this ahead of time
* and maintain it as things change, but instead read from the rest of the tree's state to decide what to build.
*
* Sort is always assigned, since a node could be expanded, might now have children (and the server needs to know
* how to sort it), etc - the server will only sort individual "children" tables lazily, so this must always be
* provided.
*
* Filters are sent when the filter changes, or when something else changes that will result in rebuilding one or
* more children trees - the two cases that exist today are changing the sort, or reconnecting to the server. When
* filters are changed, the bookkeeping is done automatically, but for other purposes the releaseAllNodes helper
* method should be used to both release nodes and indicate that when refetched the filter may need to be applied
* again as well.
*/
private TreeTableRequest buildQuery() {
TreeTableRequest request = new TreeTableRequest();
// before building, evaluate all queued operations
if (queuedOperations != null) {
queuedOperations.run();
queuedOperations = null;
}
// if any of those operations asks for a close, just do the close and skip the rest
if (Arrays.asList(nextRequestOps).contains(TreeTableRequest.TreeRequestOperation.Close)) {
closed = true;
request.setIncludedOps(new TreeTableRequest.TreeRequestOperation[] { TreeTableRequest.TreeRequestOperation.Close });
request.setExpandedNodes(new TableDetails[0]);
request.setSorts(new SortDescriptor[0]);
request.setFilters(new FilterDescriptor[0]);
request.setColumns(new BitSet());
return request;
}
request.setExpandedNodes(expandedMap.values().stream().map(TreeNodeState::toTableDetails).toArray(TableDetails[]::new));
final int hierarchicalChildrenColumnIndex = Arrays.stream(this.baseTable.getTableDef().getColumns()).filter(col -> col.getName().equals(this.baseTable.getTableDef().getAttributes().getTreeHierarchicalColumnName())).mapToInt(ColumnDefinition::getColumnIndex).findFirst().orElseThrow(() -> new IllegalStateException("TreeTable definition has no hierarchy column"));
request.setKeyColumn(hierarchicalChildrenColumnIndex);
// filters on child tables, only on the root table
if (!filters.equals(nextFilters)) {
request.setFilters(nextFilters.stream().map(FilterCondition::makeDescriptor).toArray(FilterDescriptor[]::new));
} else {
request.setFilters(new FilterDescriptor[0]);
}
// always include the sort setup, the viewport content could have changed in practically any way
request.setSorts(nextSort.stream().map(Sort::makeDescriptor).toArray(SortDescriptor[]::new));
BitSet columnsBitset = baseTable.makeBitset(this.columns);
columnsBitset.set(hierarchicalChildrenColumnIndex);
request.setColumns(columnsBitset);
request.setViewportEnd((long) (double) lastRow);
request.setViewportStart((long) (double) firstRow);
request.setIncludedOps(nextRequestOps);
nextRequestOps = new TreeTableRequest.TreeRequestOperation[0];
return request;
}
use of io.deephaven.web.client.api.filter.FilterCondition in project deephaven-core by deephaven.
the class BatchBuilder method buildFilter.
private Operation buildFilter(BatchOp op, Supplier<TableReference> prevTableSupplier, Consumer<Ticket>[] lastOp) {
FilterTableRequest value = new FilterTableRequest();
for (FilterCondition filter : op.getFilters()) {
if (op.getAppendTo() == null || !op.getAppendTo().hasFilter(filter)) {
value.addFilters(filter.makeDescriptor());
}
}
if (value.getFiltersList().length == 0) {
return null;
}
Operation filterOp = new Operation();
filterOp.setFilter(value);
value.setSourceId(prevTableSupplier.get());
lastOp[0] = value::setResultId;
return filterOp;
}
Aggregations