Package org.elasticsearch.hadoop.util

Examples of org.elasticsearch.hadoop.util.FieldAlias


    static StructTypeInfo typeInfo(StructObjectInspector inspector) {
        return (StructTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(inspector);
    }

    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;
View Full Code Here


            }

            aliasMap.put(columnIndex, columnName);
        }

        return new FieldAlias(aliasMap);
    }
View Full Code Here

    static StructTypeInfo typeInfo(StructObjectInspector inspector) {
        return (StructTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(inspector);
    }

    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;
View Full Code Here

            }

            aliasMap.put(columnIndex, columnName);
        }

        return new FieldAlias(aliasMap);
    }
View Full Code Here

            }
        }
    }

    static FieldAlias alias(Settings settings) {
        return new FieldAlias(SettingsUtils.aliases(settings.getProperty(MAPPING_NAMES)));
    }
View Full Code Here

        return names;
    }

    static Collection<String> fieldToAlias(Settings settings, Fields fields) {
        FieldAlias fa = alias(settings);
        List<String> names = asStrings(fields);
        for (int i = 0; i < names.size(); i++) {
            String original = names.get(i);
            String alias = fa.toES(original);
            if (alias != null) {
                names.set(i, alias);
            }
        }
        return names;
View Full Code Here

            return ISODateTimeFormat.dateOptionalTimeParser().parseDateTime(esDate);
        }
    }

    static FieldAlias alias(Settings settings) {
        return new FieldAlias(SettingsUtils.aliases(settings.getProperty(MAPPING_NAMES)));
    }
View Full Code Here

        }
    }

    static String asProjection(RequiredFieldList list, Properties props) {
        List<String> fields = new ArrayList<String>();
        FieldAlias alias = alias(new PropertiesSettings(props));
        for (RequiredField field : list.getFields()) {
            addField(field, fields, alias, "");
        }

        return StringUtils.concatenate(fields.toArray(new String[fields.size()]), ",");
View Full Code Here

    }

    public PigValueWriter(boolean useTupleFieldNames) {
        writeUnknownTypes = false;
        this.useTupleFieldNames = useTupleFieldNames;
        alias = new FieldAlias();
    }
View Full Code Here

            return false;
        }

        TupleEntry entry = sourceCall.getIncomingEntry();
        Map<String, ?> data = (Map<String, ?>) query.next()[1];
        FieldAlias alias = (FieldAlias) sourceCall.getContext()[0];

        if (entry.getFields().isDefined()) {
            // lookup using writables
            // TODO: it's worth benchmarking whether using an index/offset yields significantly better performance
            for (Comparable<?> field : entry.getFields()) {
                if (IS_ES_10) {
                    Object result = data;
                    // check for multi-level alias
                    for (String level : StringUtils.tokenize(alias.toES(field.toString()), ".")) {
                        result = ((Map) result).get(level);
                        if (result == null) {
                            break;
                        }
                    }
                    entry.setObject(field, result);
                }
                else {
                    //NB: coercion should be applied automatically by the TupleEntry
                    entry.setObject(field, data.get(alias.toES(field.toString())));
                }
            }
        }
        else {
            // no definition means no coercion
View Full Code Here

TOP

Related Classes of org.elasticsearch.hadoop.util.FieldAlias

Copyright © 2018 www.massapicom. 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.