use of com.cinchapi.concourse.server.storage.Action in project concourse by cinchapi.
the class RecordTest method getAction.
/**
* Get the appropriate action for {@code locator}, {@code key} and
* {@code value} to maintain the offsetting constraint.
*
* @param locator
* @param key
* @param value
* @return the appropriate action
*/
protected Action getAction(L locator, K key, V value) {
Composite comp = Composite.create(locator, key, value);
Action action = actions.get(comp);
if (action == null || action == Action.REMOVE) {
action = Action.ADD;
} else {
action = Action.REMOVE;
}
actions.put(comp, action);
return action;
}
use of com.cinchapi.concourse.server.storage.Action in project concourse by cinchapi.
the class Limbo method chronologize.
/**
* Return a time series that contains the values stored for {@code key} in
* {@code record} at each modification timestamp between {@code start}
* (inclusive) and {@code end} (exclusive).
*
* @param key the field name
* @param record the record id
* @param start the start timestamp (inclusive)
* @param end the end timestamp (exclusive)
* @param context the prior context
* @return a {@link Map mapping} from modification timestamp to a non-empty
* {@link Set} of values that were contained at that timestamp
*/
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);
}
for (Iterator<Write> it = iterator(); it.hasNext(); ) {
Write write = it.next();
long timestamp = write.getVersion();
if (timestamp >= end) {
break;
} else {
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);
}
Aggregations