public IVariable[] getVariables() {
      IVariable[] result = super.getVariables();
      if (result == null) {
        try {
          List variables = new ArrayList();
          variables.add(
              new VariableWrapper(
                  "ruleName",
                  (IJavaValue)
                      DebugUtil.getValueByExpression("return getRule().getName();", activation)));
          String activationId = null;
          IVariable[] activationVarArray = activation.getVariables();
          for (int j = 0; j < activationVarArray.length; j++) {
            IVariable activationVar = activationVarArray[j];
            if ("activationNumber".equals(activationVar.getName())) {
              activationId = activationVar.getValue().getValueString();
              break;
            }
          }
          if (activationId != null) {
            IValue objects =
                DebugUtil.getValueByExpression(
                    "return getActivationParameters(" + activationId + ");", workingMemoryImpl);
            if (objects instanceof IJavaArray) {
              IJavaArray array = (IJavaArray) objects;
              IJavaValue[] javaVals = array.getValues();
              for (int k = 0; k < javaVals.length; k++) {
                IJavaValue mapEntry = javaVals[k];
                String key = null;
                IJavaValue value = null;

                IVariable[] vars = mapEntry.getVariables();
                for (int j = 0; j < vars.length; j++) {
                  IVariable var = vars[j];
                  if ("key".equals(var.getName())) {
                    key = var.getValue().getValueString();
                  } else if ("value".equals(var.getName())) {
                    value = (IJavaValue) var.getValue();
                  }
                }
                variables.add(new VariableWrapper(key, value));
              }
              result = (IJavaVariable[]) variables.toArray(new IJavaVariable[variables.size()]);
            }
          }
        } catch (Throwable t) {
          DroolsEclipsePlugin.log(t);
        }
        if (result == null) {
          result = new IJavaVariable[0];
        }
        setVariables((IJavaVariable[]) result);
      }
      return result;
    }
  private void setStartNodeAndOuterLimits(Element root, Node node1, Node node2) {
    List<Node> node1Parents = getParents(root, node1);
    List<Node> node2Parents = getParents(root, node2);

    if (!node1Parents.isEmpty()
        && !node2Parents.isEmpty()
        && (node1Parents.get(0).equals(node2Parents.get(0)))) {

      int idx = 0;

      // the smaller size of the two lists of parents is the maximum parent index
      // we can check (for greater index numbers there is no partner parent to check against)
      int maxParentIdx = Math.min(node1Parents.size(), node2Parents.size());

      VConsole.log("maxParentIdx: " + maxParentIdx);

      DebugUtil.printNodes("node1Parents", node1Parents);
      DebugUtil.printNodes("node2Parents", node2Parents);

      // find the closest common parent node
      for (; idx < maxParentIdx; idx++) {

        VConsole.log("searching for the closest common parent, checking index: " + idx);
        if (!node1Parents.get(idx).equals(node2Parents.get(idx))) {
          // ok, the last one was the closest, because now we are no longer on the common branch
          break;
        }
      }

      startNode =
          node1Parents.get(idx - 1); // get the last common parent node, which is the closest

      // is one of the node a parent of the other?
      if (idx == maxParentIdx) {
        // one of the nodes is not a text node since text nodes cannot have children
        throw new IllegalStateException("idx==maxParentIdx, should not happen");
      } else {
        // if the second node's index is larger than the index of the first node
        // from their parents point of view, then the first node is on the outer left side of
        // the subtree and the second node is on the outer right side of the subtree;
        // in the other case the positions are swapped
        isAfter =
            indexOf(startNode, node2Parents.get(idx)) > indexOf(startNode, node1Parents.get(idx));

        if (isAfter) {
          outerLeftNode = node1;
          outerRightNode = node2;
        } else {
          outerLeftNode = node2;
          outerRightNode = node1;
        }
      }
    }
  }
 private Object[] getAgendaElements(IJavaObject workingMemoryImpl) throws DebugException {
   List result = new ArrayList();
   IValue agendaGroupObjects =
       DebugUtil.getValueByExpression("return getAgenda().getAgendaGroups();", workingMemoryImpl);
   IValue focus =
       DebugUtil.getValueByExpression("return getAgenda().getFocus();", workingMemoryImpl);
   if (agendaGroupObjects instanceof IJavaArray) {
     IJavaArray agendaGroupArray = (IJavaArray) agendaGroupObjects;
     IJavaValue[] agendaGroupValueArray = agendaGroupArray.getValues();
     for (int i = 0; i < agendaGroupValueArray.length; i++) {
       IJavaValue agendaGroup = agendaGroupValueArray[i];
       String name = "";
       List activationsResult = new ArrayList();
       IVariable[] agendaGroupVarArray = agendaGroup.getVariables();
       for (int j = 0; j < agendaGroupVarArray.length; j++) {
         IVariable agendaGroupVar = agendaGroupVarArray[j];
         if ("name".equals(agendaGroupVar.getName())) {
           name = agendaGroupVar.getValue().getValueString();
           break;
         }
       }
       IJavaArray activations =
           (IJavaArray) DebugUtil.getValueByExpression("return getActivations();", agendaGroup);
       IJavaValue[] activationArray = activations.getValues();
       for (int l = 0; l < activationArray.length; l++) {
         IJavaValue activation = activationArray[l];
         if (activation.getJavaType() != null) {
           activationsResult.add(
               new VariableWrapper(
                   "[" + l + "]",
                   new LazyActivationWrapper(activations, activation, workingMemoryImpl)));
         }
       }
       boolean active = false;
       if (agendaGroup.equals(focus)) {
         active = true;
       }
       // because the debug view does not handle spaces well, all spaces
       // in the agenda group name are replaced with '_'s.
       name = replaceSpaces(name);
       result.add(
           new MyVariableWrapper(
               name + "[" + (active ? "focus" : "nofocus") + "]",
               new ObjectWrapper(
                   (IJavaObject) agendaGroup,
                   (IJavaVariable[])
                       activationsResult.toArray(new IJavaVariable[activationsResult.size()]))));
     }
   }
   return result.toArray(new IVariable[0]);
 }
示例#4
0
 public void unloadContent() {
   ApplicationManager.getApplication().assertWriteAccessAllowed();
   clearCaches();
   myViewProvider.beforeContentsSynchronized();
   synchronized (PsiLock.LOCK) {
     FileElement treeElement = derefTreeElement();
     DebugUtil.startPsiModification("unloadContent");
     try {
       if (treeElement != null) {
         myTreeElementPointer = null;
         treeElement.detachFromFile();
         DebugUtil.onInvalidated(treeElement);
       }
       clearStub("unloadContent");
     } finally {
       DebugUtil.finishPsiModification();
     }
   }
 }
示例#5
0
 private static void staticInit()
 {
   logSources = new Vector();
   String str = DebugUtil.getAntProperty("${LOG_SOURCE_LEVELS}", "");
   logSourceLevels = parseLogSourceLevelsConfig(str);
   if (!RuntimeVarz.getInstance().isRegistered("/logs/level"))
     RuntimeVarz.getInstance().register("/logs/level", new String[] { str, "*=FINE", "*=INFO", "*=SEVERE" });
   logSourceObserver = new LogSourceObserver();
   RuntimeVarz.getInstance().addObserver(logSourceObserver);
   defaultLogSource = new LogSource(LogSource.class, null);
 }
示例#6
0
 private LogSource(Class paramClass, Object paramObject)
 {
   this.dynamicSourceObject = paramObject;
   this.logLevel = DEFAULT_LOG_LEVEL;
   this.buffer = new StringBuffer();
   if (paramClass != null)
   {
     this.buffer.append(DebugUtil.getLogSource(paramClass));
     this.buffer.append(": ");
   }
   this.logPrefixLength = this.buffer.length();
 }
示例#7
0
 public static void setup(Context context) {
   Logger.isDebuggable = DebugUtil.getInstance(context).isDebuggable();
   Logger.isSetup = true;
 }
示例#8
0
  public static LookupTable loadLookupTable(
      String schemaName, String tableName, String colName, Map<Integer, Connection> cnxMap)
      throws SQLException {

    System.out.println("loading table: " + tableName);
    Connection conn = cnxMap.values().iterator().next();
    Statement stmt = conn.createStatement();

    DebugUtil.print("connection map: " + cnxMap);

    if (cnxMap.keySet().size() == 1) {
      return new OnePartitionTable(tableName, colName, cnxMap.keySet().iterator().next());
    }

    String typeSql =
        "select COLUMN_TYPE from information_schema.`COLUMNS` where TABLE_SCHEMA='"
            + schemaName
            + "' AND TABLE_NAME='"
            + tableName
            + "' AND COLUMN_NAME='"
            + colName
            + "'";
    ResultSet typeRes = stmt.executeQuery(typeSql);
    typeRes.next();

    String columnType = typeRes.getString("COLUMN_TYPE");
    stmt.close();
    // should support more types as enum
    boolean isInt = false;

    if (columnType.startsWith("int")) {
      isInt = true;
    }

    String valSql = "select " + colName + " from " + tableName;

    DebugUtil.print("creating mapping for table: " + tableName + " col: " + colName);
    Map<Integer, Integer> mInt = new HashMap<Integer, Integer>();
    //    Map<Comparable, Integer> mInt = new HashMap<Comparable, Integer>();

    Map<Comparable, Integer> m = new HashMap<Comparable, Integer>();

    int cnt = 0;
    for (Integer partition : cnxMap.keySet()) {
      Statement stmt2 = cnxMap.get(partition).createStatement();
      ResultSet partRes = stmt2.executeQuery(valSql);
      if (isInt) {

        while (partRes.next()) {
          mInt.put(partRes.getInt(1), partition);
          cnt++;
          //          DebugUtil.print("added: val " + partRes.getInt(1) +", by colname: " +
          // partRes.getInt(colName)+ " to partition: " + partition);
        }
      }
      // otherwise store as string... should support more later
      else {

        while (partRes.next()) {
          m.put(partRes.getString(1), partition);
          cnt++;
          //          DebugUtil.print("added: val " + partRes.getString(1) + " to partition: " +
          // partition);
        }
      }
    }
    System.out.println(
        "added " + cnt + " mappings to lookup table: " + tableName + " on column " + colName);
    if (isInt) {
      return new IntLookupTable(tableName, colName, mInt);
      //      return new BasicLookupTable(tableName, colName, columnType, mInt);

    } else {
      return new BasicLookupTable(tableName, colName, columnType, m);
    }
  }
示例#9
0
  public static DBRouter loadBasicRouter(
      Map<Integer, Connection> cnxMap, String schemaName, Map<String, String> tableToColNames) {

    System.out.println("loading router....");

    DBRouter dbRouter = new DBRouter(new HashSet<Integer>(cnxMap.keySet()));
    // dbRouter.addLookupTable(new BasicLookupTable("persons", "p_id", null));

    if (DebugUtil.WIKIPEDIA_DATA_SET) {

      try {

        // create the range partition lookup on table name
        StringRangeRouter srr = loadStringRangeRouter(cnxMap);

        // create the dual lookup table for page.page_id and revision.rev_id
        //        LookupTable lt1 = loadLookupTable(schemaName, "revision", "rev_page", cnxMap);
        LookupTable lt1 = loadLookupTable(schemaName, "page", "page_id", cnxMap);

        // create the lookup table on text.old_id (can use revision.rev_text_id here)
        LookupTable lt2 = loadLookupTable(schemaName, "revision", "rev_text_id", cnxMap);
        lt2.setName("text");

        dbRouter.addLookupTable(lt1);
        dbRouter.addLookupTable(lt2);
        dbRouter.addSecondaryLookup("page", srr);

      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      return dbRouter;

    } else if (DebugUtil.TPCE_DATA_SET) {
      if (DebugUtil.TPCE_ROUTER_TYPE.equals(TpceRouterType.LOOKUP_TABLE)) {

        try {
          // read in the a_id -> partition table
          ConcurrentHashMap<Long, Integer> a_id_map = loadConcurrentLongHashMap("a_by_aid", cnxMap);
          ConcurrentLookupLong cl_a_id = new ConcurrentLookupLong(a_id_map);

          // read in the b_id mapping
          ConcurrentHashMap<Long, Integer> b_id_map = loadConcurrentLongHashMap("b_by_bid", cnxMap);
          ConcurrentLookupLong cl_b_id = new ConcurrentLookupLong(b_id_map);

          // read in the c_id mapping
          ConcurrentHashMap<Long, Integer> c_id_map = loadConcurrentLongHashMap("c_by_cid", cnxMap);
          ConcurrentLookupLong cl_c_id = new ConcurrentLookupLong(c_id_map);

          // read in the c tax_id
          ConcurrentHashMap<String, Integer> taxid_map =
              loadConcurrentStringHashMap("c_by_taxid", cnxMap);
          ConcurrentLookupString cl_taxid = new ConcurrentLookupString(taxid_map);

          // read in the tid map
          ConcurrentHashMap<Long, Integer> t_id_map = loadConcurrentLongHashMap("t_by_tid", cnxMap);
          ConcurrentLookupLong cl_t_id = new ConcurrentLookupLong(t_id_map);

          // create lt for trade
          LookupMultiColumn ltTrade = new LookupMultiColumn("trade", dbRouter.allPartitionIds);
          ltTrade.addLookupTable("t_id", cl_t_id);
          ltTrade.addLookupTable("t_ca_id", cl_a_id);

          // create lt for customer_account
          LookupMultiColumn ltCustAcct =
              new LookupMultiColumn("customer_account", dbRouter.allPartitionIds);
          ltCustAcct.addLookupTable("ca_id", cl_a_id);
          ltCustAcct.addLookupTable("ca_c_id", cl_c_id);
          ltCustAcct.addLookupTable("ca_b_id", cl_b_id);

          // create lt for customer
          LookupMultiColumn ltCustomer =
              new LookupMultiColumn("customer", dbRouter.allPartitionIds);
          ltCustomer.addLookupTable("c_id", cl_c_id);
          ltCustomer.addLookupTable("c_tax_id", cl_taxid);

          // create lt for broker
          LookupMultiColumn ltBroker = new LookupMultiColumn("broker", dbRouter.allPartitionIds);
          ltBroker.addLookupTable("b_id", cl_b_id);

          // add lt to the router
          dbRouter.addLookupTable(ltBroker);
          dbRouter.addLookupTable(ltCustomer);
          dbRouter.addLookupTable(ltCustAcct);
          dbRouter.addLookupTable(ltTrade);

          return dbRouter;

        } catch (SQLException e) {
          // TODO Auto-generated catch block
          throw new RuntimeException(e);
        }

      } else if (DebugUtil.TPCE_ROUTER_TYPE.equals(TpceRouterType.RANGE)) {
        ConcurrentRangeLookup cl_broker = new ConcurrentRangeLookup(4300000001L, 4300000100L);
        ConcurrentRangeLookup cl_cust = new ConcurrentRangeLookup(4300000001L, 4300010000L);
        ConcurrentRangeLookup cl_account = new ConcurrentRangeLookup(43000000001L, 43000099992L);

        // create lt for trade
        LookupMultiColumn ltTrade = new LookupMultiColumn("trade", dbRouter.allPartitionIds);
        ltTrade.addLookupTable("t_ca_id", cl_account);

        // create lt for customer_account
        LookupMultiColumn ltCustAcct =
            new LookupMultiColumn("customer_account", dbRouter.allPartitionIds);
        ltCustAcct.addLookupTable("ca_id", cl_account);

        // create lt for customer
        LookupMultiColumn ltCustomer = new LookupMultiColumn("customer", dbRouter.allPartitionIds);
        ltCustomer.addLookupTable("c_id", cl_cust);

        // create lt for broker
        LookupMultiColumn ltBroker = new LookupMultiColumn("broker", dbRouter.allPartitionIds);
        ltBroker.addLookupTable("b_id", cl_broker);

        // add lt to the router
        dbRouter.addLookupTable(ltBroker);
        dbRouter.addLookupTable(ltCustomer);
        dbRouter.addLookupTable(ltCustAcct);
        dbRouter.addLookupTable(ltTrade);

        return dbRouter;

      } else if (DebugUtil.TPCE_ROUTER_TYPE.equals(TpceRouterType.HASH)) {
        ConcurrentHashLookup cl_broker = new ConcurrentHashLookup();
        ConcurrentHashLookup cl_cust = new ConcurrentHashLookup();
        ConcurrentHashLookup cl_account = new ConcurrentHashLookup();

        // create lt for trade
        LookupMultiColumn ltTrade = new LookupMultiColumn("trade", dbRouter.allPartitionIds);
        ltTrade.addLookupTable("t_ca_id", cl_account);

        // create lt for customer_account
        LookupMultiColumn ltCustAcct =
            new LookupMultiColumn("customer_account", dbRouter.allPartitionIds);
        ltCustAcct.addLookupTable("ca_id", cl_account);

        // create lt for customer
        LookupMultiColumn ltCustomer = new LookupMultiColumn("customer", dbRouter.allPartitionIds);
        ltCustomer.addLookupTable("c_id", cl_cust);

        // create lt for broker
        LookupMultiColumn ltBroker = new LookupMultiColumn("broker", dbRouter.allPartitionIds);
        ltBroker.addLookupTable("b_id", cl_broker);

        // add lt to the router
        dbRouter.addLookupTable(ltBroker);
        dbRouter.addLookupTable(ltCustomer);
        dbRouter.addLookupTable(ltCustAcct);
        dbRouter.addLookupTable(ltTrade);

        return dbRouter;

      } else if (DebugUtil.TPCE_ROUTER_TYPE.equals(TpceRouterType.SINGLE_BACKEND)) {
        OnePartitionTable opt_trade = new OnePartitionTable("trade", "", 1);
        OnePartitionTable opt_cust_ac = new OnePartitionTable("customer_account", "", 1);
        OnePartitionTable opt_cust = new OnePartitionTable("customer", "", 1);
        OnePartitionTable opt_broker = new OnePartitionTable("broker", "", 1);
        // add lt to the router
        dbRouter.addLookupTable(opt_trade);
        dbRouter.addLookupTable(opt_cust_ac);
        dbRouter.addLookupTable(opt_cust);
        dbRouter.addLookupTable(opt_broker);
        return dbRouter;
      } else {
        throw new RuntimeException("other router types not supported for tpce");
      }
    } else if (DebugUtil.TWITTER_DATA_SET) {

      if (DebugUtil.TWITTER_ROUTER_TYPE.equals(TwitterRouterType.SINGLE_BACKEND)) {
        OnePartitionTable t_user = new OnePartitionTable("user", "uid", 1);
        OnePartitionTable t_followers = new OnePartitionTable("followers", "f1", 1);
        OnePartitionTable t_follows = new OnePartitionTable("follows", "f1", 1);
        OnePartitionTable t_tweets = new OnePartitionTable("tweets", "uid", 1);
        OnePartitionTable t_added_tweets = new OnePartitionTable("added_tweets", "uid", 1);

        dbRouter.addLookupTable(t_tweets);
        dbRouter.addLookupTable(t_user);
        dbRouter.addLookupTable(t_followers);
        dbRouter.addLookupTable(t_follows);
        dbRouter.addLookupTable(t_added_tweets);
      } else if (DebugUtil.TWITTER_ROUTER_TYPE.equals(TwitterRouterType.LOOKUP_TABLE)
          || DebugUtil.TWITTER_ROUTER_TYPE.equals(TwitterRouterType.ONE_HOP)) {
        try {
          OpenIntIntHashMap map = getIntegerMapUidToPartitionColt(cnxMap);
          IntLookupTable lt_user = new IntLookupTable("user", "uid", map, dbRouter.allPartitionIds);
          IntLookupTable lt_tweets = new IntLookupTable("tweets", "uid", lt_user);
          IntLookupTable lt_follows = new IntLookupTable("follows", "f1", lt_user);
          IntLookupTable lt_followers = new IntLookupTable("followers", "f1", lt_user);
          IntLookupTable lt_added = new IntLookupTable("added_tweets", "uid", lt_user);

          dbRouter.addLookupTable(lt_user);
          dbRouter.addLookupTable(lt_tweets);
          dbRouter.addLookupTable(lt_follows);
          dbRouter.addLookupTable(lt_followers);
          dbRouter.addLookupTable(lt_added);

        } catch (SQLException e) {
          // TODO Auto-generated catch block
          throw new RuntimeException(e);
        }
      }
      // also used for uber hash, but make sure lookup of 1 tweet has userid too
      else if (DebugUtil.TWITTER_ROUTER_TYPE.equals(
          TwitterRouterType
              .REAL_HASH_UID)) { // also used for uber hash, but make sure tweet has userid too
        HashPartitionLookup hp_user =
            new HashPartitionLookup("user", "uid", dbRouter.allPartitionIds);
        HashPartitionLookup hp_tweets =
            new HashPartitionLookup("tweets", "uid", dbRouter.allPartitionIds);
        HashPartitionLookup hp_follows =
            new HashPartitionLookup("follows", "f1", dbRouter.allPartitionIds);
        HashPartitionLookup hp_followers =
            new HashPartitionLookup("followers", "f1", dbRouter.allPartitionIds);
        HashPartitionLookup hp_added =
            new HashPartitionLookup("added_tweets", "uid", dbRouter.allPartitionIds);

        dbRouter.addLookupTable(hp_user);
        dbRouter.addLookupTable(hp_tweets);
        dbRouter.addLookupTable(hp_follows);
        dbRouter.addLookupTable(hp_followers);
        dbRouter.addLookupTable(hp_added);
      } else if (DebugUtil.TWITTER_ROUTER_TYPE.equals(TwitterRouterType.REAL_HASH_TID)) {
        HashPartitionLookup hp_user =
            new HashPartitionLookup("user", "uid", dbRouter.allPartitionIds);
        HashPartitionLookup hp_tweets =
            new HashPartitionLookup("tweets", "id", dbRouter.allPartitionIds);
        HashPartitionLookup hp_follows =
            new HashPartitionLookup("follows", "f1", dbRouter.allPartitionIds);
        HashPartitionLookup hp_followers =
            new HashPartitionLookup("followers", "f1", dbRouter.allPartitionIds);
        HashPartitionLookup hp_added =
            new HashPartitionLookup("added_tweets", "uid", dbRouter.allPartitionIds);

        dbRouter.addLookupTable(hp_user);
        dbRouter.addLookupTable(hp_tweets);
        dbRouter.addLookupTable(hp_follows);
        dbRouter.addLookupTable(hp_followers);
        dbRouter.addLookupTable(hp_added);
      } else if (DebugUtil.TWITTER_ROUTER_TYPE.equals(TwitterRouterType.SINGLE_BACKEND)) {
        assert dbRouter.allPartitionIds.size() == 1;
        int partId = dbRouter.allPartitionIds.iterator().next();
        OnePartitionTable o_user = new OnePartitionTable("user", "uid", partId);
        OnePartitionTable o_tweets = new OnePartitionTable("tweets", "id", partId);
        OnePartitionTable o_follows = new OnePartitionTable("follows", "f1", partId);
        OnePartitionTable o_followers = new OnePartitionTable("followers", "f1", partId);
        OnePartitionTable o_added = new OnePartitionTable("added_tweets", "uid", partId);

        dbRouter.addLookupTable(o_user);
        dbRouter.addLookupTable(o_tweets);
        dbRouter.addLookupTable(o_follows);
        dbRouter.addLookupTable(o_followers);
        dbRouter.addLookupTable(o_added);
      } else {
        assert false : "no other twitter routers supported";
      }

      return dbRouter;

    } else {
      for (String tabName : tableToColNames.keySet()) {
        try {
          LookupTable lt =
              RouterLoader.loadLookupTable(
                  schemaName, tabName, tableToColNames.get(tabName), cnxMap);
          DebugUtil.print(lt.toString());
          dbRouter.addLookupTable(lt);
        } catch (SQLException e) {
          // TODO Auto-generated catch block
          throw new RuntimeException(e);
        }
      }

      return dbRouter;
    }
  }
示例#10
0
  /*
   * used to create wikipedia table on title
   */
  public static StringRangeRouter loadStringRangeRouter(Map<Integer, Connection> cnxMap)
      throws SQLException {

    DebugUtil.print("loading string range router");
    String[] cutPoints;
    int[] partitionIds;

    if (DebugUtil.NUM_BACKENDS_FOR_WIKIPEDIA == 8) {
      cutPoints = new String[7];
      partitionIds = new int[8];
      cutPoints[0] = "Bastion_(comics)";
      cutPoints[1] = "Devil_May_Cry_2";
      cutPoints[2] = "Gypsy_(comics)";
      cutPoints[3] = "Lexington_class_aircraft_carrier_aircraft";
      cutPoints[4] = "National_Football_League";
      cutPoints[5] = "Requests_for_adminship/Biruitorul";
      cutPoints[6] = "The_Impending_Crisis_of_the_South";
    } else if (DebugUtil.NUM_BACKENDS_FOR_WIKIPEDIA == 4) {
      cutPoints = new String[3];
      partitionIds = new int[4];
      cutPoints[0] = "Devil_May_Cry_2";
      cutPoints[1] = "Lexington_class_aircraft_carrier_aircraft";
      cutPoints[2] = "Requests_for_adminship/Biruitorul";
    } else if (DebugUtil.NUM_BACKENDS_FOR_WIKIPEDIA == 2) {
      cutPoints = new String[1];
      partitionIds = new int[2];
      cutPoints[0] = "Lexington_class_aircraft_carrier_aircraft";
    } else if (DebugUtil.NUM_BACKENDS_FOR_WIKIPEDIA == 1) {
      partitionIds = new int[1];
      assert cnxMap.keySet().size() == 1;
      partitionIds[0] = cnxMap.keySet().iterator().next();
      return new StringRangeRouter(partitionIds);
    } else {
      throw new RuntimeException(
          "NUM_BACKENDS_FOR_WIKIPEDIA=" + DebugUtil.NUM_BACKENDS_FOR_WIKIPEDIA + " not supported");
    }

    assert partitionIds.length == (cutPoints.length + 1);

    String query_front = "SELECT page_title FROM `page` LIMIT 1;";
    for (Integer partition : cnxMap.keySet()) {
      Connection conn = cnxMap.get(partition);
      Statement stmt = conn.createStatement();
      ResultSet rs = stmt.executeQuery(query_front);
      rs.first();
      String title = rs.getString(1);
      DebugUtil.print("partition: " + partition + " title: " + title);
      boolean found = false;
      for (int i = 0; i < cutPoints.length; i++) {
        //        if(title.compareToIgnoreCase(cutPoints[i]) < 0){
        if (title.compareTo(cutPoints[i]) < 0) {

          partitionIds[i] = partition;
          found = true;
          break;
        }
      }
      if (found == false) {
        partitionIds[cutPoints.length] = partition;
      }
    }

    StringRangeRouter srr = new StringRangeRouter(cutPoints, partitionIds);
    DebugUtil.print("" + srr);

    return srr;
  }
示例#11
0
文件: MemLogger.java 项目: pnnl/svf
 @Override
 public void draw(final GL2 gl, final GLUgl2 glu, final Camera camera) {
   if (vendor == Vendor.ERROR) {
     return;
   }
   final int[] values = new int[] {NO_VALUE, NO_VALUE};
   // try nvidia first
   if (vendor == Vendor.NVIDIA || vendor == Vendor.NONE) {
     try {
       gl.glGetIntegerv(GL_TOTAL_AVAILABLE_MEM, values, 0);
       gl.glGetIntegerv(GL_CURRENT_AVAILABLE_MEM, values, 1);
       if (values[1] >= 0) {
         vendor = Vendor.NVIDIA;
       }
     } catch (final GLException ex) {
       // failed to get values
       DebugUtil.clearGLErrors(gl);
       // error will be logged when values are not assigned
       values[0] = ERROR_VALUE;
       values[1] = ERROR_VALUE;
     }
   }
   // try amd/ati
   if (vendor == Vendor.AMD || vendor == Vendor.NONE) {
     try {
       if (vendor == Vendor.NONE) {
         if (gl instanceof WGLExt) {
           final WGLExt wgl = (WGLExt) gl;
           final int gpuCount = wgl.wglGetGPUIDsAMD(0, null);
           final int[] gpuIds = new int[gpuCount];
           final IntBuffer totalMem = IntBuffer.allocate(1);
           for (int i = 0; i < gpuIds.length; i++) {
             wgl.wglGetGPUInfoAMD(
                 gpuIds[i], WGLExt.WGL_GPU_RAM_AMD, GL2.GL_UNSIGNED_INT, 1, totalMem);
             values[0] = Math.max(values[0], totalMem.get(0));
           }
         }
       } else {
         synchronized (this) {
           values[0] = totalAvailableMem;
         }
       }
       gl.glGetIntegerv(GL2.GL_TEXTURE_FREE_MEMORY_ATI, values, 1);
       if (values[1] >= 0) {
         vendor = Vendor.AMD;
       }
     } catch (final GLException ex) {
       // failed to get values
       DebugUtil.clearGLErrors(gl);
       // error will be logged when values are not assigned
       values[0] = ERROR_VALUE;
       values[1] = ERROR_VALUE;
     }
   }
   // catch errors
   if (vendor == Vendor.NONE && values[0] < 0 || values[1] < 0) {
     vendor = Vendor.ERROR;
   }
   synchronized (this) {
     totalAvailableMem = values[0];
     currentAvailableMem = values[1];
   }
 }