Search in sources :

Example 1 with Text

use of com.cinchapi.concourse.server.model.Text 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 2 with Text

use of com.cinchapi.concourse.server.model.Text in project concourse by cinchapi.

the class Database method explore.

@Override
public Map<Long, Set<TObject>> explore(String key, Aliases aliases, long timestamp) {
    Text L = Text.wrapCached(key);
    IndexRecord index = getIndexRecord(L);
    Value[] Ks = Transformers.transformArray(aliases.values(), Value::wrap, Value.class);
    Map<Identifier, Set<Value>> map = index.findAndGet(timestamp, aliases.operator(), Ks);
    return Transformers.transformTreeMapSet(map, Identifier::longValue, Value::getTObject, Long::compare);
}
Also used : Identifier(com.cinchapi.concourse.server.model.Identifier) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text)

Example 3 with Text

use of com.cinchapi.concourse.server.model.Text in project concourse by cinchapi.

the class Database method verify.

@Override
public boolean verify(Write write, long timestamp) {
    Identifier L = write.getRecord();
    Text K = write.getKey();
    Value V = write.getValue();
    TableRecord table = getTableRecord(L, K);
    return table.contains(K, V, timestamp);
}
Also used : Identifier(com.cinchapi.concourse.server.model.Identifier) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text)

Example 4 with Text

use of com.cinchapi.concourse.server.model.Text in project concourse by cinchapi.

the class Database method gather.

@Override
public Set<TObject> gather(String key, long record, long timestamp) {
    Text L = Text.wrapCached(key);
    Identifier V = Identifier.of(record);
    IndexRecord index = getIndexRecord(L);
    Set<Value> Ks = index.gather(V, timestamp);
    return Transformers.transformSet(Ks, Value::getTObject);
}
Also used : Identifier(com.cinchapi.concourse.server.model.Identifier) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text)

Example 5 with Text

use of com.cinchapi.concourse.server.model.Text in project concourse by cinchapi.

the class Database method verify.

@Override
public boolean verify(Write write) {
    Identifier L = write.getRecord();
    Text K = write.getKey();
    Value V = write.getValue();
    Record<Identifier, Text, Value> table = ENABLE_VERIFY_BY_LOOKUP ? getLookupRecord(L, K, V) : getTableRecord(L, K);
    return table.contains(K, V);
}
Also used : Identifier(com.cinchapi.concourse.server.model.Identifier) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text)

Aggregations

Text (com.cinchapi.concourse.server.model.Text)70 Value (com.cinchapi.concourse.server.model.Value)60 Test (org.junit.Test)46 ConcourseBaseTest (com.cinchapi.concourse.test.ConcourseBaseTest)34 Identifier (com.cinchapi.concourse.server.model.Identifier)28 CountDownLatch (java.util.concurrent.CountDownLatch)22 Set (java.util.Set)10 Operator (com.cinchapi.concourse.thrift.Operator)8 LinkedHashSet (java.util.LinkedHashSet)8 Position (com.cinchapi.concourse.server.model.Position)6 TObject (com.cinchapi.concourse.thrift.TObject)6 Action (com.cinchapi.concourse.server.storage.Action)4 Write (com.cinchapi.concourse.server.storage.temp.Write)4 RangeToken (com.cinchapi.concourse.server.concurrent.RangeToken)3 Composite (com.cinchapi.concourse.server.io.Composite)3 Revision (com.cinchapi.concourse.server.storage.db.Revision)3 Range (com.google.common.collect.Range)3 Path (java.nio.file.Path)3 AwaitableExecutorService (com.cinchapi.concourse.server.concurrent.AwaitableExecutorService)2 CorpusRecord (com.cinchapi.concourse.server.storage.db.CorpusRecord)2