@Override public void setSettings(Settings settings) { this.settings = settings; String paramString = settings.getUpdateScriptParams(); List<String> fields = StringUtils.tokenize(paramString); for (String string : fields) { List<String> param = StringUtils.tokenize(string, ":"); Assert.isTrue(param.size() == 2, "Invalid param definition " + string); params.put(param.get(0), createFieldExtractor(param.get(1))); } }
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)); }
private static List<String> qualifyNodes(String nodes, int defaultPort) { List<String> list = StringUtils.tokenize(nodes); for (int i = 0; i < list.size(); i++) { String host = list.get(i); list.set(i, qualifyNode(host, defaultPort)); } return list; }
// returns a map of {<column-name>:_colX} private static Map<String, String> columnMap(String columnString) { // add default aliases for serialization (mapping name -> _colX) List<String> columnNames = StringUtils.tokenize(columnString, ","); if (columnNames.isEmpty()) { return Collections.emptyMap(); } Map<String, String> columns = new LinkedHashMap<String, String>(); for (int i = 0; i < columnNames.size(); i++) { columns.put(columnNames.get(i), HiveConstants.UNNAMED_COLUMN_PREFIX + i); } return columns; }
public static Map<String, String> aliases(String definition, boolean caseInsensitive) { List<String> aliases = StringUtils.tokenize(definition); Map<String, String> aliasMap = new LinkedHashMap<String, String>(); if (aliases != null) { for (String string : aliases) { // split alias string = string.trim(); int index = string.indexOf(":"); if (index > 0) { String key = string.substring(0, index); aliasMap.put(key, string.substring(index + 1)); aliasMap.put( caseInsensitive ? key.toLowerCase(Locale.ROOT) : key, string.substring(index + 1)); } } } return aliasMap; }
static StandardStructObjectInspector structObjectInspector(Properties tableProperties) { // extract column info - don't use Hive constants as they were renamed in 0.9 breaking // compatibility // the column names are saved as the given inspector to #serialize doesn't preserves them (maybe // because it's an external table) // use the class since StructType requires it ... List<String> columnNames = StringUtils.tokenize(tableProperties.getProperty(HiveConstants.COLUMNS), ","); List<TypeInfo> colTypes = TypeInfoUtils.getTypeInfosFromTypeString( tableProperties.getProperty(HiveConstants.COLUMNS_TYPES)); // create a standard writable Object Inspector - used later on by serialization/deserialization List<ObjectInspector> inspectors = new ArrayList<ObjectInspector>(); for (TypeInfo typeInfo : colTypes) { inspectors.add(TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(typeInfo)); } return ObjectInspectorFactory.getStandardStructObjectInspector(columnNames, inspectors); }
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; }