コード例 #1
0
  static void fixHive13InvalidComments(Settings settings, Properties tbl) {
    if (Booleans.parseBoolean(settings.getProperty("es.hive.disable.columns.comments.fix"))) {
      return;
    }

    settings.setProperty(HiveConstants.COLUMN_COMMENTS, "");
    tbl.remove(HiveConstants.COLUMN_COMMENTS);
  }
コード例 #2
0
 public static List<String> discoveredOrDeclaredNodes(Settings settings) {
   // returned the discovered nodes or, if not defined, the set nodes
   String discoveredNodes =
       settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_DISCOVERED_NODES);
   return (StringUtils.hasText(discoveredNodes)
       ? StringUtils.tokenize(discoveredNodes)
       : declaredNodes(settings));
 }
コード例 #3
0
  /**
   * Whether the settings indicate a ES 2.x (which introduces breaking changes) or 1.x.
   *
   * @param settings
   * @return
   */
  public static boolean isEs20(Settings settings) {
    String version = settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_VERSION);
    // assume ES 1.0 by default
    if (!StringUtils.hasText(version)) {
      return true;
    }

    return version.startsWith("2.");
  }
コード例 #4
0
  static Collection<String> columnToAlias(Settings settings) {
    FieldAlias fa = alias(settings);
    List<String> columnNames =
        StringUtils.tokenize(settings.getProperty(HiveConstants.COLUMNS), ",");
    // eliminate virtual columns
    // we can't use virtual columns since some distro don't have this field...
    //        for (VirtualColumn vc : VirtualColumn.VIRTUAL_COLUMNS) {
    //            columnNames.remove(vc.getName());
    //        }

    for (String vc : HiveConstants.VIRTUAL_COLUMNS) {
      columnNames.remove(vc);
    }

    for (int i = 0; i < columnNames.size(); i++) {
      String original = columnNames.get(i);
      String alias = fa.toES(original);
      if (alias != null) {
        columnNames.set(i, alias);
      }
    }
    return columnNames;
  }
コード例 #5
0
  static FieldAlias alias(Settings settings) {
    Map<String, String> aliasMap =
        SettingsUtils.aliases(settings.getProperty(HiveConstants.MAPPING_NAMES));

    // add default aliases for serialization (_colX -> mapping name)
    Map<String, String> columnMap = columnMap(settings);

    for (Entry<String, String> entry : columnMap.entrySet()) {
      String columnName = entry.getKey();
      String columnIndex = entry.getValue();

      if (!aliasMap.isEmpty()) {
        String alias = aliasMap.get(columnName);
        if (alias != null) {
          columnName = alias;
        }
      }

      aliasMap.put(columnIndex, columnName);
    }

    return new FieldAlias(aliasMap);
  }
コード例 #6
0
 static FieldAlias alias(Settings settings) {
   return new FieldAlias(SettingsUtils.aliases(settings.getProperty(MAPPING_NAMES), false), false);
 }
コード例 #7
0
 public static String getPinnedNode(Settings settings) {
   String node = settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_PINNED_NODE);
   Assert.hasText(node, "Task has not been pinned to a node...");
   return node;
 }
コード例 #8
0
 public static boolean hasPinnedNode(Settings settings) {
   return StringUtils.hasText(
       settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_PINNED_NODE));
 }
コード例 #9
0
 public static String[] getFilters(Settings settings) {
   return IOUtils.deserializeFromBase64(
       settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_QUERY_FILTERS));
 }
コード例 #10
0
 static Map<String, String> columnMap(Settings settings) {
   return columnMap(settings.getProperty(HiveConstants.COLUMNS));
 }