use of com.cinchapi.concourse.data.sort.SortableTable in project concourse by cinchapi.
the class ConcourseServer method selectCriteriaTimePage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectCriteriaTimePage(TCriteria criteria, long timestamp, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(criteria);
AtomicSupport store = getStore(transaction, environment);
Supplier<SortableTable<Set<TObject>>> supplier = () -> emptySortableResultDataset();
return Operations.selectAstOptionalAtomic(store, ast, timestamp, Orders.from(NO_ORDER), Pages.from(page), supplier);
}
use of com.cinchapi.concourse.data.sort.SortableTable in project concourse by cinchapi.
the class ConcourseServer method getKeysRecordsTimePage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, TObject>> getKeysRecordsTimePage(List<String> keys, List<Long> records, long timestamp, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AtomicSupport store = getStore(transaction, environment);
Supplier<SortableTable<TObject>> supplier = () -> SortableTable.singleValued(new LinkedHashMap<>(records.size()));
return Operations.getKeysRecordsOptionalAtomic(store, keys, records, timestamp, Orders.from(NO_ORDER), Pages.from(page), supplier);
}
use of com.cinchapi.concourse.data.sort.SortableTable in project concourse by cinchapi.
the class ConcourseServer method selectKeysCriteriaOrderPage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectKeysCriteriaOrderPage(List<String> keys, TCriteria criteria, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(criteria);
AtomicSupport store = getStore(transaction, environment);
Supplier<SortableTable<Set<TObject>>> supplier = () -> emptySortableResultDataset();
return AtomicOperations.supplyWithRetry(store, atomic -> Operations.selectKeysAstAtomic(atomic, keys, ast, Orders.from(order), Pages.from(page), supplier));
}
use of com.cinchapi.concourse.data.sort.SortableTable in project concourse by cinchapi.
the class ConcourseServer method selectKeysRecordsOrderPage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectKeysRecordsOrderPage(List<String> keys, List<Long> records, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AtomicSupport store = getStore(transaction, environment);
Supplier<SortableTable<Set<TObject>>> supplier = () -> emptySortableResultDataset();
return AtomicOperations.supplyWithRetry(store, atomic -> Operations.selectKeysRecordsAtomic(atomic, keys, records, Orders.from(order), Pages.from(page), supplier));
}
use of com.cinchapi.concourse.data.sort.SortableTable in project concourse by cinchapi.
the class PaginationTest method testPaginateSortedMap.
@Test
public void testPaginateSortedMap() {
SortableTable<Set<TObject>> table = SortableTable.multiValued(Maps.newLinkedHashMap());
table.put(1L, ImmutableMap.of("name", ImmutableSet.of(Convert.javaToThrift("a"))));
table.put(2L, ImmutableMap.of("name", ImmutableSet.of(Convert.javaToThrift("b"))));
table.put(3L, ImmutableMap.of("name", ImmutableSet.of(Convert.javaToThrift("c"))));
table.put(4L, ImmutableMap.of("name", ImmutableSet.of(Convert.javaToThrift("d"))));
table.put(5L, ImmutableMap.of("name", ImmutableSet.of(Convert.javaToThrift("e"))));
table.put(6L, ImmutableMap.of("name", ImmutableSet.of(Convert.javaToThrift("z"))));
table.sort(Sorting.byValues(Order.by("name").largestFirst(), null));
Page page = Page.sized(2).go(2);
Map<Long, Map<String, Set<TObject>>> expected = table.entrySet().stream().skip(page.skip()).limit(page.limit()).collect(Collectors.toMap(Entry::getKey, Entry::getValue, (a, b) -> b, LinkedHashMap::new));
Map<Long, Map<String, Set<TObject>>> actual = Paging.page(table, page);
Assert.assertEquals(expected, actual);
}
Aggregations