Exemple #1
0
    public List<Map<String, Object>> execute(String columnNames[]) {
      List<Map<String, Object>> combinedRowList = null;
      Set<NoSqlPredicate> inefficientPredicates = new HashSet<NoSqlPredicate>();
      for (NoSqlPredicate predicate : predicateList) {
        if (predicate.canExecuteEfficiently()) {
          List<Map<String, Object>> rowList = predicate.execute(columnNames);
          if (combinedRowList != null) {
            String primaryKeyName = storageSource.getTablePrimaryKeyName(tableName);
            combinedRowList = combineRowLists(primaryKeyName, combinedRowList, rowList, operator);
          } else {
            combinedRowList = rowList;
          }
        } else {
          inefficientPredicates.add(predicate);
        }
      }

      if (inefficientPredicates.isEmpty()) return combinedRowList;

      List<Map<String, Object>> filteredRowList = new ArrayList<Map<String, Object>>();
      for (Map<String, Object> row : combinedRowList) {
        for (NoSqlPredicate predicate : inefficientPredicates) {
          if (predicate.matchesRow(row)) {
            filteredRowList.add(row);
          }
        }
      }

      return filteredRowList;
    }