Tabnine Logo
JSONPathSpec.<init>
Code IndexAdd Tabnine to your IDE (free)

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

Best Java code snippets using org.apache.druid.java.util.common.parsers.JSONPathSpec.<init> (Showing top 17 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

@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(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(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

 @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(
origin: apache/incubator-druid

fields.add(JSONPathFieldSpec.createRootField("foo.bar1"));
JSONPathSpec flattenSpec = new JSONPathSpec(true, fields);
final StringInputRowParser parser = new StringInputRowParser(
  new JSONParseSpec(
origin: apache/incubator-druid

fields.add(JSONPathFieldSpec.createJqField("hey0barx", ".hey[0].barx"));
JSONPathSpec flattenSpec = new JSONPathSpec(true, fields);
org.apache.druid.java.util.common.parsersJSONPathSpec<init>

Popular methods of JSONPathSpec

  • getFields
  • isUseFieldDiscovery

Popular in Java

  • Creating JSON documents from java classes using gson
  • setRequestProperty (URLConnection)
  • onRequestPermissionsResult (Fragment)
  • startActivity (Activity)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • PhpStorm for WordPress
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