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