Package cleo.search.store

Examples of cleo.search.store.ArrayStoreWeights


        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));
    }
   
    if(multiHandler.isEmpty()) return;
   
    /**
     * Bootstrap weighted-connections-store
     */
    System.out.println("-- starting bootstrap --");
   
    ConnectionsScanner scanner = new ConnectionsScanner(connectionsDir);
    scanner.scan(multiHandler);
   
    Iterator<ConnectionsHandler> iter = multiHandler.iterator();
    while(iter.hasNext()) {
      ArrayStoreWeights weightedConnectionsStore;
      weightedConnectionsStore = ((WeightedConnectionsStoreConnectionsHandler)iter.next()).getWeightedConnectionsStore();
      weightedConnectionsStore.sync();
    }
   
    System.out.println();
    System.out.printf("Bootstrap done in %d seconds%n", c.getTotalTime()/1000);
  }
View Full Code Here


  protected ArrayStoreWeights createWeightedConnectionsStore() throws Exception {
    File connectionsStoreDir = new File(getHomeDir(), "weighted-connections-store");
    int connectionsStoreSegMB = 32;
    SegmentFactory connectionsStoreSegFactory = new MemorySegmentFactory();
   
    ArrayStoreWeights connectionsStore =
      StoreFactory.createArrayStoreWeights(
          connectionsStoreDir,
          getConnectionsStoreCapacity(),
          connectionsStoreSegFactory,
          connectionsStoreSegMB);
View Full Code Here

    ConnectionFilter connFilter = null;
    if(!source.getConnectionFilter().equals(target.getConnectionFilter())) {
      connFilter = target.getConnectionFilter();
    }
   
    ArrayStoreWeights sourceConnectionsStore = source.getConnectionsStore();
    ArrayStoreWeights targetConnectionsStore = target.getConnectionsStore();
    if(targetConnectionsStore.length() < sourceConnectionsStore.length()) {
      targetConnectionsStore.setWeightData(sourceConnectionsStore.length() - 1, (int[][])null, targetConnectionsStore.getHWMark());
    }
    copy(sourceConnectionsStore, targetConnectionsStore, connFilter);
  }
View Full Code Here

    return networkTypeahead;
  }
 
  protected WeightedNetworkTypeahead<E> createTypeahead(NetworkTypeaheadConfig<E> config) throws Exception {
    // create weightedConnectionsStore
    ArrayStoreWeights weightedConnectionsStore = StoreFactory.createArrayStoreWeights(
        config.getConnectionsStoreDir(),
        config.getConnectionsStoreCapacity(),
        config.getConnectionsStoreSegmentFactory(),
        config.getConnectionsStoreSegmentMB());
   
View Full Code Here

    int cnt = rand.nextInt(1000) + 10;
    long scn = System.currentTimeMillis();
    List<Connection> list = new ArrayList<Connection>(cnt);
    Map<String, Connection> map = new HashMap<String, Connection>(cnt);
   
    ArrayStoreWeights store = typeahead.getConnectionsStore();
   
    for(int i = 0; i < cnt; i++) {
      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

TOP

Related Classes of cleo.search.store.ArrayStoreWeights

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.