@Nullable @Override public InputRow parse(@Nullable final String input) { return transformer.transform(super.parse(input)); }
@Override public List<InputRow> parseBatch(Object input) { if (input instanceof Text) { return ImmutableList.of(parser.parse(((Text) input).toString())); } else if (input instanceof BytesWritable) { BytesWritable valueBytes = (BytesWritable) input; return parser.parseBatch(ByteBuffer.wrap(valueBytes.getBytes(), 0, valueBytes.getLength())); } else { throw new IAE("can't convert type [%s] to InputRow", input.getClass().getName()); } }
@Nullable @Override public InputRow nextRow() { if (!hasMore()) { throw new NoSuchElementException(); } return parser.parse(lineIterator.next()); }
Assert.assertEquals("foofoo", row1bb.getRaw("expr")); final InputRow row1string = parser.parse("{\"time\":\"2000-01-01\",\"dimA\":\"foo\"}"); Assert.assertEquals(DateTimes.of("2000-01-01"), row1string.getTimestamp()); Assert.assertEquals("foo", row1string.getRaw("dimA"));
@Override public boolean processLine(String line) throws IOException { InputRow parsed = parser.parse(line); builder.append(parsed.getTimestamp()); for (String dimension : parsed.getDimensions()) { builder.append('\t'); builder.append(parsed.getRaw(dimension)); } logWriter.write(builder.toString()); builder.setLength(0); return true; }
@Override public List<InputRow> parseBatch(Object input) { if (input instanceof Text) { return ImmutableList.of(parser.parse(((Text) input).toString())); } else if (input instanceof BytesWritable) { BytesWritable valueBytes = (BytesWritable) input; return parser.parseBatch(ByteBuffer.wrap(valueBytes.getBytes(), 0, valueBytes.getLength())); } else { throw new IAE("can't convert type [%s] to InputRow", input.getClass().getName()); } }
private static List<InputRow> parseInputRow(Object value, InputRowParser parser) { if (parser instanceof StringInputRowParser && value instanceof Text) { //Note: This is to ensure backward compatibility with 0.7.0 and before //HadoopyStringInputRowParser can handle this and this special case is not needed //except for backward compatibility return Utils.nullableListOf(((StringInputRowParser) parser).parse(value.toString())); } else if (value instanceof InputRow) { return ImmutableList.of((InputRow) value); } else if (value == null) { // Pass through nulls so they get thrown away. return Utils.nullableListOf((InputRow) null); } else { return parser.parseBatch(value); } }
@Override public boolean processLine(String line) throws IOException { if (!runOnce) { startTime.set(System.currentTimeMillis()); runOnce = true; } retVal.add(parser.parse(line)); ++lineCount; return true; }
@Test public void testDisableJavaScript2() { final JavaScriptParseSpec parseSpec = new JavaScriptParseSpec( new TimestampSpec("timestamp", "auto", null), new DimensionsSpec( DimensionsSpec.getDefaultSchemas( ImmutableList.of( "dim1", "dim2" ) ), null, null ), "func", new JavaScriptConfig(false) ); final StringInputRowParser parser = new StringInputRowParser(parseSpec, "UTF-8"); expectedException.expect(CoreMatchers.instanceOf(IllegalStateException.class)); expectedException.expectMessage("JavaScript is disabled"); parser.parse(""); } }
); final InputRow parsed = parser2.parse( "{\"blah\":[4,5,6], \"newmet\":5, \"foo\":{\"bar1\":\"aaa\", \"bar2\":\"bbb\"}, \"baz\":[1,2,3], \"timestamp\":\"2999\", \"foo.bar1\":\"Hello world!\", \"hey\":[{\"barx\":\"asdf\"}], \"met\":{\"a\":456}}" );
) { for (String line : rows) { index.add(parser.parse(line));
incrementalIndex.add(parser.parse(row));
incrementalIndex.add(parser.parse(row));
index.add(((StringInputRowParser) parser).parse((String) row)); } else { index.add(((List<InputRow>) parser.parseBatch(row)).get(0));
@Nullable @Override public InputRow parse(@Nullable final String input) { return transformer.transform(super.parse(input)); }
@Nullable @Override public InputRow nextRow() { if (!hasMore()) { throw new NoSuchElementException(); } return parser.parse(lineIterator.next()); }
@Override public boolean processLine(String line) throws IOException { InputRow parsed = parser.parse(line); builder.append(parsed.getTimestamp()); for (String dimension : parsed.getDimensions()) { builder.append('\t'); builder.append(parsed.getRaw(dimension)); } logWriter.write(builder.toString()); builder.setLength(0); return true; }
private static List<InputRow> parseInputRow(Object value, InputRowParser parser) { if (parser instanceof StringInputRowParser && value instanceof Text) { //Note: This is to ensure backward compatibility with 0.7.0 and before //HadoopyStringInputRowParser can handle this and this special case is not needed //except for backward compatibility return Utils.nullableListOf(((StringInputRowParser) parser).parse(value.toString())); } else if (value instanceof InputRow) { return ImmutableList.of((InputRow) value); } else if (value == null) { // Pass through nulls so they get thrown away. return Utils.nullableListOf((InputRow) null); } else { return parser.parseBatch(value); } }