当前位置: 首页>>代码示例>>Java>>正文


Java StoredAsProperty类代码示例

本文整理汇总了Java中com.cloudera.sqoop.util.StoredAsProperty的典型用法代码示例。如果您正苦于以下问题:Java StoredAsProperty类的具体用法?Java StoredAsProperty怎么用?Java StoredAsProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StoredAsProperty类属于com.cloudera.sqoop.util包,在下文中一共展示了StoredAsProperty类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeProperties

import com.cloudera.sqoop.util.StoredAsProperty; //导入依赖的package包/类
/**
 * Return a Properties instance that encapsulates all the "sticky"
 * state of this SqoopOptions that should be written to a metastore
 * to restore the job later.
 */
public Properties writeProperties() {
  Properties props = new Properties();

  try {
    Field [] fields = SqoopOptions.class.getDeclaredFields();
    for (Field f : fields) {
      if (f.isAnnotationPresent(StoredAsProperty.class)) {
        Class typ = f.getType();
        StoredAsProperty storedAs = f.getAnnotation(StoredAsProperty.class);
        String propName = storedAs.value();

        if (typ.equals(int.class)) {
          putProperty(props, propName, Integer.toString(f.getInt(this)));
        } else if (typ.equals(boolean.class)) {
          putProperty(props, propName, Boolean.toString(f.getBoolean(this)));
        } else if (typ.equals(long.class)) {
          putProperty(props, propName, Long.toString(f.getLong(this)));
        } else if (typ.equals(String.class)) {
          putProperty(props, propName, (String) f.get(this));
        } else if (typ.equals(Integer.class)) {
          putProperty(
              props,
              propName,
              f.get(this) == null ? "null" : f.get(this).toString());
        } else if (typ.isEnum()) {
          putProperty(props, propName, f.get(this).toString());
        } else if (typ.equals(Map.class)) {
          putProperty(
              props,
              propName,
              SqoopJsonUtil.getJsonStringforMap((Map) f.get(this)));
        } else {
          throw new RuntimeException("Could not set property "
              + propName + " for type: " + typ);
        }
      }
    }
  } catch (IllegalAccessException iae) {
    throw new RuntimeException("Illegal access to field in property setter",
        iae);
  }

  writePasswordProperty(props);

  putProperty(props, "db.column.list", arrayToList(this.columns));
  setDelimiterProperties(props, "codegen.input.delimiters",
      this.inputDelimiters);
  setDelimiterProperties(props, "codegen.output.delimiters",
      this.outputDelimiters);
  setArgArrayProperties(props, "tool.arguments", this.extraArgs);

  setPropertiesAsNestedProperties(props,
          "db.connect.params", this.connectionParams);

  setPropertiesAsNestedProperties(props,
          "map.column.hive", this.mapColumnHive);
  setPropertiesAsNestedProperties(props,
          "map.column.java", this.mapColumnJava);
  setPropertiesAsNestedProperties(props,
          "map.column.odps", this.mapColumnOdps);
  return props;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:68,代码来源:SqoopOptions.java

示例2: writeProperties

import com.cloudera.sqoop.util.StoredAsProperty; //导入依赖的package包/类
/**
 * Return a Properties instance that encapsulates all the "sticky"
 * state of this SqoopOptions that should be written to a metastore
 * to restore the job later.
 */
public Properties writeProperties() {
	Properties props = new Properties();

	try {
		Field [] fields = SqoopOptions.class.getDeclaredFields();
		for (Field f : fields) {
			if (f.isAnnotationPresent(StoredAsProperty.class)) {
				Class typ = f.getType();
				StoredAsProperty storedAs = f.getAnnotation(StoredAsProperty.class);
				String propName = storedAs.value();

				if (typ.equals(int.class)) {
					putProperty(props, propName, Integer.toString(f.getInt(this)));
				} else if (typ.equals(boolean.class)) {
					putProperty(props, propName, Boolean.toString(f.getBoolean(this)));
				} else if (typ.equals(long.class)) {
					putProperty(props, propName, Long.toString(f.getLong(this)));
				} else if (typ.equals(String.class)) {
					putProperty(props, propName, (String) f.get(this));
				} else if (typ.equals(Integer.class)) {
					putProperty(
							props,
							propName,
							f.get(this) == null ? "null" : f.get(this).toString());
				} else if (typ.isEnum()) {
					putProperty(props, propName, f.get(this).toString());
				} else {
					throw new RuntimeException("Could not set property "
							+ propName + " for type: " + typ);
				}
			}
		}
	} catch (IllegalAccessException iae) {
		throw new RuntimeException("Illegal access to field in property setter",
				iae);
	}

	writePasswordProperty(props);

	putProperty(props, "db.column.list", arrayToList(this.columns));
	setDelimiterProperties(props, "codegen.input.delimiters",
			this.inputDelimiters);
	setDelimiterProperties(props, "codegen.output.delimiters",
			this.outputDelimiters);
	setArgArrayProperties(props, "tool.arguments", this.extraArgs);

	setPropertiesAsNestedProperties(props,
			"db.connect.params", this.connectionParams);

	setPropertiesAsNestedProperties(props,
			"map.column.hive", this.mapColumnHive);
	setPropertiesAsNestedProperties(props,
			"map.column.java", this.mapColumnJava);
	return props;
}
 
开发者ID:unicredit,项目名称:zSqoop,代码行数:61,代码来源:SqoopOptions.java

示例3: writeProperties

import com.cloudera.sqoop.util.StoredAsProperty; //导入依赖的package包/类
/**
 * Return a Properties instance that encapsulates all the "sticky"
 * state of this SqoopOptions that should be written to a metastore
 * to restore the job later.
 */
public Properties writeProperties() {
  Properties props = new Properties();

  try {
    Field [] fields = SqoopOptions.class.getDeclaredFields();
    for (Field f : fields) {
      if (f.isAnnotationPresent(StoredAsProperty.class)) {
        Class typ = f.getType();
        StoredAsProperty storedAs = f.getAnnotation(StoredAsProperty.class);
        String propName = storedAs.value();

        if (typ.equals(int.class)) {
          putProperty(props, propName, Integer.toString(f.getInt(this)));
        } else if (typ.equals(boolean.class)) {
          putProperty(props, propName, Boolean.toString(f.getBoolean(this)));
        } else if (typ.equals(long.class)) {
          putProperty(props, propName, Long.toString(f.getLong(this)));
        } else if (typ.equals(String.class)) {
          putProperty(props, propName, (String) f.get(this));
        } else if (typ.equals(Integer.class)) {
          putProperty(
              props,
              propName,
              f.get(this) == null ? "null" : f.get(this).toString());
        } else if (typ.isEnum()) {
          putProperty(props, propName, f.get(this).toString());
        } else {
          throw new RuntimeException("Could not set property "
              + propName + " for type: " + typ);
        }
      }
    }
  } catch (IllegalAccessException iae) {
    throw new RuntimeException("Illegal access to field in property setter",
        iae);
  }


  if (this.getConf().getBoolean(
      METASTORE_PASSWORD_KEY, METASTORE_PASSWORD_DEFAULT)) {
    // If the user specifies, we may store the password in the metastore.
    putProperty(props, "db.password", this.password);
    putProperty(props, "db.require.password", "false");
  } else if (this.password != null) {
    // Otherwise, if the user has set a password, we just record
    // a flag stating that the password will need to be reentered.
    putProperty(props, "db.require.password", "true");
  } else {
    // No password saved or required.
    putProperty(props, "db.require.password", "false");
  }

  putProperty(props, "db.column.list", arrayToList(this.columns));
  setDelimiterProperties(props, "codegen.input.delimiters",
      this.inputDelimiters);
  setDelimiterProperties(props, "codegen.output.delimiters",
      this.outputDelimiters);
  setArgArrayProperties(props, "tool.arguments", this.extraArgs);

  setPropertiesAsNestedProperties(props,
          "db.connect.params", this.connectionParams);

  setPropertiesAsNestedProperties(props,
          "map.column.hive", this.mapColumnHive);
  setPropertiesAsNestedProperties(props,
          "map.column.java", this.mapColumnJava);
  return props;
}
 
开发者ID:infinidb,项目名称:sqoop,代码行数:74,代码来源:SqoopOptions.java


注:本文中的com.cloudera.sqoop.util.StoredAsProperty类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。