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);
}
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);
}
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);
}
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();
}
});
}
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();
}
}
Aggregations