Package cleo.search.connection

Examples of cleo.search.connection.TransitivePartitionConnectionFilter


  protected SelectorFactory<E> createSelectorFactory() {
    return new ScoredElementSelectorFactory<E>();
  }
 
  protected ConnectionFilter createConnectionFilter() {
    return new TransitivePartitionConnectionFilter(new Range(getPartitionStart(), getPartitionCount()));
  }
View Full Code Here


    BloomFilter<Integer> bloomFilter = new FnvBloomFilter(config.getFilterPrefixLength());
   
    // create connectionFilter
    ConnectionFilter connectionFilter = config.getConnectionFilter();
    if(connectionFilter == null) {
      connectionFilter = new TransitivePartitionConnectionFilter(new Range(config.getPartitionStart(), config.getPartitionCount()));
    }
   
    // create NetworkTypeahead
    return new VanillaNetworkTypeahead<E>(config.getName(), elementStore, connectionsStore, selectorFactory, bloomFilter, connectionFilter);
  }
View Full Code Here

    if(selectorFactory == null) selectorFactory = new PrefixSelectorFactory<E>();
   
    // create connectionFilter
    ConnectionFilter connectionFilter = config.getConnectionFilter();
    if(connectionFilter == null) {
      connectionFilter = new TransitivePartitionConnectionFilter(new Range(config.getPartitionStart(), config.getPartitionCount()));
    }
   
    // create WeightedNetworkTypeahead
    return new WeightedNetworkTypeahead<E>(config.getName(), elementStore, weightedConnectionsStore, selectorFactory, bloomFilter, connectionFilter);
  }
View Full Code Here

  protected SelectorFactory<E> createSelectorFactory() {
    return new ScoredPrefixSelectorFactory<E>();
  }
 
  protected ConnectionFilter createConnectionFilter() {
    return new TransitivePartitionConnectionFilter(new Range(getPartitionStart(), getPartitionCount()));
  }
View Full Code Here

    assertEquals(false, connFilter.accept(conn));
  }
 
  public void testTransitivePartitionConnectionFilter() {
    Range range = new Range(3000, 1000); // [3000, 4000)
    ConnectionFilter connFilter = new TransitivePartitionConnectionFilter(range);
    Connection conn;
   
    // Source in range
    conn = new SimpleConnection(3100, 1, true);
    assertEquals(true, connFilter.accept(conn));
   
    conn = new SimpleConnection(3100, 3200, true);
    assertEquals(true, connFilter.accept(conn));

    conn = new SimpleConnection(3100, 5000, true);
    assertEquals(true, connFilter.accept(conn));
   
    // Target in range
    conn = new SimpleConnection(1, 3100, true);
    assertEquals(true, connFilter.accept(conn));

    conn = new SimpleConnection(3200, 3100, true);
    assertEquals(true, connFilter.accept(conn));
   
    conn = new SimpleConnection(5000, 3100, true);
    assertEquals(true, connFilter.accept(conn));
   
    // Neither source nor target in range
    conn = new SimpleConnection(1, 1, true);
    assertEquals(false, connFilter.accept(conn));
   
    conn = new SimpleConnection(1, 5000, true);
    assertEquals(false, connFilter.accept(conn));
  }
View Full Code Here

    int start = rand.nextInt(100000) + 100;
    int count = rand.nextInt(100000) + 100;
    Range range = new Range(start, count);
   
    Connection conn;
    ConnectionFilter connFilter = new TransitivePartitionConnectionFilter(range);
   
    source = range.getStart();
    target = range.getStart();
    conn = new SimpleConnection(source, target, true);
    assertEquals(true, connFilter.accept(conn));

    source = range.getStart();
    target = range.getStart() - rand.nextInt(range.getStart());
    conn = new SimpleConnection(source, target, true);
    assertEquals(true, connFilter.accept(conn));
   
    source = range.getStart();
    target = range.getEnd();
    conn = new SimpleConnection(source, target, true);
    assertEquals(true, connFilter.accept(conn));
   
    source = range.getStart();
    target = range.getEnd() + rand.nextInt(range.getEnd());
    conn = new SimpleConnection(source, target, true);
    assertEquals(true, connFilter.accept(conn));
   
    for(int i = 0, cnt = rand.nextInt(100); i < cnt; i++) {
      source = range.getStart() + rand.nextInt(range.getCount());
      target = Math.abs(rand.nextInt());
      conn = new SimpleConnection(source, target, true);
      assertEquals(true, connFilter.accept(conn));

      source = Math.abs(rand.nextInt());
      target = range.getStart() + rand.nextInt(range.getCount());
      conn = new SimpleConnection(source, target, true);
      assertEquals(true, connFilter.accept(conn));
    }
   
    for(int i = 0, cnt = rand.nextInt(100); i < cnt; i++) {
      source = range.getStart() - rand.nextInt(range.getStart()) - 1;
      target = range.getStart() - rand.nextInt(range.getStart()) - 1;
      conn = new SimpleConnection(source, target, true);
      assertEquals(false, connFilter.accept(conn));
     
      source = range.getStart() - rand.nextInt(range.getStart()) - 1;
      target = range.getEnd() + rand.nextInt(range.getEnd());
      conn = new SimpleConnection(source, target, true);
      assertEquals(false, connFilter.accept(conn));
     
      source = range.getEnd() + rand.nextInt(range.getEnd());
      target = range.getStart() - rand.nextInt(range.getStart()) - 1;
      conn = new SimpleConnection(source, target, true);
      assertEquals(false, connFilter.accept(conn));
     
      source = range.getEnd() + rand.nextInt(range.getEnd());
      target = range.getEnd() + rand.nextInt(range.getEnd());
      conn = new SimpleConnection(source, target, true);
      assertEquals(false, connFilter.accept(conn));
    }
  }
View Full Code Here

    assertTrue(cf2.equals(cf2));
   
    assertEquals(cf1.hashCode(), cf2.hashCode());
   
    // Test TransitivePartionConnectionFilter
    cf1 = new TransitivePartitionConnectionFilter(range);
    cf2 = null;
    assertFalse(cf1.equals(cf2));
   
    cf2 = new TransitivePartitionConnectionFilter(range);
    assertTrue(cf1.equals(cf2));
    assertTrue(cf2.equals(cf1));
   
    assertTrue(cf1.equals(cf1));
    assertTrue(cf2.equals(cf2));
   
    assertEquals(cf1.hashCode(), cf2.hashCode());
   
    // Test cross comparison
    cf1 = new SourcePartitionConnectionFilter(range);
    cf2 = new TargetPartitionConnectionFilter(range);
    cf3 = new TransitivePartitionConnectionFilter(range);
   
    assertFalse(cf1.equals(cf2));
    assertFalse(cf1.equals(cf3));
    assertFalse(cf2.equals(cf1));
    assertFalse(cf2.equals(cf3));
View Full Code Here

TOP

Related Classes of cleo.search.connection.TransitivePartitionConnectionFilter

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.