private static NodeId create(long v) { return NodeIdFactory.createPtr(v); } }
private static NodeId create(int v1, long v2) { if ( !BitsInt.isSet(v1, 32) ) return createPtrLong(v1, v2); int t = v1 >> 24; NodeIdType type = NodeIdType.intToEnum(t); if ( type == NodeIdType.SPECIAL ) throw new TDBException(String.format("Attempt to create a special from a long: 0x%016", v2)); return createNew(type, 0, v2); }
/** Not relative - get from position zero */ public static NodeId get(byte[] b) { return get(b,0); }
if ( leading ) { leadingIdx = i ; NodeIdFactory.set(X, minRec.getKey(), i*SizeOfNodeId) ; NodeIdFactory.set(X, maxRec.getKey(), i*SizeOfNodeId) ; NodeIdFactory.setNext(X, maxRec.getKey(), leadingIdx*SizeOfNodeId) ; tuples = index.iterator(minRec, maxRec, recordMapper) ; NodeIdFactory.setNext(X, maxRec.getKey(), leadingIdx*SizeOfNodeId) ; iter = index.iterator(minRec, maxRec) ;
@Test public void nodeId_ptr_01() { NodeId nodeId = NodeIdFactory.createPtrLong(17, 37); assertEquals(NodeIdType.PTR, nodeId.type()); // assertEquals(37L, nodeId.getPtrLo()); // assertEquals(17, nodeId.getPtrHi()); assertEquals(37L, nodeId.getValue2()); assertEquals(17, nodeId.getValue1()); }
/** Relative {@code set} */ public static void set(NodeId nodeId, ByteBuffer b) { long v2 = encode(nodeId); b.putLong(v2); }
public static Record record(RecordFactory factory, Tuple<NodeId> tuple, TupleMap tMap) { // Mapping. byte[] b = new byte[tuple.len() * NodeId.SIZE]; for ( int i = 0 ; i < tuple.len() ; i++ ) { int j = tMap.getSlotIdx(i); // i'th Nodeid goes to j'th bytes slot. NodeIdFactory.set(tuple.get(j), b, i * NodeId.SIZE); } return factory.create(b); } }
/** Relative {@code ByteBuffer} {@code get} */ public static NodeId get(ByteBuffer b) { long value2 = b.getLong(); return decode(value2); }
/** Make a NodeId of type and value - the value is assumed to be the right format for the type. */ public static NodeId createValue(NodeIdType type, long value) { return createNew(type, 0, value); }
/*package*/ /*long*/ static NodeId createPtrLong(int hi, long lo) { return create(PTR, hi, lo); }
private static NodeId makeSpecial(long v) { // Careful of an initializer loop (create(type, v1, v2) looks at specials). return NodeIdFactory.createValue(SPECIAL, v); }
private static NodeId decode(long value2) { return NodeIdFactory.create64(value2); }
@Test public void nodeId_ptr_01() { NodeId nodeId = NodeIdFactory.createPtrLong(17, 37); assertEquals(NodeIdType.PTR, nodeId.type()); // assertEquals(37L, nodeId.getPtrLo()); // assertEquals(17, nodeId.getPtrHi()); assertEquals(37L, nodeId.getValue2()); assertEquals(17, nodeId.getValue1()); }
public static void set(NodeId nodeId, ByteBuffer b, int idx) { long v2 = encode(nodeId); b.putLong(idx, v2); }
public static NodeId get(ByteBuffer b, int idx) { long value2 = b.getLong(idx); return decode(value2); }
public static NodeId createPtr(long lo) { return createNew(PTR, 0, lo); }
public static NodeId genUnique() { return NodeIdFactory.create(NodeIdType.SPECIAL, counter.incrementAndGet(), 0); } }