Package org.apache.hadoop.zebra.parser

Examples of org.apache.hadoop.zebra.parser.ParseException


  public static void setProjection(JobConf conf, String projection) throws ParseException {
    conf.set(INPUT_PROJ, Schema.normalize(projection));

    // virtual source_table columns require sorted table
    if (Projection.getVirtualColumnIndices(projection) != null && !getSorted(conf))
        throw new ParseException("The source_table virtual column is only availabe for sorted table unions.");
  }
View Full Code Here


    String normalizedProjectionString = Schema.normalize(projection.toString());
    try {
      schema = getSchema(conf);
      new org.apache.hadoop.zebra.types.Projection(schema, normalizedProjectionString);
    } catch (ParseException e) {
      throw new ParseException("[" + projection + "] " + "is not a valid Zebra projection string " + e.getMessage());
    } catch (IOException e) {
      throw new ParseException("[" + projection + "] " + "is not a valid Zebra projection string " + e.getMessage());
    }
   
    conf.set(INPUT_PROJ, normalizedProjectionString);

    // virtual source_table columns require sorted table
    if (Projection.getVirtualColumnIndices(projection.toString()) != null && !getSorted(conf))
      throw new ParseException("The source_table virtual column is only availabe for sorted table unions.");
 
View Full Code Here

   *          Column to be added to the schema
   */
  public void add(ColumnSchema f) throws ParseException {
    if (f == null) {
      if (!projection)
        throw new ParseException("Empty column schema is not allowed");
      mFields.add(null);
      return;
    }
    f.index = mFields.size();
    mFields.add(f);
    if (null != f && null != f.name) {
      if (mNames.put(f.name, f) != null && !projection)
        throw new ParseException("Duplicate field name: " + f.name);
    }
  }
View Full Code Here

    mFields = new ArrayList<ColumnSchema>();
    mNames = new HashMap<String, ColumnSchema>();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < columnNames.length; i++) {
      if (columnNames[i].contains(COLUMN_DELIMITER))
        throw new ParseException("Column name should not contain "
            + COLUMN_DELIMITER);
      if (i > 0) sb.append(",");
      sb.append(columnNames[i]);
    }
    TableSchemaParser parser =
View Full Code Here

        mycs = new ColumnSchema(pn.mName, cs.schema, cs.type);
        result.add(mycs);
        if (pn.mDT == ColumnType.MAP) {
          keysStr = projcols[i].substring(pn.mKeyOffset);
          if (!keysStr.startsWith("{") || !keysStr.endsWith("}"))
            throw new ParseException("Invalid map key specification in "
                + projcols[i]);
          keysStr = keysStr.substring(1, keysStr.length() - 1);
          if ((keysStr.indexOf('{') != -1) || (keysStr.indexOf('}') != -1)
              || (keysStr.indexOf('.') != -1) || (keysStr.indexOf('#') != -1))
            throw new ParseException("Invalid map key specification in "
                + projcols[i]);
          keys = keysStr.split("\\|");
          if ((keyentries = keysmap.get(mycs)) == null) {
            keyentries = new HashSet<String>();
            keysmap.put(mycs, keyentries);
View Full Code Here

      }
      else if (hashIndex != -1 && (fieldIndex == -1 || hashIndex < fieldIndex)) {
        prefix = currentName.substring(0, hashIndex);
        fs = currentSchema.getColumn(prefix);
        if (fs == null)
          throw new ParseException("Column " + name + " does not exist");
        currentSchema = fs.schema;
        if (fs.type != ColumnType.MAP)
          throw new ParseException(name + " is not of type MAP");
        fs = currentSchema.getColumn(0);
        return fs;
      }
      else {
        prefix = currentName.substring(0, fieldIndex);
        if ((fs = currentSchema.getColumn(prefix)) == null)
          throw new ParseException("Column " + name + " does not exist");
        currentSchema = fs.schema;
        if (fs.type != ColumnType.RECORD && fs.type != ColumnType.COLLECTION)
          throw new ParseException(name
              + " is not of type RECORD or COLLECTION");
        currentName = currentName.substring(fieldIndex + 1);
        if (currentName.length() == 0)
          throw new ParseException("Column " + name
              + " does not have field after the record field separator '.'");
      }
      fieldIndex = currentName.indexOf('.');
      hashIndex = currentName.indexOf('#');
    }
View Full Code Here

      }
      else if (hashIndex != -1 && (fieldIndex == -1 || hashIndex > fieldIndex)) {
        currentName = currentName.substring(0, hashIndex);
        if ((fs = getColumn(currentName)) != null) {
          if (fs.type != ColumnType.MAP)
            throw new ParseException(name + " is not of type MAP");
          offset += hashIndex;
          pn.setName(name.substring(0, hashIndex), ColumnType.MAP,
              hashIndex + 1);
          return fs;
        }
      }
      else {
        currentName = currentName.substring(0, fieldIndex);
        if (getColumn(currentName) != null) break;
      }
    }

    currentName = name;
    ColumnType ct = ColumnType.ANY;

    while (true) {
      if (fieldIndex == -1 && hashIndex == -1) {
        offset += currentName.length();
        pn.setName(name.substring(0, offset), ct);
        fs = currentSchema.getColumn(currentName);
        return fs;
      }
      else if (hashIndex != -1 && (fieldIndex == -1 || hashIndex < fieldIndex)) {
        prefix = currentName.substring(0, hashIndex);
        fs = currentSchema.getColumn(prefix);
        if (fs == null)
          throw new ParseException("Column " + name + " does not exist");
        currentSchema = fs.schema;
        if (fs.type != ColumnType.MAP)
          throw new ParseException(name + " is not of type MAP");
        offset += hashIndex;
        pn.setName(name.substring(0, offset), ColumnType.MAP, offset + 1);
        return fs;
      }
      else {
        prefix = currentName.substring(0, fieldIndex);
        if ((fs = currentSchema.getColumn(prefix)) == null)
          throw new ParseException("Column " + name + " does not exist");
        currentSchema = fs.schema;
        if (fs.type != ColumnType.RECORD && fs.type != ColumnType.COLLECTION)
          throw new ParseException(name
              + " is not of type RECORD or COLLECTION");
        currentName = currentName.substring(fieldIndex + 1);
        if (currentName.length() == 0)
          throw new ParseException("Column " + name
              + " does not have field after the record field separator '.'");
        offset += fieldIndex + 1;
        ct = fs.type;
      }
      fieldIndex = currentName.indexOf('.');
View Full Code Here

    }
    if (fs != null) {
      name = name.substring(maxlen);
      if (record) {
        if (fs.type != ColumnType.RECORD && fs.type != ColumnType.COLLECTION)
          throw new ParseException(name
              + " is not of type RECORD or COLLECTION");
        name = name.substring(1);
        pn.setName(name, fs.type);
      }
      else if (map) {
        if (fs.type != ColumnType.MAP)
          throw new ParseException(name + " is not of type MAP");
        name = name.substring(1);
        pn.setName(name, ColumnType.MAP);
      }
      else pn.setName(name, ColumnType.ANY);
      return fs;
View Full Code Here

      if (otherfs == null) continue;
      fs = getColumn(otherfs.name);
      if (fs == null) add(otherfs);
      else {
        if (!ColumnSchema.equals(fs, otherfs))
          throw new ParseException("Different types of column " + fs.name
              + " in tables of a union");
      }
    }
  }
View Full Code Here

     *          complex column type
     * @throws ParseException
     */
    public ColumnSchema(String a, Schema s, ColumnType t) throws ParseException {
      if ((null != s) && !(ColumnType.isSchemaType(t))) {
        throw new ParseException(
            "Only a COLLECTION or RECORD or MAP can have schemas.");
      }
      name = a;
      schema = s;
      type = t;
View Full Code Here

TOP

Related Classes of org.apache.hadoop.zebra.parser.ParseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.