use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.
the class CorpusChunkTest method testMightContainLocatorKeyValueReproA.
@Test
public void testMightContainLocatorKeyValueReproA() {
Value value = null;
Text term = null;
int position = 0;
while (term == null) {
value = Value.wrap(Convert.javaToThrift("l z15zses"));
position = 0;
for (String string : value.getObject().toString().split(TStrings.REGEX_GROUP_OF_ONE_OR_MORE_WHITESPACE_CHARS)) {
if (!GlobalState.STOPWORDS.contains(string) && !Strings.isNullOrEmpty(string)) {
term = Text.wrap(string);
break;
} else {
position++;
continue;
}
}
}
doTestMightContainLocatorKeyValue(getLocator(), value, term, getRecord(), position);
}
use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.
the class Write method fromByteBuffer.
/**
* Return the Write encoded in {@code bytes} so long as those bytes adhere
* to the format specified by the {@link #getBytes()} method. This method
* assumes that all the bytes in the {@code bytes} belong to the Value. In
* general, it is necessary to get the appropriate Write slice from the
* parent ByteBuffer using {@link ByteBuffers#slice(ByteBuffer, int, int)}.
*
* @param bytes
* @return the Value
*/
public static Write fromByteBuffer(ByteBuffer bytes) {
int keySize = bytes.getInt();
Action type = Action.values()[bytes.get()];
long version = bytes.getLong();
Identifier record = Identifier.fromByteBuffer(ByteBuffers.get(bytes, Identifier.SIZE));
Text key = Text.fromByteBuffer(ByteBuffers.get(bytes, keySize));
Value value = Value.fromByteBuffer(ByteBuffers.get(bytes, bytes.remaining()));
return new Write(type, key, value, record, version);
}
use of com.cinchapi.concourse.server.model.Value in project concourse by cinchapi.
the class RangeLockServiceTest method testWriteLtLowerValueIsNotRangeBlockedIfReadingBw.
@Test
public void testWriteLtLowerValueIsNotRangeBlockedIfReadingBw() throws InterruptedException {
final Text key = Variables.register("key", TestData.getText());
final Value value1 = Variables.register("value1", TestData.getValue());
final Value value2 = Variables.register("value2", increase(value1));
final CountDownLatch startLatch = new CountDownLatch(1);
final CountDownLatch finishLatch = new CountDownLatch(1);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
rangeLockService.getReadLock(key, Operator.BETWEEN, value1, value2).lock();
startLatch.countDown();
try {
finishLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
rangeLockService.getReadLock(key, Operator.BETWEEN, value1, value2).unlock();
}
});
t.start();
startLatch.await();
Value value3 = Variables.register("value3", decrease(value1));
Assert.assertFalse(rangeLockService.isRangeBlocked(LockType.WRITE, RangeToken.forReading(key, null, value3)));
finishLatch.countDown();
}
use of com.cinchapi.concourse.server.model.Value 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));
}
}
}
use of com.cinchapi.concourse.server.model.Value 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++;
}
}
Aggregations