use of suite.primitive.Bytes in project suite by stupidsing.
the class ImperativeCompilerTest method testTag.
@Test
public void testTag() {
String s = //
"constant optional = (tag ( | 0 struct () | 1 int));" + //
"declare optional i = newt optional 0 new ();" + //
"declare optional j = newt optional 1 2;" + "0";
Bytes bytes = imperativeCompiler.compile(0, s);
assertNotNull(bytes);
System.out.println(bytes);
}
use of suite.primitive.Bytes in project suite by stupidsing.
the class ImperativeCompilerTest method testSubroutine.
@Test
public void testSubroutine() {
Bytes bytes = imperativeCompiler.compile(0, "declare s = function [i,] ( i; ); declare s1 = s; s1 [1,];");
assertNotNull(bytes);
System.out.println(bytes);
}
use of suite.primitive.Bytes in project suite by stupidsing.
the class ImperativeCompilerTest method testExpr.
@Test
public void testExpr() {
Bytes bytes = imperativeCompiler.compile(0, "null/* + 1 = 2;");
assertNotNull(bytes);
System.out.println(bytes);
}
use of suite.primitive.Bytes in project suite by stupidsing.
the class SerializedStoreCache method get.
public V get(K key, Source<V> source) {
Bytes keyBytes = serialize(keySerializer, key);
Bytes valueBytes = storeCache.get(keyBytes, () -> serialize(valueSerializer, source.source()));
return Rethrow.ex(() -> {
try (ByteArrayInputStream bais = new ByteArrayInputStream(valueBytes.toArray());
DataInput_ dis = DataInput_.of(bais)) {
return valueSerializer.read(dis);
}
});
}
use of suite.primitive.Bytes in project suite by stupidsing.
the class To method inputStream.
public static InputStream inputStream(Outlet<Bytes> outlet) {
return new InputStream() {
private InputStream is;
private boolean isOpen = true;
public int read() throws IOException {
byte[] b = new byte[1];
int nBytesRead = read(b, 0, 1);
return 0 < nBytesRead ? b[0] : nBytesRead;
}
public int read(byte[] bs, int offset, int length) throws IOException {
int nBytesRead = -1;
while (is == null || (nBytesRead = is.read(bs, offset, length)) < 0) {
Bytes bytes = outlet.next();
if (isOpen = (bytes != null))
is = bytes.collect(As::inputStream);
else
break;
}
return nBytesRead;
}
public void close() throws IOException {
if (isOpen) {
byte[] bs = new byte[Constants.bufferSize];
while (0 <= read(bs, 0, bs.length)) ;
}
}
};
}
Aggregations