use of com.cinchapi.concourse.server.storage.Store in project concourse by cinchapi.
the class SortingTest method testMissingKeyDescendingSort.
@Test
public void testMissingKeyDescendingSort() {
Map<Long, Map<String, Set<TObject>>> records = Maps.newLinkedHashMap();
List<String> keys = Lists.newArrayList("name", "company", "age");
Map<String, Set<TObject>> entry = TMaps.newLinkedHashMapWithCapacity(keys.size());
Set<TObject> values = Sets.newHashSet(Convert.javaToThrift("jeff"));
entry.put("name", values);
values = Sets.newHashSet(Convert.javaToThrift("Cinchapi"));
entry.put("company", values);
values = Sets.newHashSet(Convert.javaToThrift(50));
entry.put("age", values);
TMaps.putResultDatasetOptimized(records, Integer.toUnsignedLong(1), entry);
entry = TMaps.newLinkedHashMapWithCapacity(keys.size());
values = Sets.newHashSet(Convert.javaToThrift("jeffB"));
entry.put("name", values);
values = Sets.newHashSet(Convert.javaToThrift("Blavity"));
entry.put("company", values);
values = Sets.newHashSet(Convert.javaToThrift(100));
entry.put("age", values);
TMaps.putResultDatasetOptimized(records, Integer.toUnsignedLong(2), entry);
entry = TMaps.newLinkedHashMapWithCapacity(keys.size());
values = Sets.newHashSet(Convert.javaToThrift("ashleah"));
entry.put("name", values);
values = Sets.newHashSet(Convert.javaToThrift("ARMN Inc."));
entry.put("company", values);
TMaps.putResultDatasetOptimized(records, Integer.toUnsignedLong(3), entry);
entry = TMaps.newLinkedHashMapWithCapacity(keys.size());
values = Sets.newHashSet(Convert.javaToThrift("mark"));
entry.put("name", values);
values = Sets.newHashSet(Convert.javaToThrift("Cinchapi"));
entry.put("company", values);
values = Sets.newHashSet(Convert.javaToThrift(100));
entry.put("age", values);
TMaps.putResultDatasetOptimized(records, Integer.toUnsignedLong(4), entry);
Order order = Order.by("age").descending();
Store store = new Queue(1);
Map<Long, Map<String, Set<TObject>>> result = Sorting.byValues(order, store).organize(records);
List<Long> expectedSort = Lists.newArrayList();
expectedSort.add(Integer.toUnsignedLong(2));
expectedSort.add(Integer.toUnsignedLong(4));
expectedSort.add(Integer.toUnsignedLong(1));
expectedSort.add(Integer.toUnsignedLong(3));
List<Long> sort = Lists.newArrayList(result.keySet());
Assert.assertEquals(expectedSort, sort);
}
use of com.cinchapi.concourse.server.storage.Store in project concourse by cinchapi.
the class ConcourseServer method findCcl.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findCcl(String ccl, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(ccl);
AtomicSupport store = getStore(transaction, environment);
Function<Store, Set<Long>> function = $store -> ast.accept(Finder.instance(), $store);
try {
return function.apply(store);
} catch (InsufficientAtomicityException e) {
return AtomicOperations.supplyWithRetry(store, atomic -> function.apply(atomic));
}
}
use of com.cinchapi.concourse.server.storage.Store in project concourse by cinchapi.
the class ConcourseServer method findKeyOperatorValuesPage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findKeyOperatorValuesPage(String key, Operator operator, List<TObject> values, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
TObject[] tValues = values.toArray(Array.containing());
AtomicSupport store = getStore(transaction, environment);
Function<Store, Set<Long>> function = $store -> Stores.find($store, key, operator, tValues);
Set<Long> records;
try {
records = function.apply(store);
} catch (InsufficientAtomicityException e) {
records = AtomicOperations.supplyWithRetry(store, atomic -> function.apply(atomic));
}
return Paging.page(records, Pages.from(page));
}
use of com.cinchapi.concourse.server.storage.Store in project concourse by cinchapi.
the class ConcourseServer method getKeyRecord.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public TObject getKeyRecord(String key, long record, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AtomicSupport store = getStore(transaction, environment);
Function<Store, TObject> function = $store -> Iterables.getLast(Stores.select($store, key, record), TObject.NULL);
try {
return function.apply(store);
} catch (InsufficientAtomicityException e) {
return AtomicOperations.supplyWithRetry(store, atomic -> function.apply(atomic));
}
}
use of com.cinchapi.concourse.server.storage.Store in project concourse by cinchapi.
the class ConcourseServer method findKeyOperatorValuesTimePage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findKeyOperatorValuesTimePage(String key, Operator operator, List<TObject> values, long timestamp, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
TObject[] tValues = values.toArray(Array.containing());
AtomicSupport store = getStore(transaction, environment);
Function<Store, Set<Long>> function = $store -> Stores.find($store, timestamp, key, operator, tValues);
Set<Long> records;
try {
records = function.apply(store);
} catch (InsufficientAtomicityException e) {
records = AtomicOperations.supplyWithRetry(store, atomic -> function.apply(atomic));
}
return Paging.page(records, Pages.from(page));
}
Aggregations