Package org.apache.hadoop.util.bloom

Examples of org.apache.hadoop.util.bloom.Key


      }
    }

    @Override
    public boolean accept(Pair<K, V> input) {
      Key key = new Key(keyToBytesFn.map(input.first()));
      return bloomFilter.membershipTest(key);
    }
View Full Code Here


   * Adds an int to the bloom filter.
   */
  public void addInt(int i) {
    ByteBuffer buf = ByteBuffer.allocate(4);
    buf.putInt(i);
    Key k = new Key(buf.array());
    bloom.add(k);
  }
View Full Code Here

          } catch (URISyntaxException e) {
          }
          builder = new StringBuilder();
          value = builder.append("<").append(value).append(">").toString(); //String builder
          uriSet.add(value);
          uris.add(new Key(value.getBytes(UTF8_CHARSET)));
        }
      }
    }
    Set<String> maps = new HashSet<String>();
    Map<String, String> bloomfilterMapping = new HashMap<String, String>();
View Full Code Here

            }
          } catch (URISyntaxException e) {
          }
          value = builder.append("<").append(value).append(">").toString(); //String builder
          uriSet.add(value);
          uris.add(new Key(value.getBytes(UTF8_CHARSET)));
        }
      }
    }
    Set<String> maps = new HashSet<String>();
    Map<String, String> bloomfilterMapping = new HashMap<String, String>();
View Full Code Here

    try {

      KR2RMLBloomFilterManager peopleBloomFilterManager = getBloomFilterManagerForSource("people.json", InputType.JSON, "people-model");
      KR2RMLBloomFilterManager scheduleBloomFilterManager = getBloomFilterManagerForSource("schedule.csv", InputType.CSV, "schedule-model");
      KR2RMLBloomFilter peoplePersonWithTwitterIdBF = peopleBloomFilterManager.getBloomFilter("http://isi.edu/integration/karma/dev#PredicateObjectMap_5fcf2d39-f62b-4cdd-863e-bde21493e1bd");
      Key k = new Key(("<http://lod.isi.edu/cs548/person/Slepicka>").getBytes());
      assertFalse(peoplePersonWithTwitterIdBF.membershipTest(k));
      k = new Key(("<http://lod.isi.edu/cs548/person/Taheriyan>").getBytes());
      assertTrue(peoplePersonWithTwitterIdBF.membershipTest(k));
      k = new Key(("<http://lod.isi.edu/cs548/person/Kozareva>").getBytes());
      assertFalse(peoplePersonWithTwitterIdBF.membershipTest(k));
      k = new Key(("<http://lod.isi.edu/cs548/person/Ambite>").getBytes());
      assertFalse(peoplePersonWithTwitterIdBF.membershipTest(k));
      k = new Key(("<http://lod.isi.edu/cs548/person/Szekely>").getBytes());
      assertTrue(peoplePersonWithTwitterIdBF.membershipTest(k));
      k = new Key(("<http://lod.isi.edu/cs548/person/Knoblock>").getBytes());
      assertTrue(peoplePersonWithTwitterIdBF.membershipTest(k));
      k = new Key(("<http://lod.isi.edu/cs548/person/Wu>").getBytes());
      assertFalse(peoplePersonWithTwitterIdBF.membershipTest(k));
      assertEquals(3, peoplePersonWithTwitterIdBF.estimateNumberOfHashedValues());
      KR2RMLBloomFilter schedulePersonBF = scheduleBloomFilterManager.getBloomFilter("http://isi.edu/integration/karma/dev#TriplesMap_413a6176-d893-45aa-b1c2-6661b5c491ab");
      k = new Key(("<http://lod.isi.edu/cs548/person/Slepicka>").getBytes());
      assertTrue(schedulePersonBF.membershipTest(k));
      k = new Key(("<http://lod.isi.edu/cs548/person/Taheriyan>").getBytes());
      assertTrue(schedulePersonBF.membershipTest(k));
      k = new Key(("<http://lod.isi.edu/cs548/person/Ambite>").getBytes());
      assertTrue(schedulePersonBF.membershipTest(k));
      k = new Key(("<http://lod.isi.edu/cs548/person/Szekely>").getBytes());
      assertTrue(schedulePersonBF.membershipTest(k));
      k = new Key(("<http://lod.isi.edu/cs548/person/Knoblock>").getBytes());
      assertTrue(schedulePersonBF.membershipTest(k));
      assertEquals(5, schedulePersonBF.estimateNumberOfHashedValues());
     
      KR2RMLBloomFilter intersectionBF = new KR2RMLBloomFilter(KR2RMLBloomFilter.defaultVectorSize, KR2RMLBloomFilter.defaultnbHash, Hash.JENKINS_HASH);
      intersectionBF.or(peoplePersonWithTwitterIdBF);
      intersectionBF.and(schedulePersonBF);
      assertEquals(3, intersectionBF.estimateNumberOfHashedValues());
     
      KR2RMLBloomFilter hasInstructorBF = scheduleBloomFilterManager.getBloomFilter("http://isi.edu/integration/karma/dev#RefObjectMap_bb82f923-2953-4bd4-bc7b-d1196e05dbf6");
     
      k = new Key(("<http://lod.isi.edu/cs548/person/Szekely>").getBytes());
      assertTrue(hasInstructorBF.membershipTest(k));
      intersectionBF = new KR2RMLBloomFilter(KR2RMLBloomFilter.defaultVectorSize, KR2RMLBloomFilter.defaultnbHash, Hash.JENKINS_HASH);
      intersectionBF.or(hasInstructorBF);
      intersectionBF.and(peoplePersonWithTwitterIdBF);
      assertEquals(3, intersectionBF.estimateNumberOfHashedValues());
View Full Code Here

    {
      idToBloomFilter.putIfAbsent(id, new KR2RMLBloomFilter(KR2RMLBloomFilter.defaultVectorSize, KR2RMLBloomFilter.defaultnbHash, Hash.JENKINS_HASH));
    }
    bf = idToBloomFilter.get(id);
   
    Key k = new Key(uri.getBytes(UTF8_CHARSET));
    bf.add(k);
    return;
  }
View Full Code Here

      Statement st = iterator.next();
      String subject = "<" + st.getSubject().toString() + ">";
      String object = "<" + st.getObject().toString() + ">";
      for (Entry<String, KR2RMLBloomFilter> entry : mapping.entrySet()) {
        KR2RMLBloomFilter bf = entry.getValue();
        if (bf.membershipTest(new Key(subject.getBytes("UTF-8"))))
          bf.add(new Key(object.getBytes("UTF-8")));
        if (bf.membershipTest(new Key(object.getBytes("UTF-8"))))
          bf.add(new Key(subject.getBytes("UTF-8")));
      }
    }
   
    utilObj.updateTripleStoreWithBloomFilters(mapping, serializedmapping, triplestoreURL, null);
   
View Full Code Here

      @Override
      public Collection<Key> generateKeys(String input) {
        List<String> parts = Arrays.asList(StringUtils.split(input, " "));
        Collection<Key> keys = new HashSet<Key>();
        for (String stringpart : parts) {
          keys.add(new Key(stringpart.getBytes()));
        }
        return keys;
      }
    };
    Map<String, BloomFilter> filterValues = BloomFilterFactory.createFilter(new Path(inputPath), filterFn).getValue();
    assertEquals(1, filterValues.size());
    BloomFilter filter = filterValues.get("shakes.txt");
    assertTrue(filter.membershipTest(new Key("Mcbeth".getBytes())));
    assertTrue(filter.membershipTest(new Key("apples".getBytes())));
  }
View Full Code Here

    public void close() throws IOException {
      if (collector!=null) {
        collector.collect(nullKey, bloomFilter);
      }
      System.err.println("TESTTTTTTTTTTTTTTT [organizations elsewhere] "+
          bloomFilter.membershipTest(new Key("organizations elsewhere".getBytes())));
      super.close();
    }
View Full Code Here

        this.collector = collector;
      }     
          
      byte[] buff = new byte[key.getLength()];
      System.arraycopy(key.getBytes(), 0, buff, 0, buff.length);
      bloomFilter.add(new Key(buff, value.get()));
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.util.bloom.Key

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.