Examples of MorphlineCompilationException


Examples of org.kitesdk.morphline.api.MorphlineCompilationException

 
    public ReadCSV(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) {
      super(builder, config, parent, child, context);
      String separator = getConfigs().getString(config, "separator", ",");
      if (separator.length() != 1) {
        throw new MorphlineCompilationException("CSV separator must be one character only: " + separator, config);
      }
      this.separatorChar = separator.charAt(0);
      this.columnNames = getConfigs().getStringList(config, "columns");
      this.charset = getConfigs().getCharset(config, "charset", null);
      this.ignoreFirstLine = getConfigs().getBoolean(config, "ignoreFirstLine", false);
      this.trim = getConfigs().getBoolean(config, "trim", true);     
      this.addEmptyStrings = getConfigs().getBoolean(config, "addEmptyStrings", true);
      this.quoteChar = getConfigs().getString(config, "quoteChar", "");
      if (quoteChar.length() > 1) {
        throw new MorphlineCompilationException(
            "Quote character must not have a length of more than one character: " + quoteChar, config);
      }
      if (quoteChar.equals(String.valueOf(separatorChar))) {
        throw new MorphlineCompilationException(
            "Quote character must not be the same as separator: " + quoteChar, config);
      }
      this.commentPrefix = getConfigs().getString(config, "commentPrefix", "");
      if (commentPrefix.length() > 1) {
        throw new MorphlineCompilationException(
            "Comment prefix must not have a length of more than one character: " + commentPrefix, config);
      }
      this.maxCharactersPerRecord = getConfigs().getInt(config, "maxCharactersPerRecord", 1000 * 1000);
      this.ignoreTooLongRecords = new Validator<OnMaxCharactersPerRecord>().validateEnum(
          config,
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

        LOG.debug("Loading inline grok dictionary:{}", dictionaryString);
      }

      loadDictionary(new StringReader(dictionaryString));
    } catch (IOException e) {
      throw new MorphlineCompilationException("Cannot compile grok dictionary", config, e);
    }

    resolveDictionaryExpressions();   
  }
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

      if (line.startsWith("#")) {
        continue; // ignore comment lines
      }
      int i = line.indexOf(" ");
      if (i < 0) {
        throw new MorphlineCompilationException("Dictionary entry line must contain a space to separate name and value: " + line, getConfig());
      }
      if (i == 0) {
        throw new MorphlineCompilationException("Dictionary entry line must contain a name: " + line, getConfig());
      }
      String name = line.substring(0, i);
      String value = line.substring(i + 1, line.length()).trim();
      if (value.length() == 0) {
        throw new MorphlineCompilationException("Dictionary entry line must contain a value: " + line, getConfig());
      }
      dictionary.put(name, value);
    }     
  }
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

        }
      }
      //LOG.debug("patternName=" + patternName + ", groupName=" + groupName + ", conversion=" + conversion);
      String refValue = dictionary.get(regexName);
      if (refValue == null) {
        throw new MorphlineCompilationException("Missing value for name: " + regexName, getConfig());
      }
      if (refValue.contains(PATTERN_START)) {
        break; // not a literal value; defer resolution until next iteration
      }
      String replacement = refValue;
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

      super(builder, config, parent, child, context);
     
      Command devNull = new DropRecordBuilder().build(null, this, null, context); // pipes into /dev/null
      List<Command> conditions = buildCommandChain(config, "conditions", devNull, true);
      if (conditions.size() == 0) {
        throw new MorphlineCompilationException("Missing conditions", config);
      } else {
        this.conditionChain = conditions.get(0);
      }

      List<Command> thenCommands = buildCommandChain(config, "then", child, true);
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

 
  public void validateArguments(Config config) {
    Set<String> recognizedArgs = getRecognizedArguments();
    for (String key : config.root().keySet()) {
      if (!recognizedArgs.contains(key)) {
        throw new MorphlineCompilationException("Unrecognized command argument: " + key +
            ", recognized arguments: " + recognizedArgs, config);
      }
    }     
  }
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

    } else if (parts.length == 2) {
      return new Locale(parts[0], parts[1]);
    } else if (parts.length == 3) {
      return new Locale(parts[0], parts[1], parts[2]);
    } else {
      throw new MorphlineCompilationException("Illegal locale: " + str, config);
    }
  } 
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

        String projectionSchemaFile = getConfigs().getString(config, "projectionSchemaFile", null);
        if (projectionSchemaFile != null) {
          try {
            projectionSchema = new Parser().parse(new File(projectionSchemaFile));
          } catch (IOException e) {
            throw new MorphlineCompilationException("Cannot parse external Avro projection schema file: " + projectionSchemaFile, config, e);
          }
        } else {
          projectionSchema = null;
        }
      }     
     
      if (projectionSchema != null) {
        AvroReadSupport.setRequestedProjection(conf, projectionSchema);
      }
     
      // configure reader schema, if any
      String readerSchemaString = getConfigs().getString(config, "readerSchemaString", null);
      Schema readerSchema;
      if (readerSchemaString != null) {
        readerSchema = new Parser().parse(readerSchemaString);
      } else {       
        String readerSchemaFile = getConfigs().getString(config, "readerSchemaFile", null);
        if (readerSchemaFile != null) {
          try {
            readerSchema = new Parser().parse(new File(readerSchemaFile));
          } catch (IOException e) {
            throw new MorphlineCompilationException("Cannot parse external Avro reader schema file: " + readerSchemaFile, config, e);
          }
        } else {
          readerSchema = null;
        }
      }     
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

   
    public Sample(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) {
      super(builder, config, parent, child, context);   
      this.probability = getConfigs().getDouble(config, "probability", 1.0);
      if (probability < 0.0) {
        throw new MorphlineCompilationException("Probability must not be negative: " + probability, config);
      }
      if (probability >= 1.0) {
        this.prng = null;
      } else {
        if (config.hasPath("seed")) {
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

      super(builder, config, parent, child, context);     
      this.inputFieldName = getConfigs().getString(config, "inputField");     
      this.outputFieldPrefix = getConfigs().getString(config, "outputFieldPrefix", "");
      this.separator = getConfigs().getString(config, "separator", "=");
      if (separator.length() == 0) {
        throw new MorphlineCompilationException("separator must not be the empty string", config);
      }
      if (getConfigs().getBoolean(config, "isRegex", false)) {
        GrokDictionaries dict = new GrokDictionaries(config, getConfigs());
        this.regex = dict.compileExpression(separator).pattern().matcher("");
      } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.