@Test(expected = Test.None.class) public void test() throws IOException { System.out.println("SNLSH"); SNLSH<String[], String> lsh = createLSH(texts); ArrayList<Neighbor<String[], String>> neighbors = new ArrayList<>(); lsh.range(tokenize(texts[0]), 3, neighbors); assertEquals(2, neighbors.size()); assertEquals(0, neighbors.get(0).index); assertEquals(1, neighbors.get(1).index); neighbors.clear(); lsh.range(tokenize(texts[1]), 3, neighbors); assertEquals(2, neighbors.size()); assertEquals(0, neighbors.get(0).index); assertEquals(1, neighbors.get(1).index); neighbors.clear(); lsh.range(tokenize(texts[2]), 3, neighbors); assertEquals(1, neighbors.size()); assertEquals(2, neighbors.get(0).index); neighbors.clear(); lsh.range(tokenize(texts[3]), 3, neighbors); assertEquals(1, neighbors.size()); assertEquals(3, neighbors.get(0).index); }
@Override public void range(K q, double radius, List<Neighbor<K, V>> neighbors) { if (radius <= 0 || radius != (int) radius) { throw new IllegalArgumentException("The parameter radius has to be an integer: " + radius); } long fpq = simhash.hash(q); Set<Integer> candidates = getCandidates(q); for (int index : candidates) { int distance = HammingDistance.d(fpq, signatures.get(index)); if (distance <= radius) { neighbors.add(new Neighbor<>(keys.get(index), data.get(index), index, distance)); } } }
SNLSH implements RNNSearch<K, V>, Serializable { @Override public void range(K q, double radius, List<Neighbor<K, V>> neighbors) { if (radius <= 0 || radius != (int) radius) { throw new IllegalArgumentException("The parameter radius has to be an integer: " + radius); } long fpq = simhash.hash(q); Set<Integer> candidates = getCandidates(q); for (int index : candidates) { int distance = HammingDistance.d(fpq, signatures.get(index)); if (distance <= radius) { neighbors.add(new Neighbor<>(keys.get(index), data.get(index), index, distance)); } } } }
SNLSH implements RNNSearch<K, V>, Serializable { @Override public void range(K q, double radius, List<Neighbor<K, V>> neighbors) { if (radius <= 0 || radius != (int) radius) { throw new IllegalArgumentException("The parameter radius has to be an integer: " + radius); } long fpq = simhash.hash(q); Set<Integer> candidates = getCandidates(q); for (int index : candidates) { int distance = HammingDistance.d(fpq, signatures.get(index)); if (distance <= radius) { neighbors.add(new Neighbor<>(keys.get(index), data.get(index), index, distance)); } } } @SuppressWarnings("unchecked")  SNLSH(int L, SimHash<K> hash); }
SNLSH implements RNNSearch<K, V>, Serializable { @Override public void range(K q, double radius, List<Neighbor<K, V>> neighbors) { if (radius <= 0 || radius != (int) radius) { throw new IllegalArgumentException("The parameter radius has to be an integer: " + radius); } long fpq = simhash.hash(q); Set<Integer> candidates = getCandidates(q); for (int index : candidates) { int distance = HammingDistance.d(fpq, signatures.get(index)); if (distance <= radius) { neighbors.add(new Neighbor<>(keys.get(index), data.get(index), index, distance)); } } } @SuppressWarnings("unchecked")  SNLSH(int L, SimHash<K> hash); void put(K k, V v); @Override void range(K q, double radius, List<Neighbor<K, V>> neighbors); }
SNLSH implements RNNSearch<K, V>, Serializable { @Override public void range(K q, double radius, List<Neighbor<K, V>> neighbors) { if (radius <= 0 || radius != (int) radius) { throw new IllegalArgumentException("The parameter radius has to be an integer: " + radius); } long fpq = simhash.hash(q); Set<Integer> candidates = getCandidates(q); for (int index : candidates) { int distance = HammingDistance.d(fpq, signatures.get(index)); if (distance <= radius) { neighbors.add(new Neighbor<>(keys.get(index), data.get(index), index, distance)); } } } @SuppressWarnings("unchecked")  SNLSH(int L, SimHash<K> hash); void put(K k, V v); @Override void range(K q, double radius, List<Neighbor<K, V>> neighbors);  }