Package cleo.search.connection

Examples of cleo.search.connection.SimpleConnection


   *
   * @param connIndexer - the connection indexer
   * @throws Exception
   */
  public static void indexConnections(ConnectionIndexer connIndexer) throws Exception {
    connIndexer.index(new SimpleConnection(5, 1007, true));
    connIndexer.index(new SimpleConnection(5, 2007, true));
    connIndexer.index(new SimpleConnection(5, 780208, true));
    connIndexer.index(new SimpleConnection(167, 180208, true));
    connIndexer.index(new SimpleConnection(167, 119205, true));
    connIndexer.index(new SimpleConnection(167, 29, true));

    connIndexer.index(new SimpleConnection(1, 5, true));
    connIndexer.index(new SimpleConnection(1, 167, true));
   
    connIndexer.flush();
  }
View Full Code Here


    List<SimpleElement> results;
   
    int uid = getConnectionsStoreIndexStart() + rand.nextInt(this.getConnectionsStoreCapacity());
    int elemId = getElementStoreIndexStart() + rand.nextInt(getElementStoreCapacity());
   
    Connection conn = new SimpleConnection(uid, elemId, true);
    conn.setTimestamp(System.currentTimeMillis());
   
    SimpleElement elem = new SimpleElement(elemId);
    elem.setTimestamp(System.currentTimeMillis());
    elem.setTerms("Bloom", "filter");
   
View Full Code Here

    List<SimpleElement> results;
   
    int uid = getConnectionsStoreIndexStart() + rand.nextInt(this.getConnectionsStoreCapacity());
    int elemId = getElementStoreIndexStart() + rand.nextInt(getElementStoreCapacity());
   
    Connection conn = new SimpleConnection(uid, elemId, true);
    conn.setTimestamp(System.currentTimeMillis());
   
    SimpleElement elem = new SimpleElement(elemId);
    elem.setTimestamp(System.currentTimeMillis());
    elem.setTerms("Bloom", "filter");
   
View Full Code Here

      int source = getConnectionsStoreIndexStart() + rand.nextInt(this.getConnectionsStoreCapacity());
      int target = getElementStoreIndexStart() + rand.nextInt(getElementStoreCapacity());
      String key = source + "=>" + target;
     
      if(!map.containsKey(key)) {
        Connection conn = new SimpleConnection(source, target, true);
        conn.setStrength(rand.nextInt(1000000));
       
        map.put(key, conn);
        list.add(conn);
      }
    }
   
    // Index active connections
    for(Connection conn : list) {
      conn.setTimestamp(scn++);
      typeahead.index(conn);
    }
   
    for(Connection conn : list) {
      assertEquals(conn.getStrength(), store.getWeight(conn.source(), conn.target()));
     
      int[][] dat = store.getWeightData(conn.source());
      assertEquals(2, dat.length);
      assertTrue(dat[ArrayStoreWeights.ELEMID_SUBARRAY_INDEX].length > 0);
      assertTrue(dat[ArrayStoreWeights.ELEMID_SUBARRAY_INDEX].length == dat[ArrayStoreWeights.WEIGHT_SUBARRAY_INDEX].length);
    }
   
    // Index inactive connections
    for(Connection conn : list) {
      conn.setActive(false);
      conn.setTimestamp(scn++);
      typeahead.index(conn);
    }
   
    for(Connection conn : list) {
      assertEquals(0, store.getWeight(conn.source(), conn.target()));
     
      int[][] dat = store.getWeightData(conn.source());
      assertEquals(2, dat.length);
      assertEquals(0, dat[ArrayStoreWeights.ELEMID_SUBARRAY_INDEX].length);
      assertTrue(dat[ArrayStoreWeights.ELEMID_SUBARRAY_INDEX].length == dat[ArrayStoreWeights.WEIGHT_SUBARRAY_INDEX].length);
    }
  }
View Full Code Here

      }
    }
    elemIdSet.addAll(uidSetDeg1);
   
    for(int target : uidSetDeg1) {
      Connection conn = new SimpleConnection(uid, target, true);
      conn.setStrength(rand.nextInt(10000));
      connList.add(conn);
    }
   
    for(int source : uidSetDeg1) {
      Set<Integer> uidSetDeg2 = new HashSet<Integer>();
     
      for(int i = 0, cnt = rand.nextInt(10) + 10; i < cnt; i++) {
        int target = rand.nextInt(uidMax);
        if(source != target && !uidSetDeg2.contains(target)) {
          uidSetDeg2.add(target);
        }
      }
     
      for(int target : uidSetDeg2) {
        Connection conn = new SimpleConnection(source, target, true);
        conn.setStrength(rand.nextInt(10000));
        connList.add(conn);
      }
     
      elemIdSet.addAll(uidSetDeg2);
      uidSetDeg2.clear();
    }
   
    // Index active connections
    for(Connection conn : connList) {
      conn.setTimestamp(System.currentTimeMillis());
      typeahead.index(conn);
    }
  }
View Full Code Here

     *  
     *   013 -> 001
     *   013 -> 131
     */
    Connection conn;
    conn = new SimpleConnection(1, 11, true);
    typeahead.index(conn);
   
    conn = new SimpleConnection(1, 12, true);
    typeahead.index(conn);
   
    conn = new SimpleConnection(1, 13, true);
    typeahead.index(conn);
   
    conn = new SimpleConnection(1, 499, true);
    typeahead.index(conn);
   
    conn = new SimpleConnection(1, 111, true);
    typeahead.index(conn);
   
    conn = new SimpleConnection(11, 111, true);
    typeahead.index(conn);
   
    conn = new SimpleConnection(11, 112, true);
    typeahead.index(conn);

    conn = new SimpleConnection(12, 1, true);
    typeahead.index(conn);
   
    conn = new SimpleConnection(12, 121, true);
    typeahead.index(conn);

    conn = new SimpleConnection(13, 1, true);
    typeahead.index(conn);
   
    conn = new SimpleConnection(13, 131, true);
    typeahead.index(conn);
   
    typeahead.flush();
   
    // Search
View Full Code Here

    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

    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

    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

    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.SimpleConnection

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.