use of com.cinchapi.concourse.util.Convert.ResolvableLink in project concourse by cinchapi.
the class ConvertTest method testConvertResolvableLinkWithNumbers.
@Test
public void testConvertResolvableLinkWithNumbers() {
String key = Random.getNumber().toString();
String value = Random.getNumber().toString();
String ccl = AnyStrings.joinWithSpace(key, "=", value);
ResolvableLink link = (ResolvableLink) Convert.stringToJava(Convert.stringToResolvableLinkInstruction(ccl));
Assert.assertEquals(ccl, link.getCcl());
}
use of com.cinchapi.concourse.util.Convert.ResolvableLink in project concourse by cinchapi.
the class Operations method insertDeferredAtomic.
/**
* Atomically insert a list of {@link DeferredWrite deferred writes}. This
* method should only be called after all necessary calls to
* {@link #insertAtomic(Multimap, long, AtomicOperation, List)} have been
* made.
*
* @param parser
* @param deferred
* @param atomic
* @return {@code true} if all the writes are successful
*/
public static boolean insertDeferredAtomic(List<DeferredWrite> deferred, AtomicOperation atomic) {
// have already been checked
for (DeferredWrite write : deferred) {
if (write.getValue() instanceof ResolvableLink) {
ResolvableLink rlink = (ResolvableLink) write.getValue();
AbstractSyntaxTree ast = ConcourseCompiler.get().parse(rlink.getCcl());
Set<Long> targets = ast.accept(Finder.instance(), atomic);
for (long target : targets) {
if (target == write.getRecord()) {
// accidentally creates self links.
continue;
}
TObject link = Convert.javaToThrift(Link.to(target));
if (!atomic.add(write.getKey(), link, write.getRecord())) {
return false;
}
}
} else if (!atomic.add(write.getKey(), Convert.javaToThrift(write.getValue()), write.getRecord())) {
return false;
}
}
return true;
}
use of com.cinchapi.concourse.util.Convert.ResolvableLink in project concourse by cinchapi.
the class ConvertTest method testConvertResolvableLink.
@Test
public void testConvertResolvableLink() {
String key = Random.getString().replace(" ", "");
String value = Random.getObject().toString().replace(" ", "");
String ccl = AnyStrings.joinWithSpace(key, "=", value);
ResolvableLink link = (ResolvableLink) Convert.stringToJava(Convert.stringToResolvableLinkInstruction(ccl));
Assert.assertEquals(ccl, link.getCcl());
}
Aggregations