Search in sources :

Example 71 with Value

use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.

the class CorpusChunkTest method testCannotInsertInImmutableChunk.

@Override
@Test(expected = IllegalStateException.class)
public void testCannotInsertInImmutableChunk() {
    Text locator = Variables.register("locator", getLocator());
    Value value = Variables.register("value", getStringValue());
    Identifier record = Variables.register("record", getRecord());
    ((CorpusChunk) chunk).insert(locator, value, record, Time.now(), Action.ADD);
    if (chunk.length() <= 0) {
        value = Variables.register("value", getStringValue());
        ((CorpusChunk) chunk).insert(locator, value, record, Time.now(), Action.ADD);
    }
    chunk.transfer(file);
    ((CorpusChunk) chunk).insert(locator, value, record, Time.now(), Action.ADD);
}
Also used : Identifier(com.cinchapi.concourse.server.model.Identifier) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text) Test(org.junit.Test)

Example 72 with Value

use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.

the class CorpusChunkTest method testDataDeduplication.

@Test
public void testDataDeduplication() {
    Text locator1 = Text.wrap("name");
    Text locator2 = Text.wrap("name");
    Value key1 = Value.wrap(Convert.javaToThrift("Fonamey"));
    Value key2 = Value.wrap(Convert.javaToThrift("Fonamey"));
    Identifier value1 = Identifier.of(1);
    Identifier value2 = Identifier.of(1);
    CorpusChunk corpus = (CorpusChunk) chunk;
    corpus.insert(locator2, key2, value2, Time.now(), Action.ADD);
    corpus.insert(locator1, key1, value1, Time.now(), Action.ADD);
    Position position = null;
    Iterator<Revision<Text, Text, Position>> it = corpus.iterator();
    while (it.hasNext()) {
        Revision<Text, Text, Position> revision = it.next();
        if (position == null) {
            position = revision.getValue();
        }
        Assert.assertSame(locator2, revision.getLocator());
        if (revision.getKey().toString().equals("name")) {
            Assert.assertSame(locator2, revision.getKey());
        }
        Assert.assertSame(position, revision.getValue());
    }
}
Also used : Identifier(com.cinchapi.concourse.server.model.Identifier) Revision(com.cinchapi.concourse.server.storage.db.Revision) Position(com.cinchapi.concourse.server.model.Position) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text) Test(org.junit.Test)

Example 73 with Value

use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.

the class CorpusChunkTest method testReproCON_4.

@Test
public void testReproCON_4() {
    // TODO file this in jira
    Text key = Variables.register("key", Text.wrap("strings"));
    Identifier record = Variables.register("record", getRecord());
    Value value = Variables.register("value", Value.wrap(Convert.javaToThrift("aaihwopxetdxrumqlbjwgdsjgs tan rczlfjhyhlwhsr aqzpmquui mmmynpklmctgnonaaafagpjgv augolkz")));
    ((CorpusChunk) chunk).insert(key, value, record, Time.now(), Action.ADD);
    Text term = Variables.register("term", Text.wrap("aa"));
    Variables.register("chunkDump", chunk.dump());
    CorpusRecord searchRecord = CorpusRecord.createPartial(key, term);
    ((CorpusChunk) chunk).seek(Composite.create(key, term), searchRecord);
    Assert.assertTrue(searchRecord.get(term).stream().map(Position::getIdentifier).collect(Collectors.toCollection(LinkedHashSet::new)).contains(record));
}
Also used : Identifier(com.cinchapi.concourse.server.model.Identifier) CorpusRecord(com.cinchapi.concourse.server.storage.db.CorpusRecord) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text) Test(org.junit.Test)

Aggregations

Value (com.cinchapi.concourse.server.model.Value)73 Text (com.cinchapi.concourse.server.model.Text)60 Test (org.junit.Test)43 ConcourseBaseTest (com.cinchapi.concourse.test.ConcourseBaseTest)34 Identifier (com.cinchapi.concourse.server.model.Identifier)25 CountDownLatch (java.util.concurrent.CountDownLatch)22 Set (java.util.Set)14 Operator (com.cinchapi.concourse.thrift.Operator)10 Action (com.cinchapi.concourse.server.storage.Action)6 Range (com.google.common.collect.Range)6 LinkedHashSet (java.util.LinkedHashSet)6 TObject (com.cinchapi.concourse.thrift.TObject)5 LazyTransformSet (com.cinchapi.common.collect.lazy.LazyTransformSet)3 RangeToken (com.cinchapi.concourse.server.concurrent.RangeToken)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 ByteBuffer (java.nio.ByteBuffer)3 Path (java.nio.file.Path)3 NavigableSet (java.util.NavigableSet)3 CoalescableTreeMap (com.cinchapi.common.collect.CoalescableTreeMap)2 Position (com.cinchapi.concourse.server.model.Position)2