예제 #1
0
 public List<SqlMoniker> getAllSchemaObjectNames(List<String> names) {
   List<SqlMoniker> result;
   switch (names.size()) {
     case 0:
       // looking for schema names
       result = new ArrayList<SqlMoniker>();
       for (MockSchema schema : schemas.values()) {
         result.add(new SqlMonikerImpl(schema.name, SqlMonikerType.Schema));
       }
       return result;
     case 1:
       // looking for table names in the given schema
       MockSchema schema = schemas.get(names.get(0));
       if (schema == null) {
         return Collections.emptyList();
       }
       result = new ArrayList<SqlMoniker>();
       for (String tableName : schema.tableNames) {
         result.add(new SqlMonikerImpl(tableName, SqlMonikerType.Table));
       }
       return result;
     default:
       return Collections.emptyList();
   }
 }
예제 #2
0
  /**
   * Adds on to the existing join condition reference counts the references from the new join
   * condition.
   *
   * @param multiJoinInputs inputs into the new MultiJoinRel
   * @param nTotalFields total number of fields in the MultiJoinRel
   * @param joinCondition the new join condition
   * @param origJoinFieldRefCounts existing join condition reference counts
   * @param newJoinFieldRefCountsMap map containing the new join condition reference counts, indexed
   *     by input #
   */
  private void addOnJoinFieldRefCounts(
      RelNode[] multiJoinInputs,
      int nTotalFields,
      RexNode joinCondition,
      List<int[]> origJoinFieldRefCounts,
      Map<Integer, int[]> newJoinFieldRefCountsMap) {
    // count the input references in the join condition
    int[] joinCondRefCounts = new int[nTotalFields];
    joinCondition.accept(new InputReferenceCounter(joinCondRefCounts));

    // first, make a copy of the ref counters
    int nInputs = multiJoinInputs.length;
    int currInput = 0;
    for (int[] origRefCounts : origJoinFieldRefCounts) {
      newJoinFieldRefCountsMap.put(currInput, (int[]) origRefCounts.clone());
      currInput++;
    }

    // add on to the counts for each input into the MultiJoinRel the
    // reference counts computed for the current join condition
    currInput = -1;
    int startField = 0;
    int nFields = 0;
    for (int i = 0; i < nTotalFields; i++) {
      if (joinCondRefCounts[i] == 0) {
        continue;
      }
      while (i >= (startField + nFields)) {
        startField += nFields;
        currInput++;
        assert (currInput < nInputs);
        nFields = multiJoinInputs[currInput].getRowType().getFieldCount();
      }
      int[] refCounts = newJoinFieldRefCountsMap.get(currInput);
      refCounts[i - startField] += joinCondRefCounts[i];
    }
  }
예제 #3
0
 /**
  * Creates a JdbcSchema, taking credentials from a map.
  *
  * @param parentSchema Parent schema
  * @param name Name
  * @param operand Map of property/value pairs
  * @return A JdbcSchema
  */
 public static JdbcSchema create(
     SchemaPlus parentSchema, String name, Map<String, Object> operand) {
   DataSource dataSource;
   try {
     final String dataSourceName = (String) operand.get("dataSource");
     if (dataSourceName != null) {
       final Class<?> clazz = Class.forName((String) dataSourceName);
       dataSource = (DataSource) clazz.newInstance();
     } else {
       final String jdbcUrl = (String) operand.get("jdbcUrl");
       final String jdbcDriver = (String) operand.get("jdbcDriver");
       final String jdbcUser = (String) operand.get("jdbcUser");
       final String jdbcPassword = (String) operand.get("jdbcPassword");
       dataSource = dataSource(jdbcUrl, jdbcDriver, jdbcUser, jdbcPassword);
     }
   } catch (Exception e) {
     throw new RuntimeException("Error while reading dataSource", e);
   }
   String jdbcCatalog = (String) operand.get("jdbcCatalog");
   String jdbcSchema = (String) operand.get("jdbcSchema");
   return JdbcSchema.create(parentSchema, name, dataSource, jdbcCatalog, jdbcSchema);
 }
예제 #4
0
파일: RexUtil.java 프로젝트: kunlqt/optiq
 protected RexNode lookup(RexNode expr) {
   return mapDigestToExpr.get(expr.toString());
 }