congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
JSONPathSpec
Code IndexAdd Tabnine to your IDE (free)

How to use
JSONPathSpec
in
org.apache.druid.java.util.common.parsers

Best Java code snippets using org.apache.druid.java.util.common.parsers.JSONPathSpec (Showing top 19 results out of 315)

origin: apache/incubator-druid

@JsonCreator
public JSONFlatDataParser(
  @JacksonInject @Json ObjectMapper jsonMapper,
  @JsonProperty("keyFieldName") final String keyFieldName,
  @JsonProperty("valueFieldName") final String valueFieldName
)
{
 Preconditions.checkArgument(!Strings.isNullOrEmpty(keyFieldName), "[keyFieldName] cannot be empty");
 Preconditions.checkArgument(!Strings.isNullOrEmpty(valueFieldName), "[valueFieldName] cannot be empty");
 this.keyFieldName = keyFieldName;
 this.valueFieldName = valueFieldName;
 // Copy jsonMapper; don't want to share canonicalization tables, etc., with the global ObjectMapper.
 this.parser = new DelegateParser(
   new JSONPathParser(
     new JSONPathSpec(
       false,
       ImmutableList.of(
         new JSONPathFieldSpec(JSONPathFieldType.ROOT, keyFieldName, keyFieldName),
         new JSONPathFieldSpec(JSONPathFieldType.ROOT, valueFieldName, valueFieldName)
       )
     ),
     jsonMapper.copy()
   ),
   keyFieldName,
   valueFieldName
 );
}
origin: apache/incubator-druid

fields.add(JSONPathFieldSpec.createJqField("hey0barx", ".hey[0].barx"));
JSONPathSpec flattenSpec = new JSONPathSpec(true, fields);
  JSONPathSpec.class
);
Assert.assertTrue(serde.isUseFieldDiscovery());
List<JSONPathFieldSpec> serdeFields = serde.getFields();
JSONPathFieldSpec foobar1 = serdeFields.get(0);
JSONPathFieldSpec baz0 = serdeFields.get(1);
origin: apache/incubator-druid

fields.add(JSONPathFieldSpec.createRootField("foo.bar1"));
JSONPathSpec flattenSpec = new JSONPathSpec(true, fields);
final StringInputRowParser parser = new StringInputRowParser(
  new JSONParseSpec(
List<JSONPathFieldSpec> fieldSpecs = parsedSpec.getFields();
Assert.assertEquals(JSONPathFieldType.ROOT, fieldSpecs.get(0).getType());
Assert.assertEquals("parseThisRootField", fieldSpecs.get(0).getName());
origin: apache/incubator-druid

for (final JSONPathFieldSpec fieldSpec : flattenSpec.getFields()) {
 final Function<T, Object> extractor;
origin: org.apache.druid/java-util

for (final JSONPathFieldSpec fieldSpec : flattenSpec.getFields()) {
 final Function<T, Object> extractor;
origin: apache/incubator-druid

@Test
public void testWithNumbers()
{
 List<JSONPathFieldSpec> fields = new ArrayList<>();
 final Parser<String, Object> jsonParser = new JSONPathParser(new JSONPathSpec(true, fields), null);
 final Map<String, Object> jsonMap = jsonParser.parseToMap(numbersJson);
 Assert.assertEquals(
   "jsonMap",
   ImmutableMap.of("five", 5.0, "six", 6L, "many", 1234567878900L, "toomany", 1.23456789E21),
   jsonMap
 );
}
origin: apache/incubator-druid

@Test
public void testSimple()
{
 List<JSONPathFieldSpec> fields = new ArrayList<>();
 final Parser<String, Object> jsonParser = new JSONPathParser(new JSONPathSpec(true, fields), null);
 final Map<String, Object> jsonMap = jsonParser.parseToMap(json);
 Assert.assertEquals(
   "jsonMap",
   ImmutableMap.of("one", "foo", "two", ImmutableList.of("bar", "baz"), "three", "qux"),
   jsonMap
 );
}
origin: apache/incubator-druid

@Test
public void testWithWhackyCharacters()
{
 List<JSONPathFieldSpec> fields = new ArrayList<>();
 final Parser<String, Object> jsonParser = new JSONPathParser(new JSONPathSpec(true, fields), null);
 final Map<String, Object> jsonMap = jsonParser.parseToMap(whackyCharacterJson);
 Assert.assertEquals(
   "jsonMap",
   ImmutableMap.of("one", "foo?"),
   jsonMap
 );
}
origin: apache/incubator-druid

public Parser getFieldDiscoveryParser()
{
 List<JSONPathFieldSpec> fields = new ArrayList<>();
 JSONPathSpec flattenSpec = new JSONPathSpec(true, fields);
 JSONParseSpec spec = new JSONParseSpec(
   new TimestampSpec("ts", "iso", null),
   new DimensionsSpec(null, null, null),
   flattenSpec,
   null
 );
 return spec.makeParser();
}
origin: apache/incubator-druid

fields.add(JSONPathFieldSpec.createNestedField("e4.e4.m4", "$['e4.e4.m4']"));
JSONPathSpec flattenSpec = new JSONPathSpec(false, fields);
JSONParseSpec spec = new JSONParseSpec(
  new TimestampSpec("ts", "iso", null),
origin: apache/incubator-druid

fields.add(JSONPathFieldSpec.createJqField("e4.e4.m4", ".e4.e4.m4"));
JSONPathSpec flattenSpec = new JSONPathSpec(true, fields);
JSONParseSpec spec = new JSONParseSpec(
  new TimestampSpec("ts", "iso", null),
origin: apache/incubator-druid

fields.add(JSONPathFieldSpec.createNestedField("e4.e4.m4", "$.e4.e4.m4"));
JSONPathSpec flattenSpec = new JSONPathSpec(true, fields);
JSONParseSpec spec = new JSONParseSpec(
  new TimestampSpec("ts", "iso", null),
origin: apache/incubator-druid

 @Test
 public void testParseFail()
 {
  List<JSONPathFieldSpec> fields = new ArrayList<>();

  thrown.expect(ParseException.class);
  thrown.expectMessage("Unable to parse row [" + notJson + "]");

  final Parser<String, Object> jsonParser = new JSONPathParser(new JSONPathSpec(true, fields), null);
  jsonParser.parseToMap(notJson);
 }
}
origin: apache/incubator-druid

@Test
public void testRejectDuplicates()
{
 List<JSONPathFieldSpec> fields = new ArrayList<>();
 fields.add(new JSONPathFieldSpec(JSONPathFieldType.PATH, "met-array", "$.met.a"));
 fields.add(new JSONPathFieldSpec(JSONPathFieldType.PATH, "met-array", "$.met.a"));
 thrown.expect(IllegalArgumentException.class);
 thrown.expectMessage("Cannot have duplicate field definition: met-array");
 final Parser<String, Object> jsonParser = new JSONPathParser(new JSONPathSpec(false, fields), null);
 jsonParser.parseToMap(nestedJson);
}
origin: apache/incubator-druid

@Test
public void testRejectDuplicates2()
{
 List<JSONPathFieldSpec> fields = new ArrayList<>();
 fields.add(new JSONPathFieldSpec(JSONPathFieldType.PATH, "met-array", "$.met.a"));
 fields.add(new JSONPathFieldSpec(JSONPathFieldType.JQ, "met-array", ".met.a"));
 thrown.expect(IllegalArgumentException.class);
 thrown.expectMessage("Cannot have duplicate field definition: met-array");
 final Parser<String, Object> jsonParser = new JSONPathParser(new JSONPathSpec(false, fields), null);
 jsonParser.parseToMap(nestedJson);
}
origin: apache/incubator-druid

fields.add(new JSONPathFieldSpec(JSONPathFieldType.JQ, "jq-met-array", ".met.a"));
final Parser<String, Object> jsonParser = new JSONPathParser(new JSONPathSpec(false, fields), null);
final Map<String, Object> jsonMap = jsonParser.parseToMap(nestedJson);
origin: apache/incubator-druid

final Parser<String, Object> jsonParser = new JSONPathParser(new JSONPathSpec(true, fields), null);
final Map<String, Object> jsonMap = jsonParser.parseToMap(nestedJson);
origin: apache/incubator-druid

@Test
public void testParseRowWithConditional()
{
 final JSONParseSpec parseSpec = new JSONParseSpec(
   new TimestampSpec("timestamp", "iso", null),
   new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("foo")), null, null),
   new JSONPathSpec(
     true,
     ImmutableList.of(
       new JSONPathFieldSpec(JSONPathFieldType.PATH, "foo", "$.[?(@.maybe_object)].maybe_object.foo.test"),
       new JSONPathFieldSpec(JSONPathFieldType.PATH, "baz", "$.maybe_object_2.foo.test"),
       new JSONPathFieldSpec(JSONPathFieldType.PATH, "bar", "$.[?(@.something_else)].something_else.foo")
     )
   ),
   null
 );
 final Map<String, Object> expected = new HashMap<>();
 expected.put("foo", new ArrayList());
 expected.put("baz", null);
 expected.put("bar", Collections.singletonList("test"));
 final Parser<String, Object> parser = parseSpec.makeParser();
 final Map<String, Object> parsedRow = parser.parseToMap("{\"something_else\": {\"foo\": \"test\"}}");
 Assert.assertNotNull(parsedRow);
 Assert.assertEquals(expected, parsedRow);
}
origin: apache/incubator-druid

new TimestampSpec("timestamp", "iso", null),
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("bar", "foo")), null, null),
new JSONPathSpec(
  true,
  ImmutableList.of(
org.apache.druid.java.util.common.parsersJSONPathSpec

Most used methods

  • <init>
  • getFields
  • isUseFieldDiscovery

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSharedPreferences (Context)
  • putExtra (Intent)
  • setContentView (Activity)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • JButton (javax.swing)
  • JComboBox (javax.swing)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now