@Override public Map<String, Object> parseToMap(String input) { try { final Matcher matcher = compiled.matcher(input); if (!matcher.matches()) { throw new ParseException("Incorrect Regex: %s . No match found.", pattern); } List<String> values = new ArrayList<>(); for (int i = 1; i <= matcher.groupCount(); i++) { values.add(matcher.group(i)); } if (fieldNames == null) { setFieldNames(ParserUtils.generateFieldNames(values.size())); } return Utils.zipMapPartial(fieldNames, Iterables.transform(values, valueFunction)); } catch (Exception e) { throw new ParseException(e, "Unable to parse row [%s]", input); } }
@Override public Map<String, Object> parseToMap(final String input) { if (!supportSkipHeaderRows && (hasHeaderRow || maxSkipHeaderRows > 0)) { throw new UnsupportedOperationException("hasHeaderRow or maxSkipHeaderRows is not supported. " + "Please check the indexTask supports these options."); } try { List<String> values = parseLine(input); if (skippedHeaderRows < maxSkipHeaderRows) { skippedHeaderRows++; return null; } if (hasHeaderRow && !hasParsedHeader) { if (fieldNames == null) { setFieldNames(values); } hasParsedHeader = true; return null; } if (fieldNames == null) { setFieldNames(ParserUtils.generateFieldNames(values.size())); } return Utils.zipMapPartial(fieldNames, Iterables.transform(values, valueFunction)); } catch (Exception e) { throw new ParseException(e, "Unable to parse row [%s]", input); } }
@Override public Map<String, Object> parseToMap(String input) { try { final Matcher matcher = compiled.matcher(input); if (!matcher.matches()) { throw new ParseException("Incorrect Regex: %s . No match found.", pattern); } List<String> values = Lists.newArrayList(); for (int i = 1; i <= matcher.groupCount(); i++) { values.add(matcher.group(i)); } if (fieldNames == null) { setFieldNames(ParserUtils.generateFieldNames(values.size())); } return Utils.zipMapPartial(fieldNames, Iterables.transform(values, valueFunction)); } catch (Exception e) { throw new ParseException(e, "Unable to parse row [%s]", input); } }
@Override public Map<String, Object> parseToMap(final String input) { if (!supportSkipHeaderRows && (hasHeaderRow || maxSkipHeaderRows > 0)) { throw new UnsupportedOperationException("hasHeaderRow or maxSkipHeaderRows is not supported. " + "Please check the indexTask supports these options."); } try { List<String> values = parseLine(input); if (skippedHeaderRows < maxSkipHeaderRows) { skippedHeaderRows++; return null; } if (hasHeaderRow && !hasParsedHeader) { if (fieldNames == null) { setFieldNames(values); } hasParsedHeader = true; return null; } if (fieldNames == null) { setFieldNames(ParserUtils.generateFieldNames(values.size())); } return Utils.zipMapPartial(fieldNames, Iterables.transform(values, valueFunction)); } catch (Exception e) { throw new ParseException(e, "Unable to parse row [%s]", input); } }