Package cleo.search.connection

Examples of cleo.search.connection.ConnectionFilter


    // connectionFilter for network partition
    config.setPartitionStart(Integer.parseInt(properties.getProperty("cleo.search.network.typeahead.config.partition.start")));
    config.setPartitionCount(Integer.parseInt(properties.getProperty("cleo.search.network.typeahead.config.partition.count")));
    Range partitionRange = new Range(config.getPartitionStart(), config.getPartitionCount());
   
    ConnectionFilter connectionFilter = (ConnectionFilter)
      Class.forName(properties.getProperty("cleo.search.network.typeahead.config.connectionFilter.class")).getConstructor(Range.class).newInstance(partitionRange);
    config.setConnectionFilter(connectionFilter);
   
    // elementSerializer
    ElementSerializer<E> elementSerializer = (ElementSerializer<E>)
View Full Code Here


      WeightedNetworkTypeaheadInitializer<TypeaheadElement> initializer =
        new WeightedNetworkTypeaheadInitializer<TypeaheadElement>(config);
      WeightedNetworkTypeahead<TypeaheadElement> typeahead =
        (WeightedNetworkTypeahead<TypeaheadElement>) initializer.getTypeahead();

      ConnectionFilter connectionFilter = typeahead.getConnectionFilter();
      ArrayStoreWeights weightedConnectionsStore = typeahead.getConnectionsStore();
      System.out.printf("Added %s%n", config.getConnectionsStoreDir().getParent());
     
      multiHandler.add(new WeightedConnectionsStoreConnectionsHandler(weightedConnectionsStore, connectionFilter, maxScn));
    }
View Full Code Here

  public static <E extends Element> void copy(VanillaNetworkTypeahead<E> source, VanillaNetworkTypeahead<E> target) throws Exception {
    ArrayStoreElement<E> sourceStore = source.getElementStore();
    ArrayStoreElement<E> targetStore = target.getElementStore();
    copy(sourceStore, targetStore);
   
    ConnectionFilter connFilter = null;
    if(!source.getConnectionFilter().equals(target.getConnectionFilter())) {
      connFilter = target.getConnectionFilter();
    }
   
    ArrayStoreConnections sourceConnectionsStore = source.getConnectionsStore();
View Full Code Here

  public static <E extends Element> void copy(WeightedNetworkTypeahead<E> source, WeightedNetworkTypeahead<E> target) throws Exception {
    ArrayStoreElement<E> sourceStore = source.getElementStore();
    ArrayStoreElement<E> targetStore = target.getElementStore();
    copy(sourceStore, targetStore);
   
    ConnectionFilter connFilter = null;
    if(!source.getConnectionFilter().equals(target.getConnectionFilter())) {
      connFilter = target.getConnectionFilter();
    }
   
    ArrayStoreWeights sourceConnectionsStore = source.getConnectionsStore();
View Full Code Here

   
    // create bloomFilter
    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
View Full Code Here

    // create selectorFactory
    SelectorFactory<E> selectorFactory = config.getSelectorFactory();
    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
View Full Code Here

 
  public void testSourcePartitionConnectionFilter() {
    int start = rand.nextInt(10000) + 100;
    int count = rand.nextInt(10000) + 100;
    Range sourceRange = new Range(start, count);
    ConnectionFilter connFilter = new SourcePartitionConnectionFilter(sourceRange);
   
    Connection conn = new SimpleConnection(0, rand.nextInt(), true);
    assertEquals(false, connFilter.accept(conn));
   
    conn = new SimpleConnection(rand.nextInt(start), rand.nextInt(), true);
    assertEquals(false, connFilter.accept(conn));
   
    conn = new SimpleConnection(start + rand.nextInt(count), rand.nextInt(), true);
    assertEquals(true, connFilter.accept(conn));
   
    conn = new SimpleConnection(sourceRange.getEnd(), rand.nextInt(), true);
    assertEquals(false, connFilter.accept(conn));
   
    conn = new SimpleConnection(sourceRange.getEnd() + rand.nextInt(count), rand.nextInt(), true);
    assertEquals(false, connFilter.accept(conn));
  }
View Full Code Here

 
  public void testTargetPartitionConnectionFilter() {
    int start = rand.nextInt(10000) + 100;
    int count = rand.nextInt(10000) + 100;
    Range targetRange = new Range(start, count);
    ConnectionFilter connFilter = new TargetPartitionConnectionFilter(targetRange);
   
    Connection conn = new SimpleConnection(rand.nextInt(), 0, true);
    assertEquals(false, connFilter.accept(conn));
   
    conn = new SimpleConnection(rand.nextInt(), rand.nextInt(start), true);
    assertEquals(false, connFilter.accept(conn));
   
    conn = new SimpleConnection(rand.nextInt(), start + rand.nextInt(count), true);
    assertEquals(true, connFilter.accept(conn));
   
    conn = new SimpleConnection(rand.nextInt(), targetRange.getEnd(), true);
    assertEquals(false, connFilter.accept(conn));
   
    conn = new SimpleConnection(rand.nextInt(), targetRange.getEnd() + rand.nextInt(count), true);
    assertEquals(false, connFilter.accept(conn));
  }
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

TOP

Related Classes of cleo.search.connection.ConnectionFilter

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.