Search in sources :

Example 41 with Value

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

the class Database method explore.

@Override
public Map<Long, Set<TObject>> explore(String key, Aliases aliases) {
    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(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 42 with Value

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

the class Database method browse.

@Override
public Map<TObject, Set<Long>> browse(String key) {
    Text L = Text.wrapCached(key);
    IndexRecord index = getIndexRecord(L);
    Map<Value, Set<Identifier>> data = index.getAll();
    return Transformers.transformTreeMapSet(data, Value::getTObject, Identifier::longValue, TObjectSorter.INSTANCE);
}
Also used : Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) Identifier(com.cinchapi.concourse.server.model.Identifier) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text)

Example 43 with Value

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

the class Database method browse.

@Override
public Map<TObject, Set<Long>> browse(String key, long timestamp) {
    Text L = Text.wrapCached(key);
    IndexRecord index = getIndexRecord(L);
    Map<Value, Set<Identifier>> data = index.getAll(timestamp);
    return Transformers.transformTreeMapSet(data, Value::getTObject, Identifier::longValue, TObjectSorter.INSTANCE);
}
Also used : Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) Identifier(com.cinchapi.concourse.server.model.Identifier) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text)

Example 44 with Value

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

the class Upgrade0_11_0_1 method doTask.

@Override
protected void doTask() {
    Environments.iterator(GlobalState.BUFFER_DIRECTORY, GlobalState.DATABASE_DIRECTORY).forEachRemaining(environment -> {
        logInfoMessage("Upgrading Storage Format v2 data files to Storage Format v3 in environment {}", environment);
        Path directory = Paths.get(GlobalState.DATABASE_DIRECTORY).resolve(environment);
        Database db = new Database(directory);
        db.start();
        try {
            Path cpb = directory.resolve("cpb");
            Iterable<Block<Identifier, Text, Value>> blocks = StorageFormatV2.load(cpb, TableRevision.class);
            for (Block<Identifier, Text, Value> block : blocks) {
                for (Revision<Identifier, Text, Value> revision : block) {
                    Write write = Reflection.newInstance(Write.class, revision.getType(), revision.getKey(), revision.getValue(), revision.getLocator(), // (authorized)
                    revision.getVersion());
                    db.accept(write);
                }
                db.sync();
                logInfoMessage("Finished transferring v2 data Block {} to v3 Segment format", block.getId());
            }
        } finally {
            db.stop();
        }
    });
}
Also used : Path(java.nio.file.Path) Write(com.cinchapi.concourse.server.storage.temp.Write) Identifier(com.cinchapi.concourse.server.model.Identifier) Database(com.cinchapi.concourse.server.storage.db.Database) Value(com.cinchapi.concourse.server.model.Value) Block(com.cinchapi.concourse.server.storage.format.StorageFormatV2.Block) Text(com.cinchapi.concourse.server.model.Text)

Example 45 with Value

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

the class IndexRecord method gather.

/**
 * Return all the keys that mapped to the {@code record} at
 * {@code timestamp}.
 * <p>
 * In the broader {@link Database} sense, this method can be used to return
 * all the data "values" that were stored within a data "record" under a
 * data "key" that is equivalent to this {@link IndexRecord
 * SecondaryRecord's} locator at {@code timestamp} (similar to
 * {@link Database#select(long, long)}).
 * </p>
 * <p>
 * NOTE: The order of the items in the returned {@link Set} are not
 * necessarily reflective of the order in which they were inserted into the
 * {@link IndexRecord}.
 * </p>
 *
 * @param record
 * @return a {@link Set} containing all the keys that map to the
 *         {@code value}
 */
public Set<Value> gather(Identifier record, long timestamp) {
    Preconditions.checkState(!isPartial(), "Cannot gather from a partial Secondary Record.");
    read.lock();
    try {
        Map<Identifier, Set<Value>> slice = cube.slice(timestamp);
        if (slice == null) {
            Set<Value> values = Sets.newHashSet();
            Set<Entry<Value, Set<Identifier>>> entries = timestamp != Time.NONE ? LazyTransformSet.of(history.entrySet(), entry -> new AbstractMap.SimpleImmutableEntry<>(entry.getKey(), extractHistoricalValues(entry.getValue(), timestamp))) : present.entrySet();
            for (Entry<Value, Set<Identifier>> entry : entries) {
                Value value = entry.getKey();
                Set<Identifier> records = entry.getValue();
                if (records.contains(record)) {
                    values.add(value);
                }
                for (Identifier $record : records) {
                    if ($record.equals(record)) {
                        values.add(value);
                    }
                    cube.put($record, value, timestamp);
                }
            }
            return values;
        } else {
            return slice.getOrDefault(record, ImmutableSet.of());
        }
    } finally {
        read.unlock();
    }
}
Also used : PackagePrivate(com.cinchapi.concourse.annotate.PackagePrivate) BiPredicate(java.util.function.BiPredicate) Matcher(java.util.regex.Matcher) MultimapViews(com.cinchapi.concourse.util.MultimapViews) CoalescableTreeMap(com.cinchapi.common.collect.CoalescableTreeMap) Map(java.util.Map) Action(com.cinchapi.concourse.server.storage.Action) SoftReference(java.lang.ref.SoftReference) Value(com.cinchapi.concourse.server.model.Value) Nullable(javax.annotation.Nullable) DoNotInvoke(com.cinchapi.concourse.annotate.DoNotInvoke) Time(com.cinchapi.concourse.time.Time) ImmutableSet(com.google.common.collect.ImmutableSet) Iterator(java.util.Iterator) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) NavigableSet(java.util.NavigableSet) ThreadSafe(javax.annotation.concurrent.ThreadSafe) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) AbstractMap(java.util.AbstractMap) List(java.util.List) Operator(com.cinchapi.concourse.thrift.Operator) Identifier(com.cinchapi.concourse.server.model.Identifier) Versioned(com.cinchapi.concourse.server.storage.Versioned) Entry(java.util.Map.Entry) Preconditions(com.google.common.base.Preconditions) Pattern(java.util.regex.Pattern) LazyTransformSet(com.cinchapi.common.collect.lazy.LazyTransformSet) Text(com.cinchapi.concourse.server.model.Text) Entry(java.util.Map.Entry) Identifier(com.cinchapi.concourse.server.model.Identifier) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) NavigableSet(java.util.NavigableSet) LazyTransformSet(com.cinchapi.common.collect.lazy.LazyTransformSet) Value(com.cinchapi.concourse.server.model.Value)

Aggregations

Value (com.cinchapi.concourse.server.model.Value)73 Text (com.cinchapi.concourse.server.model.Text)60 Test (org.junit.Test)43 ConcourseBaseTest (com.cinchapi.concourse.test.ConcourseBaseTest)34 Identifier (com.cinchapi.concourse.server.model.Identifier)25 CountDownLatch (java.util.concurrent.CountDownLatch)22 Set (java.util.Set)14 Operator (com.cinchapi.concourse.thrift.Operator)10 Action (com.cinchapi.concourse.server.storage.Action)6 Range (com.google.common.collect.Range)6 LinkedHashSet (java.util.LinkedHashSet)6 TObject (com.cinchapi.concourse.thrift.TObject)5 LazyTransformSet (com.cinchapi.common.collect.lazy.LazyTransformSet)3 RangeToken (com.cinchapi.concourse.server.concurrent.RangeToken)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 ByteBuffer (java.nio.ByteBuffer)3 Path (java.nio.file.Path)3 NavigableSet (java.util.NavigableSet)3 CoalescableTreeMap (com.cinchapi.common.collect.CoalescableTreeMap)2 Position (com.cinchapi.concourse.server.model.Position)2