/** * 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; }
public PlanItem getBestPlanItem(Session session, int[] masks) { PlanItem item = new PlanItem(); item.cost = index.getCost(session, masks); IntArray masksArray = new IntArray(masks == null ? Utils.EMPTY_INT_ARRAY : masks); ViewIndex i2 = indexCache.get(masksArray); if (i2 == null || i2.getSession() != session) { i2 = new ViewIndex(this, index, session, masks); indexCache.put(masksArray, i2); } item.setIndex(i2); return item; }