public DHT_Active(ActiveRDMA c) { m_c = c; m_dht = new DHT_RDMA(c, N); c.load(DHT_RDMA.class); c.load(DHT_Active_Find.class); c.load(DHT_Active_Get.class); c.load(DHT_Active_Put.class); c.load(DHT_Active_Has.class); }
public boolean has(String key) { byte[] b = key.getBytes(); int[] args = new int[b.length]; for (int i = 0; i < b.length; i++) args[i] = (int) b[i]; return m_c.run(DHT_Active_Has.class, args) != 0; }
public int get(String key) { byte[] b = key.getBytes(); int[] args = new int[b.length]; for (int i = 0; i < b.length; i++) args[i] = (int) b[i]; return m_c.run(DHT_Active_Get.class, args); }
public int[] match(int key, byte[] pattern) { // byte[] b = pattern.getBytes(); int[] args = new int[pattern.length + 1]; args[0] = key; for (int i = 0; i < pattern.length; i++) args[i] = (int) pattern[i]; return m_c.runArray(DHT_Active_Find.class, args); }
public void put(String key, int val) { byte[] b = key.getBytes(); int[] args = new int[b.length + 1]; for (int i = 0; i < b.length; i++) args[i + 1] = (int) b[i]; args[0] = val; m_c.run(DHT_Active_Put.class, args); }
public int getNext(int ptr) { return m_c.r(ptr); }
public int getHead(int bin) { return m_c.r(4 * (N + bin)); }
public String getKey(int ptr) { int len = m_c.r(ptr + 8); byte[] bytes = m_c.readbytes(ptr + 12, len); return new String(bytes); }