Search in sources :

Example 11 with Text

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

the class AtomicOperation method browse.

@Override
public final Map<TObject, Set<Long>> browse(String key) throws AtomicStateException {
    checkState();
    Text key0 = Text.wrapCached(key);
    RangeToken rangeToken = RangeToken.forReading(key0, Operator.BETWEEN, Value.NEGATIVE_INFINITY, Value.POSITIVE_INFINITY);
    source.addVersionChangeListener(rangeToken, this);
    Iterable<Range<Value>> ranges = RangeTokens.convertToRange(rangeToken);
    for (Range<Value> range : ranges) {
        rangeReads2Lock.put(key0, range);
    }
    return super.browse(key);
}
Also used : RangeToken(com.cinchapi.concourse.server.concurrent.RangeToken) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text) Range(com.google.common.collect.Range)

Example 12 with Text

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

the class AtomicOperation method explore.

@Override
public Map<Long, Set<TObject>> explore(String key, Aliases aliases) {
    checkState();
    Operator operator = aliases.operator();
    TObject[] values = aliases.values();
    Text key0 = Text.wrapCached(key);
    RangeToken rangeToken = RangeToken.forReading(key0, operator, Transformers.transformArray(values, Value::wrap, Value.class));
    source.addVersionChangeListener(rangeToken, this);
    Iterable<Range<Value>> ranges = RangeTokens.convertToRange(rangeToken);
    for (Range<Value> range : ranges) {
        rangeReads2Lock.put(key0, range);
    }
    return super.explore(key, aliases);
}
Also used : Operator(com.cinchapi.concourse.thrift.Operator) TObject(com.cinchapi.concourse.thrift.TObject) RangeToken(com.cinchapi.concourse.server.concurrent.RangeToken) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text) Range(com.google.common.collect.Range)

Example 13 with Text

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

the class TableChunkTest method testInsertLocatorWithTrailingWhiteSpace.

@Test
public void testInsertLocatorWithTrailingWhiteSpace() {
    Identifier locator = Identifier.of(1);
    Text key = Text.wrap("Youtube Embed Link ");
    Value value = Value.wrap(Convert.javaToThrift("http://youtube.com"));
    chunk.insert(locator, key, value, Time.now(), Action.ADD);
    TableRecord record = TableRecord.createPartial(locator, key);
    chunk.transfer(file);
    chunk = load(file, filter, chunk.manifest());
    chunk.seek(Composite.create(locator, key), record);
    Assert.assertTrue(record.get(key).contains(value));
}
Also used : Identifier(com.cinchapi.concourse.server.model.Identifier) Value(com.cinchapi.concourse.server.model.Value) Text(com.cinchapi.concourse.server.model.Text) TableRecord(com.cinchapi.concourse.server.storage.db.TableRecord) Test(org.junit.Test)

Example 14 with Text

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

the class OffHeapTextSetTest method testContains.

@Test
public void testContains() {
    List<String> corpus = new ArrayList<>();
    for (int i = 0; i < 5 * TestData.getScaleCount(); ++i) {
        corpus.add(Random.getString());
    }
    Set<Text> ohts = OffHeapTextSet.test();
    Set<Text> control = new HashSet<>();
    Iterator<String> it = corpus.iterator();
    while (it.hasNext()) {
        Text string = Text.wrap(it.next());
        if (TestData.getScaleCount() % 3 == 0) {
            control.add(string);
            ohts.add(string);
        }
    }
    it = corpus.iterator();
    while (it.hasNext()) {
        Text string = Text.wrap(it.next());
        Assert.assertEquals(control.contains(string), ohts.contains(string));
    }
}
Also used : ArrayList(java.util.ArrayList) Text(com.cinchapi.concourse.server.model.Text) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 15 with Text

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

the class OffHeapTextSetTest method testAdd.

@Test
public void testAdd() {
    List<String> corpus = new ArrayList<>();
    for (int i = 0; i < 5 * TestData.getScaleCount(); ++i) {
        corpus.add(Random.getString());
    }
    Set<Text> ohts = OffHeapTextSet.test();
    Set<Text> control = new HashSet<>();
    Iterator<String> it = corpus.iterator();
    while (it.hasNext()) {
        Text string = Text.wrap(it.next());
        if (TestData.getScaleCount() % 3 == 0) {
            control.add(string);
            ohts.add(string);
        }
    }
    it = corpus.iterator();
    while (it.hasNext()) {
        Text string = Text.wrap(it.next());
        if (TestData.getScaleCount() % 2 == 0) {
            Assert.assertEquals(control.add(string), ohts.add(string));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Text(com.cinchapi.concourse.server.model.Text) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Text (com.cinchapi.concourse.server.model.Text)70 Value (com.cinchapi.concourse.server.model.Value)60 Test (org.junit.Test)46 ConcourseBaseTest (com.cinchapi.concourse.test.ConcourseBaseTest)34 Identifier (com.cinchapi.concourse.server.model.Identifier)28 CountDownLatch (java.util.concurrent.CountDownLatch)22 Set (java.util.Set)10 Operator (com.cinchapi.concourse.thrift.Operator)8 LinkedHashSet (java.util.LinkedHashSet)8 Position (com.cinchapi.concourse.server.model.Position)6 TObject (com.cinchapi.concourse.thrift.TObject)6 Action (com.cinchapi.concourse.server.storage.Action)4 Write (com.cinchapi.concourse.server.storage.temp.Write)4 RangeToken (com.cinchapi.concourse.server.concurrent.RangeToken)3 Composite (com.cinchapi.concourse.server.io.Composite)3 Revision (com.cinchapi.concourse.server.storage.db.Revision)3 Range (com.google.common.collect.Range)3 Path (java.nio.file.Path)3 AwaitableExecutorService (com.cinchapi.concourse.server.concurrent.AwaitableExecutorService)2 CorpusRecord (com.cinchapi.concourse.server.storage.db.CorpusRecord)2