Search in sources :

Example 1 with Bloom

use of com.xrtb.blocks.Bloom in project XRTB by benmfaul.

the class TestBloom method testBloom.

/**
	   * Test a valid bid response.
	   * @throws Exception on networking errors.
	   */
@Test
public void testBloom() throws Exception {
    new Bloom("$test", "data/c1x_cookies.csv");
    BloomFilter b = (BloomFilter) LookingGlass.get("$test");
    assertNotNull(b);
    boolean p = b.mightContain("842AAB10FBA04247B3A9CE00C9172350");
    BufferedReader br = new BufferedReader(new FileReader("data/c1x_cookies.csv"));
    String line = null;
    int nP = 0;
    int k = 0;
    while ((line = br.readLine()) != null) {
        p = b.mightContain(line);
        if (p)
            nP++;
        k++;
    }
    assertTrue(k == nP);
}
Also used : Bloom(com.xrtb.blocks.Bloom) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) BloomFilter(com.google.common.hash.BloomFilter) Test(org.junit.Test)

Example 2 with Bloom

use of com.xrtb.blocks.Bloom in project XRTB by benmfaul.

the class Configuration method readData.

public static String readData(String type, String name, S3Object object, long size) throws Exception {
    String message = "";
    switch(type) {
        case "range":
        case "cidr":
            NavMap map = new NavMap(name, object);
            message = "Added NavMap " + name + ": has " + map.size() + " members";
            break;
        case "set":
            SimpleSet set = new SimpleSet(name, object);
            message = "Initialize Set: " + name + " from S3, entries = " + set.size();
            break;
        case "bloom":
            Bloom b = new Bloom(name, object, size);
            message = "Initialize Bloom Filter: " + name + " from S3, members = " + b.getMembers();
            break;
        case "cuckoo":
            Cuckoo c = new Cuckoo(name, object, size);
            message = "Initialize Cuckoo Filter: " + name + " from S3, entries = " + c.getMembers();
            break;
        case "multiset":
            SimpleMultiset ms = new SimpleMultiset(name, object);
            message = "Initialize Multiset " + name + " from S3, entries = " + ms.getMembers();
            break;
        default:
            message = "Unknown type: " + type;
    }
    System.out.println("*** " + message);
    return message;
}
Also used : SimpleSet(com.xrtb.blocks.SimpleSet) Bloom(com.xrtb.blocks.Bloom) SimpleMultiset(com.xrtb.blocks.SimpleMultiset) NavMap(com.xrtb.blocks.NavMap) Cuckoo(com.xrtb.blocks.Cuckoo)

Example 3 with Bloom

use of com.xrtb.blocks.Bloom in project XRTB by benmfaul.

the class Configuration method readData.

public static String readData(String fileName) throws Exception {
    String message = "";
    int i = fileName.indexOf(".");
    if (i == -1)
        throw new Exception("Filename is missing type field");
    String type = fileName.substring(i);
    NavMap map;
    SimpleMultiset set;
    SimpleSet sset;
    Bloom b;
    Cuckoo c;
    switch(type) {
        case "range":
            map = new NavMap(fileName, fileName, false);
            message = "Added NavMap " + fileName + ": from file, has " + map.size() + " members";
            break;
        case "cidr":
            map = new NavMap(fileName, fileName, true);
            message = "Added NavMap " + fileName + ": from file, has " + map.size() + " members";
            break;
        case "bloom":
            b = new Bloom(fileName, fileName);
            message = "Initialize Bloom Filter: " + fileName + " from file, members = " + b.getMembers();
            break;
        case "cuckoo":
            c = new Cuckoo(fileName, fileName);
            break;
        case "multiset":
            set = new SimpleMultiset(fileName, fileName);
            message = "Initialize Multiset " + fileName + " from file, entries = " + set.getMembers();
            break;
        case "set":
            sset = new SimpleSet(fileName, fileName);
            message = "Initialize Multiset " + fileName + " from file, entries = " + sset.size();
            break;
        default:
            message = "Unknown type: " + type;
    }
    System.out.println("*** " + message);
    return message;
}
Also used : SimpleSet(com.xrtb.blocks.SimpleSet) Bloom(com.xrtb.blocks.Bloom) SimpleMultiset(com.xrtb.blocks.SimpleMultiset) NavMap(com.xrtb.blocks.NavMap) Cuckoo(com.xrtb.blocks.Cuckoo)

Aggregations

Bloom (com.xrtb.blocks.Bloom)3 Cuckoo (com.xrtb.blocks.Cuckoo)2 NavMap (com.xrtb.blocks.NavMap)2 SimpleMultiset (com.xrtb.blocks.SimpleMultiset)2 SimpleSet (com.xrtb.blocks.SimpleSet)2 BloomFilter (com.google.common.hash.BloomFilter)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 Test (org.junit.Test)1