/** * Read and decode a {@link Node} from the {@link ObjectFile}. The {@code id} must * have originally been generated by {@link #encodeStore}. */ public static Node fetchDecode(long id, ObjectFile file) { ByteBuffer bb = file.read(id); if ( bb == null ) return null; return decode(bb); }
@Test public void test_04() { // see: http://www.unicode.org/charts/PDF/UD800.pdf String s = "\uDAE0"; Node literal = NodeFactory.createLiteral(s); ByteBuffer bb = NodeLib.encode(literal); NodeLib.decode(bb); }
private Iterator<Pair<NodeId, Node>> all2() { Iterator<Pair<Long, ByteBuffer>> objs = objects.all() ; Function<Pair<Long, ByteBuffer>, Pair<NodeId, Node>> transform = item -> { NodeId id = NodeId.create(item.car().longValue()); ByteBuffer bb = item.cdr(); Node n = NodeLib.decode(bb); return new Pair<>(id, n); }; return Iter.map(objs, transform) ; }
private static Iterator<Pair<NodeId, Node>> all(ObjectFile objFile) { Iterator<Pair<Long, ByteBuffer>> objs = objFile.all() ; Function<Pair<Long, ByteBuffer>, Pair<NodeId, Node>> transform = item -> { NodeId id = NodeId.create(item.car().longValue()); ByteBuffer bb = item.cdr(); Node n = NodeLib.decode(bb); return new Pair<>(id, n); }; return Iter.map(objs, transform) ; }
private static Iterator<Pair<NodeId, Node>> all(ObjectFile objFile) { Iterator<Pair<Long, ByteBuffer>> objs = objFile.all() ; Function<Pair<Long, ByteBuffer>, Pair<NodeId, Node>> transform = item -> { NodeId id = NodeId.create(item.car().longValue()); ByteBuffer bb = item.cdr(); Node n = NodeLib.decode(bb); return new Pair<>(id, n); }; return Iter.map(objs, transform) ; }