Ejemplo n.º 1
0
 /**
  * Get the best plan for the given search mask.
  *
  * @param session the session
  * @param masks per-column comparison bit masks, null means 'always false', see constants in
  *     IndexCondition
  * @param sortOrder the sort order
  * @return the plan item
  */
 public PlanItem getBestPlanItem(Session session, int[] masks, SortOrder sortOrder) {
   PlanItem item = new PlanItem();
   item.setIndex(getScanIndex(session));
   item.cost = item.getIndex().getCost(session, null, null);
   ArrayList<Index> indexes = getIndexes();
   if (indexes != null && masks != null) {
     for (int i = 1, size = indexes.size(); i < size; i++) {
       Index index = indexes.get(i);
       double cost = index.getCost(session, masks, sortOrder);
       if (cost < item.cost) {
         item.cost = cost;
         item.setIndex(index);
       }
     }
   }
   return item;
 }