Search in sources :

Example 46 with SortableTable

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);
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) SortableTable(com.cinchapi.concourse.data.sort.SortableTable) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 47 with SortableTable

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);
}
Also used : AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) SortableTable(com.cinchapi.concourse.data.sort.SortableTable) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 48 with SortableTable

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));
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) SortableTable(com.cinchapi.concourse.data.sort.SortableTable) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 49 with SortableTable

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));
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) SortableTable(com.cinchapi.concourse.data.sort.SortableTable) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 50 with SortableTable

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);
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Page(com.cinchapi.concourse.lang.paginate.Page) Order(com.cinchapi.concourse.lang.sort.Order) Sorting(com.cinchapi.concourse.server.query.sort.Sorting) ImmutableMap(com.google.common.collect.ImmutableMap) TestData(com.cinchapi.concourse.util.TestData) Set(java.util.Set) Random(java.util.Random) Test(org.junit.Test) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) Lists(com.google.common.collect.Lists) TObject(com.cinchapi.concourse.thrift.TObject) Convert(com.cinchapi.concourse.util.Convert) Map(java.util.Map) Entry(java.util.Map.Entry) Assert(org.junit.Assert) SortableTable(com.cinchapi.concourse.data.sort.SortableTable) TObject(com.cinchapi.concourse.thrift.TObject) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) Page(com.cinchapi.concourse.lang.paginate.Page) ImmutableMap(com.google.common.collect.ImmutableMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

SortableTable (com.cinchapi.concourse.data.sort.SortableTable)64 TranslateClientExceptions (com.cinchapi.concourse.server.aop.TranslateClientExceptions)63 VerifyAccessToken (com.cinchapi.concourse.server.aop.VerifyAccessToken)63 VerifyReadPermission (com.cinchapi.concourse.server.aop.VerifyReadPermission)63 AtomicSupport (com.cinchapi.concourse.server.storage.AtomicSupport)63 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)54 TObject (com.cinchapi.concourse.thrift.TObject)49 ComplexTObject (com.cinchapi.concourse.thrift.ComplexTObject)48 Order (com.cinchapi.concourse.lang.sort.Order)31 NaturalLanguage (com.cinchapi.ccl.util.NaturalLanguage)30 AnyStrings (com.cinchapi.common.base.AnyStrings)30 Array (com.cinchapi.common.base.Array)30 CheckedExceptions (com.cinchapi.common.base.CheckedExceptions)30 Reflection (com.cinchapi.common.reflect.Reflection)30 Constants (com.cinchapi.concourse.Constants)30 Link (com.cinchapi.concourse.Link)30 Timestamp (com.cinchapi.concourse.Timestamp)30 SortableColumn (com.cinchapi.concourse.data.sort.SortableColumn)30 SortableSet (com.cinchapi.concourse.data.sort.SortableSet)30 ConcourseCompiler (com.cinchapi.concourse.lang.ConcourseCompiler)30