-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PathExtraction initinal implementaion #1
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
33ad390
PathExtraction initinal implementaion
raganhan 304a356
Adding a user context example
raganhan 7a22315
Wildcard escape should be first annotation
raganhan aaaa169
Make PathComponentParser static and adds a PathExtractor interface
raganhan 7536374
short circuiting zero search paths and test
raganhan ec97718
Bugfix: fails when the callback return is higher than the reader
raganhan 90ab6dd
fixing initial Tracker size
raganhan 9788b3a
renaming builder's register methods to withSearchPath
raganhan 0ef0b5d
using IonType.isContainer instead of hand coding container detection
raganhan ae5525c
adding support for specifying search paths as Ion lists
raganhan 1fd9398
Addressing multiple PR comments
raganhan 9697962
Changing README example to not depend on IonSystem
raganhan f96a8f3
README.md typos
raganhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.gradle/ | ||
.idea/ | ||
build | ||
gradle/ | ||
gradlew | ||
gradlew.bat | ||
out/ | ||
ion-c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,59 @@ | |
|
||
Ion Path Extraction API aims to combine the convenience of a DOM API with the speed of a streaming API. | ||
|
||
The traditional streaming and DOM APIs force the user to choose between speed and convenience, respectively. | ||
Path extraction APIs aim to combine the two by allowing the user to register paths into the data using just a | ||
few lines of code and receive callbacks during stream processing when any of those paths is matched. This allows | ||
the Ion reader to plan the most efficient traversal over the data without requiring further manual interaction | ||
from the user. For example, there is no reason to step in to containers which could not possibly match one of | ||
the search paths. When encoded in binary Ion, the resulting skip is a seek forward in the input stream, which | ||
is inexpensive relative to the cost of parsing (and in the case of a DOM, materializing) the skipped value. | ||
|
||
## Usage | ||
Path extractor works in two phases: | ||
1. Configuration | ||
2. Notification | ||
|
||
### Search Paths | ||
A `SearchPath` is a path provided to the extractor for matching. It's composed of a list of `PathComponent`s | ||
which can be one of: | ||
* Wildcard: matches all values | ||
* Index: match the value at that index | ||
* Text: match all values whose field names are equivalent to that text | ||
|
||
Some examples: | ||
``` | ||
data on reader: {foo: ["foo1", "foo2"] , bar: "myBarValue"} | ||
|
||
(foo 0) - matches "foo1" | ||
(1) - matches "myBarValue" | ||
(*) - matches ["foo1", "foo2"] and "myBarValue" | ||
() - matches {foo: ["foo1", "foo2"] , bar: "myBarValue"} | ||
``` | ||
|
||
### Configuration | ||
The configuration phase involves building a `PathExtractor` instance through the `PathExtractorBuilder` by setting its | ||
configuration options and registering its search paths. The built `PathExtractor` can be reused over many `IonReader`s. | ||
|
||
example: | ||
|
||
```java | ||
PathExtractorBuilder.standard() | ||
.withMatchCaseInsensitive(true) | ||
.register("(foo)", (reader) -> { ... }) | ||
.build() | ||
``` | ||
|
||
see `PathExtractorBuilder` javadoc for more information on configuration options and search path registration. | ||
|
||
### Notification | ||
Each time the `PathExtractor` encounters a value that matches a registered search path it will invoke the respective | ||
callback passing the reader positioned at the current value. See `PathExtractorBuilder#register` methods for more | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. withSearchPath |
||
information on the callback contract. | ||
|
||
## Ion Developer information | ||
See the developer guide on: http://amzn.github.io/ion-docs/guides/path-extractor-guide.html | ||
|
||
## License | ||
|
||
This library is licensed under the Apache 2.0 License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at: | ||
* | ||
* http://aws.amazon.com/apache2.0/ | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific | ||
* language governing permissions and limitations under the License. | ||
*/ | ||
|
||
buildscript { | ||
ext.ionVersion = "1.2.+" | ||
ext.kotlin_version = "1.2.+" | ||
ext.junitVersion = "5.3.+" | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
} | ||
|
||
apply plugin: "java" | ||
apply plugin: "kotlin" | ||
|
||
group 'software.amazon.ion' | ||
version '1.0-SNAPSHOT' | ||
|
||
sourceCompatibility = 1.8 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compile "software.amazon.ion:ion-java:$ionVersion" | ||
|
||
// using kotlin to make tests less verbose | ||
testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" | ||
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" | ||
|
||
// JUnit 5 | ||
testCompile "org.junit.jupiter:junit-jupiter-api:$junitVersion" | ||
testCompile "org.junit.jupiter:junit-jupiter-params:$junitVersion" | ||
testRuntime "org.junit.jupiter:junit-jupiter-engine:$junitVersion" | ||
} | ||
|
||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
apply plugin: 'checkstyle' | ||
checkstyle { | ||
toolVersion = "8.12" | ||
ignoreFailures = false | ||
maxWarnings = 0 | ||
maxErrors = 0 | ||
configDir = file("$rootProject.projectDir/config/checkstyle") | ||
} | ||
tasks.withType(Checkstyle) { | ||
reports { | ||
xml.enabled = false | ||
html.enabled = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Configuration | ||
Project development configuration files, for example code style and checkstyle settings used on all modules |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
withSearchPath