Search in sources :

Example 26 with TObject

use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.

the class ConcourseServer method selectKeysCclTimeOrder.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectKeysCclTimeOrder(List<String> keys, String ccl, long timestamp, TOrder order, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    try {
        AbstractSyntaxTree ast = compiler.parse(ccl);
        AtomicSupport store = getStore(transaction, environment);
        SortableTable<Set<TObject>> result = emptySortableResultDataset();
        AtomicOperations.executeWithRetry(store, atomic -> Operations.selectKeysAstAtomic(keys, ast, timestamp, result, null, $result -> $result.sort(Sorting.byValues(Orders.from(order), atomic), timestamp), atomic));
        return result;
    } catch (Exception e) {
        throw new ParseException(e.getMessage());
    }
}
Also used : UpgradeTasks(com.cinchapi.concourse.server.upgrade.UpgradeTasks) TServer(org.apache.thrift.server.TServer) Transaction(com.cinchapi.concourse.server.storage.Transaction) Constants(com.cinchapi.concourse.Constants) Permission(com.cinchapi.concourse.security.Permission) ServerSocket(java.net.ServerSocket) ConcourseCalculateService(com.cinchapi.concourse.thrift.ConcourseCalculateService) TransactionStateException(com.cinchapi.concourse.server.storage.TransactionStateException) SortableColumn(com.cinchapi.concourse.data.sort.SortableColumn) SecurityException(com.cinchapi.concourse.thrift.SecurityException) Map(java.util.Map) TThreadPoolServer(org.apache.thrift.server.TThreadPoolServer) TransactionException(com.cinchapi.concourse.thrift.TransactionException) Link(com.cinchapi.concourse.Link) SortableSet(com.cinchapi.concourse.data.sort.SortableSet) SortableTable(com.cinchapi.concourse.data.sort.SortableTable) AccessToken(com.cinchapi.concourse.thrift.AccessToken) UserService(com.cinchapi.concourse.security.UserService) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions) Orders(com.cinchapi.concourse.server.query.sort.Orders) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) FileSystem(com.cinchapi.concourse.server.io.FileSystem) Set(java.util.Set) DuplicateEntryException(com.cinchapi.concourse.thrift.DuplicateEntryException) Executors(java.util.concurrent.Executors) ConcourseManagementService(com.cinchapi.concourse.server.management.ConcourseManagementService) MalformedObjectNameException(javax.management.MalformedObjectNameException) AtomicOperation(com.cinchapi.concourse.server.storage.AtomicOperation) Operator(com.cinchapi.concourse.thrift.Operator) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TProcessor(org.apache.thrift.TProcessor) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) PluginManager(com.cinchapi.concourse.server.plugin.PluginManager) Stores(com.cinchapi.concourse.server.ops.Stores) Iterables(com.google.common.collect.Iterables) Environments(com.cinchapi.concourse.util.Environments) TMultiplexedProcessor(org.apache.thrift.TMultiplexedProcessor) Sorting(com.cinchapi.concourse.server.query.sort.Sorting) Timestamps(com.cinchapi.concourse.util.Timestamps) ConcourseCompiler(com.cinchapi.concourse.lang.ConcourseCompiler) Strings(com.google.common.base.Strings) Reflection(com.cinchapi.common.reflect.Reflection) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) Lists(com.google.common.collect.Lists) InsufficientAtomicityException(com.cinchapi.concourse.server.ops.InsufficientAtomicityException) ManagementFactory(java.lang.management.ManagementFactory) TSimpleServer(org.apache.thrift.server.TSimpleServer) Array(com.cinchapi.common.base.Array) Nullable(javax.annotation.Nullable) ConcourseServerAdvisor(com.cinchapi.concourse.server.aop.ConcourseServerAdvisor) NonBlockingHashMap(org.cliffc.high_scale_lib.NonBlockingHashMap) Engine(com.cinchapi.concourse.server.storage.Engine) TException(org.apache.thrift.TException) CommandLine(com.cinchapi.concourse.shell.CommandLine) File(java.io.File) Args(org.apache.thrift.server.TThreadPoolServer.Args) NaturalLanguage(com.cinchapi.ccl.util.NaturalLanguage) CommitVersions(com.cinchapi.concourse.server.storage.CommitVersions) Guice(com.google.inject.Guice) Preconditions(com.google.common.base.Preconditions) ConcourseNavigateService(com.cinchapi.concourse.thrift.ConcourseNavigateService) AnyStrings(com.cinchapi.common.base.AnyStrings) TCriteria(com.cinchapi.concourse.thrift.TCriteria) TTransportException(org.apache.thrift.transport.TTransportException) Logger(com.cinchapi.concourse.util.Logger) AtomicStateException(com.cinchapi.concourse.server.storage.AtomicStateException) Paging(com.cinchapi.concourse.server.query.paginate.Paging) ByteBuffer(java.nio.ByteBuffer) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Convert(com.cinchapi.concourse.util.Convert) PluginRestricted(com.cinchapi.concourse.server.plugin.PluginRestricted) BufferedStore(com.cinchapi.concourse.server.storage.BufferedStore) TOrder(com.cinchapi.concourse.thrift.TOrder) Internal(com.cinchapi.concourse.server.aop.Internal) AtomicOperations(com.cinchapi.concourse.server.ops.AtomicOperations) Timestamp(com.cinchapi.concourse.Timestamp) Version(com.cinchapi.concourse.util.Version) ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) ManagedOperation(com.cinchapi.concourse.server.jmx.ManagedOperation) Operations(com.cinchapi.concourse.server.ops.Operations) Language(com.cinchapi.concourse.lang.Language) Sets(com.google.common.collect.Sets) List(java.util.List) Entry(java.util.Map.Entry) VerifyWritePermission(com.cinchapi.concourse.server.aop.VerifyWritePermission) CheckedExceptions(com.cinchapi.common.base.CheckedExceptions) Role(com.cinchapi.concourse.security.Role) ManagementException(com.cinchapi.concourse.thrift.ManagementException) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) Store(com.cinchapi.concourse.server.storage.Store) HttpServer(com.cinchapi.concourse.server.http.HttpServer) ConcourseService(com.cinchapi.concourse.thrift.ConcourseService) TransactionToken(com.cinchapi.concourse.thrift.TransactionToken) Multimap(com.google.common.collect.Multimap) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ParseException(com.cinchapi.concourse.thrift.ParseException) TObject(com.cinchapi.concourse.thrift.TObject) GlobalState(com.cinchapi.concourse.server.GlobalState) TMaps(com.cinchapi.concourse.util.TMaps) MBeanRegistrationException(javax.management.MBeanRegistrationException) NoSuchElementException(java.util.NoSuchElementException) MemoryUsage(java.lang.management.MemoryUsage) Time(com.cinchapi.concourse.time.Time) Iterator(java.util.Iterator) Order(com.cinchapi.concourse.lang.sort.Order) LazyTrackingTObjectResultDataset(com.cinchapi.concourse.server.plugin.data.LazyTrackingTObjectResultDataset) TPage(com.cinchapi.concourse.thrift.TPage) Pages(com.cinchapi.concourse.server.query.paginate.Pages) Maps(com.google.common.collect.Maps) Injector(com.google.inject.Injector) TServerSocket(org.apache.thrift.transport.TServerSocket) Finder(com.cinchapi.concourse.server.query.Finder) ClientInvokable(com.cinchapi.concourse.server.management.ClientInvokable) Immutable(javax.annotation.concurrent.Immutable) Diff(com.cinchapi.concourse.thrift.Diff) SortableSet(com.cinchapi.concourse.data.sort.SortableSet) Set(java.util.Set) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) ParseException(com.cinchapi.concourse.thrift.ParseException) TransactionStateException(com.cinchapi.concourse.server.storage.TransactionStateException) SecurityException(com.cinchapi.concourse.thrift.SecurityException) TransactionException(com.cinchapi.concourse.thrift.TransactionException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) DuplicateEntryException(com.cinchapi.concourse.thrift.DuplicateEntryException) MalformedObjectNameException(javax.management.MalformedObjectNameException) InsufficientAtomicityException(com.cinchapi.concourse.server.ops.InsufficientAtomicityException) TException(org.apache.thrift.TException) TTransportException(org.apache.thrift.transport.TTransportException) AtomicStateException(com.cinchapi.concourse.server.storage.AtomicStateException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ManagementException(com.cinchapi.concourse.thrift.ManagementException) ParseException(com.cinchapi.concourse.thrift.ParseException) MBeanRegistrationException(javax.management.MBeanRegistrationException) NoSuchElementException(java.util.NoSuchElementException) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 27 with TObject

use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.

the class Buffer method chronologize.

@Override
public Map<Long, Set<TObject>> chronologize(String key, long record, long start, long end, Map<Long, Set<TObject>> context) {
    Set<TObject> snapshot = Iterables.getLast(context.values(), Sets.<TObject>newLinkedHashSet());
    if (snapshot.isEmpty() && !context.isEmpty()) {
        // CON-474: Empty set is placed in the context if it was the last
        // snapshot known to the database
        context.remove(Time.NONE);
    }
    Iterator<Write> it = iterator(key, record, end - 1);
    try {
        while (it.hasNext()) {
            Write write = it.next();
            long timestamp = write.getVersion();
            Text $key = write.getKey();
            long $record = write.getRecord().longValue();
            Action action = write.getType();
            if ($key.toString().equals(key) && $record == record) {
                snapshot = Sets.newLinkedHashSet(snapshot);
                Value value = write.getValue();
                if (action == Action.ADD) {
                    snapshot.add(value.getTObject());
                } else if (action == Action.REMOVE) {
                    snapshot.remove(value.getTObject());
                }
                if (timestamp >= start) {
                    context.put(timestamp, snapshot);
                }
            }
        }
        return Maps.filterValues(context, emptySetFilter);
    } finally {
        Iterators.close(it);
    }
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) Action(com.cinchapi.concourse.server.storage.Action) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text)

Example 28 with TObject

use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.

the class Limbo method explore.

/**
 * This is an implementation of the
 * {@link #explore(long, String, Operator, TObject...)} routine that takes
 * in a prior {@code context} and will return a mapping from
 * records that match a criteria (expressed as {@code key} filtered by
 * {@code operator} in relation to one or more {@code values}) to the set of
 * values that caused that record to match the criteria {@code timestamp}.
 *
 * @param context
 * @param timestamp
 * @param key
 * @param operator
 * @param values
 * @return the relevant data for the records that satisfy the find query
 */
public Map<Long, Set<TObject>> explore(Map<Long, Set<TObject>> context, String key, Aliases aliases, long timestamp) {
    if (timestamp >= getOldestWriteTimestamp()) {
        Operator operator = aliases.operator();
        TObject[] values = aliases.values();
        for (Iterator<Write> it = iterator(); it.hasNext(); ) {
            Write write = it.next();
            long record = write.getRecord().longValue();
            if (write.getVersion() <= timestamp) {
                if (write.getKey().toString().equals(key) && matches(write.getValue(), operator, values)) {
                    if (write.getType() == Action.ADD) {
                        MultimapViews.put(context, record, write.getValue().getTObject());
                    } else {
                        MultimapViews.remove(context, record, write.getValue().getTObject());
                    }
                }
            } else {
                break;
            }
        }
    }
    return TMaps.asSortedMap(context);
}
Also used : Operator(com.cinchapi.concourse.thrift.Operator) TObject(com.cinchapi.concourse.thrift.TObject)

Example 29 with TObject

use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.

the class Operations method minKeyAtomic.

/**
 * Use the {@code store} to atomically compute the min across all the values
 * stored for {@code key} across all records at {@code timestamp}.
 *
 * @param key
 * @param timestamp
 * @param store
 * @return the max
 */
public static Number minKeyAtomic(String key, long timestamp, Store store) {
    checkAtomicity(store, timestamp);
    Map<TObject, Set<Long>> data = Stores.browse(store, key, timestamp);
    TObject min = Iterables.getFirst(data.keySet(), null);
    if (min != null) {
        return (Number) Convert.thriftToJava(min);
    } else {
        return null;
    }
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set)

Example 30 with TObject

use of com.cinchapi.concourse.thrift.TObject in project concourse by cinchapi.

the class Operations method avgKeyRecordAtomic.

/**
 * Use the provided {@code store} to atomically add each of the values in
 * {@code key}/{@code record} at {@code timestamp} to the running
 * {@code sum}.
 *
 * @param key the field name
 * @param record the record id
 * @param timestamp the selection timestamp
 * @param store the {@link Store} to use
 * @return the new running sum
 */
public static Number avgKeyRecordAtomic(String key, long record, long timestamp, Store store) {
    checkAtomicity(store, timestamp);
    Set<TObject> values = Stores.select(store, key, record, timestamp);
    Number sum = 0;
    for (TObject value : values) {
        Object object = Convert.thriftToJava(value);
        Calculations.checkCalculatable(object);
        Number number = (Number) object;
        sum = Numbers.add(sum, number);
    }
    return values.isEmpty() ? null : Numbers.divide(sum, values.size());
}
Also used : TObject(com.cinchapi.concourse.thrift.TObject) TObject(com.cinchapi.concourse.thrift.TObject)

Aggregations

TObject (com.cinchapi.concourse.thrift.TObject)242 Test (org.junit.Test)100 ComplexTObject (com.cinchapi.concourse.thrift.ComplexTObject)98 Set (java.util.Set)98 AtomicSupport (com.cinchapi.concourse.server.storage.AtomicSupport)96 TranslateClientExceptions (com.cinchapi.concourse.server.aop.TranslateClientExceptions)91 VerifyAccessToken (com.cinchapi.concourse.server.aop.VerifyAccessToken)91 VerifyReadPermission (com.cinchapi.concourse.server.aop.VerifyReadPermission)88 Map (java.util.Map)76 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)72 SortableTable (com.cinchapi.concourse.data.sort.SortableTable)71 Store (com.cinchapi.concourse.server.storage.Store)66 Order (com.cinchapi.concourse.lang.sort.Order)63 SortableColumn (com.cinchapi.concourse.data.sort.SortableColumn)61 SortableSet (com.cinchapi.concourse.data.sort.SortableSet)60 ByteBuffer (java.nio.ByteBuffer)60 Operator (com.cinchapi.concourse.thrift.Operator)59 Entry (java.util.Map.Entry)59 Convert (com.cinchapi.concourse.util.Convert)57 Sets (com.google.common.collect.Sets)57