Package org.apache.hadoop.zebra.parser

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


  /**
   * sets the source tuple for the column group ops
   */
  public void setSource(Tuple[] tuples) throws ParseException {
    if (tuples.length < mCGs.size())
      throw new ParseException(
          "Internal Logical Error: Invalid number of column groups");
    for (int i = 0; i < tuples.length; i++) {
      CGEntry mCG = mCGs.get(i);
      if (mCG != null) {
        if (tuples[i] == null) {
View Full Code Here


            return;
        }
        if (splitChild)
        {
          if (stype != SplitType.NONE && splitChildren.isEmpty())
            throw new ParseException("Split on "+name+" is set at different levels.");
          splitChildren.add(childName);
        } else {
          if (splitChildren.contains(childName))
            throw new ParseException("Split on "+name+" is set at different levels.");
        }
        stype = st;
      }
View Full Code Here

        final Schema.ParsedName pn, final int projIndex, HashSet<String> keys) throws ParseException, ExecException
    {
      // recursive call to get the next level schema
      ColumnType ct = pn.getDT();
      if (ct != fs.getType())
          throw new ParseException(fs.getName()+" is not of proper type.");
 
      String prefix;
      int fieldIndex;
      SplitColumn sc;
      Partition.SplitType callerDT = (ct == ColumnType.MAP ? Partition.SplitType.MAP :
View Full Code Here

    {
      startidx = name.indexOf("#{");
      if (startidx != -1)
      {
        if (!name.endsWith("}"))
          throw new ParseException("Invalid projection");
        startidx += 2;
        if (name.substring(startidx, name.length()-1).indexOf("#") != -1 ||
          name.substring(startidx, name.length()-1).indexOf("{") != -1 ||
          name.substring(startidx, name.length()-1).indexOf("}") != -1)
          throw new ParseException("Invalid projection");
        name = name.substring(0, startidx-2);
      } else {
        if (name.indexOf("#") != -1 || name.indexOf("{") != -1 ||
            name.indexOf("}") != -1)
          throw new ParseException("Invalid projection");
      }
      if (i++ > 0)
        schemaStr += ",";
      schemaStr += name;
    }
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");
        else if( fs.type == ColumnType.COLLECTION )
      throw new ParseException( name + "Projection within COLLECTION is not supported" );
        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

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.