Search in sources :

Example 16 with Identifier

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));
        }
    }
}
Also used : Identifier(com.cinchapi.concourse.server.model.Identifier) Set(java.util.Set) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text) Test(org.junit.Test)

Example 17 with Identifier

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++;
    }
}
Also used : Set(java.util.Set) Identifier(com.cinchapi.concourse.server.model.Identifier) Value(com.cinchapi.concourse.server.model.Value) Test(org.junit.Test)

Example 18 with Identifier

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());
}
Also used : Path(java.nio.file.Path) Identifier(com.cinchapi.concourse.server.model.Identifier) ByteBuffer(java.nio.ByteBuffer) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) Test(org.junit.Test)

Example 19 with Identifier

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);
}
Also used : Path(java.nio.file.Path) Identifier(com.cinchapi.concourse.server.model.Identifier) ByteBuffer(java.nio.ByteBuffer) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) Test(org.junit.Test)

Example 20 with Identifier

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

Aggregations

Identifier (com.cinchapi.concourse.server.model.Identifier)40 Text (com.cinchapi.concourse.server.model.Text)28 Value (com.cinchapi.concourse.server.model.Value)25 Test (org.junit.Test)18 Set (java.util.Set)13 ConcourseBaseTest (com.cinchapi.concourse.test.ConcourseBaseTest)9 LinkedHashSet (java.util.LinkedHashSet)7 ByteBuffer (java.nio.ByteBuffer)6 Path (java.nio.file.Path)6 Write (com.cinchapi.concourse.server.storage.temp.Write)4 List (java.util.List)4 LazyTransformSet (com.cinchapi.common.collect.lazy.LazyTransformSet)3 Position (com.cinchapi.concourse.server.model.Position)3 Action (com.cinchapi.concourse.server.storage.Action)3 Range (com.cinchapi.concourse.server.storage.db.kernel.Manifest.Range)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 NavigableSet (java.util.NavigableSet)3 CoalescableTreeMap (com.cinchapi.common.collect.CoalescableTreeMap)2 Composite (com.cinchapi.concourse.server.io.Composite)2 CorpusRecord (com.cinchapi.concourse.server.storage.db.CorpusRecord)2