public static NodeId create(byte[] b) { return create(b, 0) ; } public static NodeId create(ByteBuffer b) { return create(b, 0) ; }
public static NodeId create(ByteBuffer b) { return create(b, 0) ; }
public static NodeId create(ByteBuffer b, int idx) { long value = b.getLong(idx) ; return create(value) ; } public NodeId(long v) { value = v ;}
public static NodeId create(byte[] b, int idx) { long value = Bytes.getLong(b, idx) ; return create(value) ; }
private final NodeId writeNodeToTable(Node node) { syncNeeded = true ; long x = NodeLib.encodeStore(node, getObjects(), writeBuffer) ; return NodeId.create(x); }
@Override public NodeId allocOffset() { return NodeId.create(getObjects().length()) ; }
public static NodeId getNodeId(Record r, int idx) { return NodeId.create(Bytes.getLong(r.getKey(), idx)); }
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) ; }
public static Tuple<NodeId> tuple(Record r, ColumnMap cMap) { int N = r.getKey().length/SizeOfLong ; NodeId[] nodeIds = new NodeId[N] ; for ( int i = 0 ; i < N ; i++ ) { NodeId id = NodeId.create(r.getKey(), i*SizeOfLong) ; int j = i ; if ( cMap != null ) j = cMap.fetchSlotIdx(i) ; nodeIds[j] = id ; } return TupleFactory.asTuple(nodeIds) ; }
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) ; }
@Test public void nodeId_01() { NodeId nodeId = NodeId.create(37) ; assertEquals(37L, nodeId.getId()) ; }
@Test public void nodeId_01() { NodeId nodeId = NodeId.create(37) ; assertEquals(37L, nodeId.getId()) ; }
@Test public void nodeId_02() { NodeId nodeId = NodeId.create(-1L) ; assertEquals(-1L, nodeId.getId()) ; }
@Test public void nodeId_02() { NodeId nodeId = NodeId.create(-1L) ; assertEquals(-1L, nodeId.getId()) ; }
NodeId id = NodeId.create(r2.getValue(), 0) ; return id ;