/** * Sets the delimiter. * * @param delimiter The delimiter. */ @HadoopConf(key=CONF_FIELD_DELIMITER, defaultValue=DEFAULT_FIELD_DELIMITER) protected void setFieldDelimiter(String delimiter) { if (delimiter.length() != 1) { throw new RuntimeException("Delimiter must be exactly one character long." + " Received: \"" + delimiter + "\"."); } mFieldDelimiter = delimiter; }
/** * Gets the default value specified by the annotation. * * @return The default value. */ private String getDefault() { return mAnnotation.defaultValue(); } }
/** * Gets the configuration key that should be used to populate the field. * * @return The key that was specified in the HadoopConf annotation. */ public String getKey() { return mAnnotation.key(); }
/** * Sets the log rate - the number of lines between log statements for incomplete/rejected lines. * * @param logRateString The logging rate as a string. */ @HadoopConf(key=CONF_LOG_RATE, usage="The number of lines to skip between log statements") protected final void setLogRate(String logRateString) { if (logRateString != null) { try { Long logRate = Long.parseLong(logRateString); mLogRate = logRate; } catch (NumberFormatException ne) { LOG.warn("Unable to parse log rate: " + logRateString); } } }
/** * Gets the default value as a string. * * @param instance The object instance. * @return The default string value. * @throws IllegalAccessException If the field cannot be read. */ private String getDefaultString(Object instance) throws IllegalAccessException { String defaultValue = mAnnotation.defaultValue(); if (defaultValue.isEmpty()) { return (String) mField.get(instance); } return defaultValue; } }
/** * Gets the configuration key that should be used to populate the field. * * @return The key that was specified in the HadoopConf annotation. */ public String getKey() { return mAnnotation.key(); }
public static final String CONF_REGEX = "fiji.regexproducer.regex"; @HadoopConf(key=CONF_INPUT_COLUMN, usage="The input column name.") private String mInputColumn; @HadoopConf(key=CONF_OUTPUT_COLUMN, usage="The output column name.") private String mOutputColumn; @HadoopConf(key=CONF_REGEX, usage="The regular expression used to extract from the input column.") private String mRegex;
/** * Gets the default value as a boolean. * * @param instance The object instance. * @return The default boolean value. * @throws IllegalAccessException If the field cannot be read. */ private boolean getDefaultBoolean(Object instance) throws IllegalAccessException { String defaultValue = mAnnotation.defaultValue(); if (defaultValue.isEmpty()) { return mField.getBoolean(instance); } return Boolean.parseBoolean(defaultValue); }
/** * Sets the output column name. * * @param column The output column. */ @HadoopConf(key=CONF_OUTPUT, usage="The output column name.") protected void setOutputColumn(String column) { if (null == column || column.isEmpty()) { throw new RuntimeException("Must specify " + CONF_OUTPUT); } mOutputColumn = new FijiColumnName(column); }
/** * Gets the default value as an int. * * @param instance The object instance. * @return The default int value. * @throws IllegalAccessException If the field cannot be read. */ private int getDefaultInt(Object instance) throws IllegalAccessException { String defaultValue = mAnnotation.defaultValue(); if (defaultValue.isEmpty()) { return mField.getInt(instance); } return Integer.parseInt(defaultValue); }
/** * Sets the input column name. * * @param column The input column. */ @HadoopConf(key=CONF_INPUT, usage="The input column name.") protected void setInputColumn(String column) { if (null == column || column.isEmpty()) { throw new RuntimeException("Must specify " + CONF_INPUT); } mInputColumn = new FijiColumnName(column); }
/** * Gets the default value as a long. * * @param instance The object instance. * @return The default long value. * @throws IllegalAccessException If the field cannot be read. */ private long getDefaultLong(Object instance) throws IllegalAccessException { String defaultValue = mAnnotation.defaultValue(); if (defaultValue.isEmpty()) { return mField.getLong(instance); } return Long.parseLong(defaultValue); }
@HadoopConf(key=CONF_MAX_VERSIONS, usage="Max number of versions to return for any key.") private int mMaxVersions = 1;
/** * Gets the default value as a double. * * @param instance The object instance. * @return The default double value. * @throws IllegalAccessException If the field cannot be read. */ private float getDefaultDouble(Object instance) throws IllegalAccessException { String defaultValue = mAnnotation.defaultValue(); if (defaultValue.isEmpty()) { return (float) mField.getDouble(instance); } return Float.parseFloat(defaultValue); }
/** * Sets the path to the text input descriptor file and parses it. * * @param inputDescriptorFile The input descriptor path. * @throws RuntimeException if there's an error reading or parsing the input descriptor. */ @HadoopConf(key=CONF_FILE, usage="The input descriptor file.") protected final void setInputDescriptorPath(String inputDescriptorFile) { if (null == inputDescriptorFile || inputDescriptorFile.isEmpty()) { // Remind the user to specify this path. LOG.error("No input-descriptor path specified."); throw new RuntimeException("No input descriptor file specified on the Configuration." + " Did you specify the " + CONF_FILE + " variable?"); } Path descriptorPath = new Path(inputDescriptorFile); try { LOG.info("Parsing input-descriptor file: " + descriptorPath.toString()); FileSystem fs = descriptorPath.getFileSystem(getConf()); FSDataInputStream inputStream = fs.open(descriptorPath); mTableImportDescriptor = FijiTableImportDescriptor.createFromEffectiveJson(inputStream); } catch (IOException ioe) { LOG.error("Could not read input-descriptor file: " + descriptorPath.toString()); throw new RuntimeException("Could not read file: " + descriptorPath.toString(), ioe); } } }
/** * Gets the default value as a float. * * @param instance The object instance. * @return The default float value. * @throws IllegalAccessException If the field cannot be read. */ private float getDefaultFloat(Object instance) throws IllegalAccessException { String defaultValue = mAnnotation.defaultValue(); if (defaultValue.isEmpty()) { return mField.getFloat(instance); } return Float.parseFloat(defaultValue); }
/** * Sets the family. * * @param family The family. */ @HadoopConf(key=CONF_EXPORT_FAMILY) protected void setFamily(String family) { FijiColumnName name = new FijiColumnName(family); if (name.isFullyQualified()) { throw new RuntimeException("Expected an unqualified map type family. " + "Requested family was: " + name.getName()); } mFamily = family; }
+ instance.getClass().getName() + "." + mField.getName()); if (null == conf.get(key) && mAnnotation.defaultValue().isEmpty()) {
@HadoopConf(key=CONF_COLUMN_DESCRIPTORS) protected void setColumnDescriptors(String[] columnDescriptors) { if (null == columnDescriptors || 0 == columnDescriptors.length) {
@HadoopConf(key=CONF_FIELD_DELIMITER) private String mColumnDelimiter = CSV_DELIMITER;