use of com.cinchapi.concourse.server.model.Identifier in project concourse by cinchapi.
the class IndexRecordTest method testFindBrowseOnlyReturnsRelevantData.
@Test
public void testFindBrowseOnlyReturnsRelevantData() {
Text locator = TestData.getText();
record = getRecord(locator);
for (int i = 0; i < 100; i++) {
for (int j = 0; j <= i; j++) {
record.append(getRevision(locator, Value.wrap(Convert.javaToThrift(j)), Identifier.of(i)));
}
}
Map<Identifier, Set<Value>> data = ((IndexRecord) record).findAndGet(Operator.GREATER_THAN, Value.wrap(Convert.javaToThrift(50)));
for (int i = 0; i < 100; i++) {
Identifier pk = Identifier.of(i);
if (i > 50) {
Assert.assertTrue(data.containsKey(pk));
Assert.assertEquals(i - 50, data.get(pk).size());
for (Value value : data.get(pk)) {
Assert.assertTrue(value.compareTo(Value.wrap(Convert.javaToThrift(50))) > 0);
}
} else {
Assert.assertFalse(data.containsKey(pk));
}
}
}
use of com.cinchapi.concourse.server.model.Identifier in project concourse by cinchapi.
the class TableRecordTest method testChronologize.
@Test
public void testChronologize() {
Map<Long, Set<Value>> map = Maps.newLinkedHashMap();
Set<Value> set = Sets.newLinkedHashSet();
Set<Value> allValues = Sets.newLinkedHashSet();
long recordId = TestData.getLong();
Identifier primaryKey = Identifier.of(recordId);
TableRecord record = TableRecord.create(primaryKey);
for (long i = 30; i <= 35; i++) {
Value value = null;
while (value == null || !allValues.add(value)) {
value = TestData.getValue();
}
record.append(getRevision(primaryKey, Text.wrapCached("name"), value));
set.add(value);
}
long start = Time.now();
for (long i = 36; i <= 45; i++) {
set = Sets.newLinkedHashSet(set);
Value value = null;
while (value == null || !allValues.add(value)) {
value = TestData.getValue();
}
record.append(getRevision(primaryKey, Text.wrapCached("name"), value));
set.add(value);
map.put(i, set);
}
long end = Time.now();
for (long i = 51; i <= 60; i++) {
Value value = null;
while (value == null || !allValues.add(value)) {
value = TestData.getValue();
}
record.append(getRevision(primaryKey, Text.wrapCached("name"), value));
}
Map<Long, Set<Value>> newMap = record.chronologize(Text.wrapCached("name"), start, end);
long key = 36;
for (Entry<Long, Set<Value>> e : newMap.entrySet()) {
Set<Value> result = e.getValue();
Assert.assertEquals(map.get(key), result);
key++;
}
}
use of com.cinchapi.concourse.server.model.Identifier in project concourse by cinchapi.
the class ByteableCollectionsTest method testHasNextNotRequired.
@Test
public void testHasNextNotRequired() {
Path file = Paths.get(TestData.getTemporaryTestFile());
List<Identifier> values = Lists.newArrayList();
int count = 10;
for (int i = 0; i < count; ++i) {
values.add(Identifier.of(i));
}
ByteBuffer bytes = ByteableCollections.toByteBuffer(values);
FileSystem.writeBytes(bytes, file.toString());
int bufferSize = 64;
Iterator<ByteBuffer> it = ByteableCollections.stream(file, bufferSize);
for (int i = 0; i < count; ++i) {
it.next();
}
Assert.assertFalse(it.hasNext());
}
use of com.cinchapi.concourse.server.model.Identifier in project concourse by cinchapi.
the class ByteableCollectionsTest method testStreamIteratorMultipleHasNext.
@Test
public void testStreamIteratorMultipleHasNext() {
Path file = Paths.get(TestData.getTemporaryTestFile());
List<Identifier> values = Lists.newArrayList();
int count = 10;
for (int i = 0; i < count; ++i) {
values.add(Identifier.of(i));
}
ByteBuffer bytes = ByteableCollections.toByteBuffer(values);
FileSystem.writeBytes(bytes, file.toString());
int bufferSize = 64;
Iterator<ByteBuffer> it = ByteableCollections.stream(file, bufferSize);
List<Identifier> newValues = Lists.newArrayList();
while (it.hasNext()) {
if (it.hasNext()) {
newValues.add(Identifier.fromByteBuffer(it.next()));
}
}
Assert.assertEquals(values, newValues);
}
use of com.cinchapi.concourse.server.model.Identifier 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);
}
Aggregations