Search in sources :

Example 41 with AbstractSyntaxTree

use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.

the class ConcourseServer method findCclOrderPage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findCclOrderPage(String ccl, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AbstractSyntaxTree ast = compiler.parse(ccl);
    AtomicSupport store = getStore(transaction, environment);
    return AtomicOperations.supplyWithRetry(store, atomic -> {
        SortableSet<Set<TObject>> records = SortableSet.of(ast.accept(Finder.instance(), atomic));
        records.sort(Sorting.byValues(Orders.from(order), store));
        return Paging.page(records, Pages.from(page));
    });
}
Also used : SortableSet(com.cinchapi.concourse.data.sort.SortableSet) Set(java.util.Set) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 42 with AbstractSyntaxTree

use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.

the class ConcourseServer method findOrInsertCriteriaJson.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public long findOrInsertCriteriaJson(TCriteria criteria, String json, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    List<Multimap<String, Object>> objects = Lists.newArrayList(Convert.jsonToJava(json));
    AbstractSyntaxTree ast = compiler.parse(criteria);
    AtomicSupport store = getStore(transaction, environment);
    Set<Long> records = Sets.newLinkedHashSet();
    AtomicOperations.executeWithRetry(store, (atomic) -> {
        records.clear();
        Operations.findOrInsertAtomic(records, objects, ast, atomic);
    });
    if (records.size() == 1) {
        return Iterables.getOnlyElement(records);
    } else {
        throw new DuplicateEntryException(AnyStrings.joinWithSpace("Found", records.size(), "records that match", Language.translateFromThriftCriteria(criteria).ccl()));
    }
}
Also used : Multimap(com.google.common.collect.Multimap) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) DuplicateEntryException(com.cinchapi.concourse.thrift.DuplicateEntryException) VerifyWritePermission(com.cinchapi.concourse.server.aop.VerifyWritePermission) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 43 with AbstractSyntaxTree

use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.

the class ConcourseServer method countKeyCcl.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public long countKeyCcl(String key, String ccl, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AbstractSyntaxTree ast = compiler.parse(ccl);
    AtomicSupport store = getStore(transaction, environment);
    return AtomicOperations.supplyWithRetry(store, (atomic) -> {
        Set<Long> records = ast.accept(Finder.instance(), atomic);
        return Operations.countKeyRecordsAtomic(key, records, Time.NONE, atomic);
    });
}
Also used : AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 44 with AbstractSyntaxTree

use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.

the class ConcourseServer method selectCriteriaTimeOrderPage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectCriteriaTimeOrderPage(TCriteria criteria, long timestamp, 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.selectAstOptionalAtomic(atomic, ast, timestamp, 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 45 with AbstractSyntaxTree

use of com.cinchapi.ccl.syntax.AbstractSyntaxTree in project concourse by cinchapi.

the class ConcourseServer method selectKeysCclOrderPage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectKeysCclOrderPage(List<String> keys, String ccl, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AbstractSyntaxTree ast = compiler.parse(ccl);
    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)

Aggregations

AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)113 TranslateClientExceptions (com.cinchapi.concourse.server.aop.TranslateClientExceptions)104 VerifyAccessToken (com.cinchapi.concourse.server.aop.VerifyAccessToken)104 AtomicSupport (com.cinchapi.concourse.server.storage.AtomicSupport)104 VerifyReadPermission (com.cinchapi.concourse.server.aop.VerifyReadPermission)102 SortableTable (com.cinchapi.concourse.data.sort.SortableTable)62 TObject (com.cinchapi.concourse.thrift.TObject)57 ComplexTObject (com.cinchapi.concourse.thrift.ComplexTObject)56 SortableColumn (com.cinchapi.concourse.data.sort.SortableColumn)50 SortableSet (com.cinchapi.concourse.data.sort.SortableSet)42 Set (java.util.Set)42 VerifyWritePermission (com.cinchapi.concourse.server.aop.VerifyWritePermission)40 InsufficientAtomicityException (com.cinchapi.concourse.server.ops.InsufficientAtomicityException)39 NaturalLanguage (com.cinchapi.ccl.util.NaturalLanguage)38 AnyStrings (com.cinchapi.common.base.AnyStrings)38 Array (com.cinchapi.common.base.Array)38 CheckedExceptions (com.cinchapi.common.base.CheckedExceptions)38 Reflection (com.cinchapi.common.reflect.Reflection)38 Constants (com.cinchapi.concourse.Constants)38 Link (com.cinchapi.concourse.Link)38