Search in sources :

Example 36 with Identifier

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

the class SimilarityCompactorTest method testSanityCheck.

@Test
public void testSanityCheck() {
    SegmentStorageSystem storage = CompactorTests.getStorageSystem();
    Segment a = Segment.create();
    a.acquire(Write.add("name", Convert.javaToThrift("jeff"), 1));
    a.acquire(Write.add("name", Convert.javaToThrift("ashleah"), 2));
    a.acquire(Write.add("age", Convert.javaToThrift(33), 2));
    a.acquire(Write.add("company", Convert.javaToThrift("Cinchapi"), 1));
    a.transfer(Paths.get(TestData.getTemporaryTestFile()));
    Segment b = Segment.create();
    b.acquire(Write.add("name", Convert.javaToThrift("Jeff"), 1));
    b.acquire(Write.remove("name", Convert.javaToThrift("jeff"), 1));
    b.acquire(Write.remove("name", Convert.javaToThrift("ashleah"), 2));
    b.acquire(Write.add("name", Convert.javaToThrift("Jeffery"), 1));
    b.acquire(Write.add("company", Convert.javaToThrift("Know Full Well"), 2));
    b.acquire(Write.add("age", Convert.javaToThrift(33), 1));
    b.acquire(Write.add("age", Convert.javaToThrift(33.0), 1));
    b.transfer(Paths.get(TestData.getTemporaryTestFile()));
    storage.segments().add(a);
    storage.segments().add(b);
    // seg0
    storage.segments().add(Segment.create());
    SimilarityCompactor compactor = new SimilarityCompactor(storage);
    compactor.minimumSimilarityThreshold(0);
    List<Write> expected = storage.segments().stream().flatMap(segment -> segment.writes()).collect(Collectors.toList());
    compactor.executeFullCompaction();
    List<Write> actual = storage.segments().stream().flatMap(segment -> segment.writes()).collect(Collectors.toList());
    Assert.assertEquals(2, storage.segments().size());
    Assert.assertTrue(expected.size() == actual.size() && expected.containsAll(actual) && // assert that no data
    actual.containsAll(expected));
    // lost...
    actual.forEach(System.out::println);
    for (int i = 0; i < actual.size(); ++i) {
        if (i > 0) {
            Identifier previous = actual.get(i - 1).getRecord();
            Identifier current = actual.get(i).getRecord();
            // Assert that, from table view, all records are grouped
            // together
            Assert.assertTrue(current.longValue() == previous.longValue() || current.longValue() == previous.longValue() + 1);
        }
    }
    Assert.assertEquals(ImmutableList.of(a, b), compactor.garbage());
}
Also used : Write(com.cinchapi.concourse.server.storage.temp.Write) CompactorTests(com.cinchapi.concourse.server.storage.db.compaction.CompactorTests) TestData(com.cinchapi.concourse.util.TestData) Test(org.junit.Test) SegmentStorageSystem(com.cinchapi.concourse.server.storage.db.SegmentStorageSystem) Write(com.cinchapi.concourse.server.storage.temp.Write) Collectors(java.util.stream.Collectors) Segment(com.cinchapi.concourse.server.storage.db.kernel.Segment) List(java.util.List) Identifier(com.cinchapi.concourse.server.model.Identifier) ImmutableList(com.google.common.collect.ImmutableList) Paths(java.nio.file.Paths) Convert(com.cinchapi.concourse.util.Convert) Assert(org.junit.Assert) Identifier(com.cinchapi.concourse.server.model.Identifier) SegmentStorageSystem(com.cinchapi.concourse.server.storage.db.SegmentStorageSystem) Segment(com.cinchapi.concourse.server.storage.db.kernel.Segment) Test(org.junit.Test)

Example 37 with Identifier

use of com.cinchapi.concourse.server.model.Identifier 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 38 with Identifier

use of com.cinchapi.concourse.server.model.Identifier 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 39 with Identifier

use of com.cinchapi.concourse.server.model.Identifier 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)

Example 40 with Identifier

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

the class IndexRecordTest method testCaseInsensitiveValuesNotLost.

@Test
public void testCaseInsensitiveValuesNotLost() {
    Text locator = Text.wrap("major");
    record = getRecord(locator);
    record.append(getRevision(locator, Value.wrap(Convert.javaToThrift("Business Management")), Identifier.of(1)));
    record.append(getRevision(locator, Value.wrap(Convert.javaToThrift("business management")), Identifier.of(2)));
    IndexRecord index = (IndexRecord) record;
    Map<Identifier, Set<Value>> data = index.findAndGet(Operator.REGEX, Value.wrap(Convert.javaToThrift(".*business.*")));
    Assert.assertFalse(data.isEmpty());
}
Also used : Identifier(com.cinchapi.concourse.server.model.Identifier) Set(java.util.Set) Text(com.cinchapi.concourse.server.model.Text) Test(org.junit.Test)

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