use of suite.primitive.Bytes in project suite by stupidsing.
the class FailedTests method testDataStructure.
// cannot capture reference to a structure
@Test
public void testDataStructure() {
Bytes bytes = new ImperativeCompiler().compile(0, //
"" + //
"constant p = fix :p struct (() | pointer::p +next);" + //
"declare r = & new p (+next = null,);" + "0");
assertNotNull(bytes);
System.out.println(bytes);
}
use of suite.primitive.Bytes in project suite by stupidsing.
the class B_TreeTest method testInsertPerformance.
@Test
public void testInsertPerformance() throws IOException {
int nKeys = 16384;
keys = Ints_.toArray(nKeys, i -> i);
int pageSize = 4096;
Path path = Constants.tmp("b_tree-file");
for (int i = 0; i < nKeys; i++) {
int j = random.nextInt(nKeys);
Integer temp = keys[i];
keys[i] = keys[j];
keys[j] = temp;
}
Files.deleteIfExists(path);
B_TreeBuilder<Integer, Bytes> builder = new B_TreeBuilder<>(serialize.int_, serialize.bytes(64));
try (JournalledPageFile jpf = JournalledFileFactory.journalled(path, pageSize);
B_Tree<Integer, Bytes> b_tree = builder.build(jpf, comparator, 9999)) {
new Profiler().profile(() -> {
b_tree.create();
for (int i = 0; i < nKeys; i++) {
int key = keys[i];
b_tree.put(key, To.bytes(Integer.toString(key)));
}
jpf.commit();
jpf.sync();
});
}
}
use of suite.primitive.Bytes in project suite by stupidsing.
the class FileSystemTest method testWriteOneFile.
private void testWriteOneFile(FileSystem fs) {
Bytes filename = To.bytes("file");
Bytes data = To.bytes("data");
FileSystemMutator fsm = fs.mutate();
fsm.replace(filename, data);
assertEquals(1, fsm.list(filename, null).size());
assertEquals(data, fsm.read(filename));
fsm.replace(filename, null);
assertEquals(0, fsm.list(filename, null).size());
}
use of suite.primitive.Bytes in project suite by stupidsing.
the class FileSystemTest method testWriteFiles.
private void testWriteFiles(FileSystem fs) throws IOException {
Streamlet<Path> paths = FileUtil.findPaths(Paths.get("src/test/java/"));
FileSystemMutator fsm = fs.mutate();
for (Path path : paths) {
String filename = path.toString().replace(File.separatorChar, '/');
Bytes name = Bytes.of(filename.getBytes(Constants.charset));
fsm.replace(name, Bytes.of(Files.readAllBytes(path)));
}
}
use of suite.primitive.Bytes in project suite by stupidsing.
the class FileSystemTest method testReadFile.
private void testReadFile(FileSystem fs) throws IOException {
String filename = "src/test/java/suite/fs/FileSystemTest.java";
FileSystemMutator fsm = fs.mutate();
Bytes name = Bytes.of(filename.getBytes(Constants.charset));
Copy.stream(fsm.read(name).collect(As::inputStream), System.out);
}
Aggregations