-
Notifications
You must be signed in to change notification settings - Fork 80
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
JSON configuration and Jackson Streaming Object Processor #5225
Merged
Merged
Changes from 2 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
1320749
JSON configuration and Processor
devinrsmith bb1d02e
spotless
devinrsmith 5c7dde9
review response
devinrsmith 44f4bc9
spotless
devinrsmith c567c21
Boxed builders
devinrsmith 60fad28
Make universe implementation / documentation detail
devinrsmith 2358a24
f
devinrsmith 50ec4cb
Rename to Value
devinrsmith 5dc5aa8
unmodifiable set
devinrsmith 26ff817
f
devinrsmith 14eadba
f
devinrsmith 5c65852
f
devinrsmith 979bdfa
ValueInnerRepeaterProcessor
devinrsmith fd3f6ed
ValueProcessor knows types
devinrsmith a16b30f
f
devinrsmith f564bc4
f
devinrsmith f4c674e
f
devinrsmith 6f45aa7
some review responses
devinrsmith 6d4ebef
f
devinrsmith 32841a5
f
devinrsmith 7a1a2d3
Merge remote-tracking branch 'upstream/main' into json-config-review
devinrsmith 2d73895
exceptions
devinrsmith c6f098b
tests
devinrsmith cf81769
Rename tests
devinrsmith 8d1e377
f
devinrsmith 5828f1a
stuff
devinrsmith 5022c2d
Tests and stuff
devinrsmith 88db86d
Typed object improvements
devinrsmith f4b60c2
Array maths
devinrsmith 52e5932
deeply nested array test
devinrsmith dbb66de
array stuff
devinrsmith 0c0760e
kv mixin
devinrsmith c9c20e0
mixin consolidation
devinrsmith f979b56
discriminated object
devinrsmith 2338fa0
outputSize
devinrsmith 34dda0c
cleanup
devinrsmith 9fccd9d
Instant array types
devinrsmith c4cae88
Merge remote-tracking branch 'upstream/main' into json-config-review
devinrsmith a389e88
Introduce ObjectChunkDeepEquals
devinrsmith 91c2990
Move LongRepeaterImpl to LongMixin
devinrsmith 1526eb4
Remove some exceptions
devinrsmith 30ef952
math util
devinrsmith c0ab02a
Update python
devinrsmith 08e44de
Review responses
devinrsmith aeb4628
Merge remote-tracking branch 'upstream/main' into json-config-review
devinrsmith 6a6f383
Add python json tests
devinrsmith c7fc14b
Fix test
devinrsmith 10b7794
Undo ChunkEquals interface changes in light of #5605
devinrsmith c26304e
Fix on_null, on_missing, add tests
devinrsmith fb9d759
object_processor_spec, jackson provider python construction test
devinrsmith 258a8b8
Add JacksonProvider documentation
devinrsmith 1683d9e
Review points
devinrsmith c53262c
Python _val
devinrsmith 3cf7e9f
rename ObjectKvValue to ObjectEntriesValue
devinrsmith 7e81e41
Review responses
devinrsmith b319512
Add high-level example documentation is python json module
devinrsmith 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
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
94 changes: 94 additions & 0 deletions
94
engine/processor/src/main/java/io/deephaven/processor/NamedObjectProcessor.java
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,94 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.processor; | ||
|
||
import io.deephaven.annotations.BuildableStyle; | ||
import io.deephaven.qst.type.Type; | ||
import org.immutables.value.Value.Check; | ||
import org.immutables.value.Value.Immutable; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
@Immutable | ||
@BuildableStyle | ||
public abstract class NamedObjectProcessor<T> { | ||
|
||
public static <T> Builder<T> builder() { | ||
return ImmutableNamedObjectProcessor.builder(); | ||
} | ||
|
||
public static <T> NamedObjectProcessor<T> of(ObjectProcessor<? super T> processor, String... names) { | ||
return NamedObjectProcessor.<T>builder().processor(processor).addNames(names).build(); | ||
} | ||
|
||
public static <T> NamedObjectProcessor<T> of(ObjectProcessor<? super T> processor, Iterable<String> names) { | ||
return NamedObjectProcessor.<T>builder().processor(processor).addAllNames(names).build(); | ||
} | ||
|
||
public static <T> NamedObjectProcessor<T> prefix(ObjectProcessor<T> processor, String prefix) { | ||
rcaudy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
final int size = processor.size(); | ||
if (size == 1) { | ||
return of(processor, prefix); | ||
} | ||
return of(processor, IntStream.range(0, size).mapToObj(ix -> prefix + "_" + ix).collect(Collectors.toList())); | ||
} | ||
|
||
/** | ||
* The name for each output of {@link #processor()}. | ||
*/ | ||
public abstract List<String> names(); | ||
|
||
/** | ||
* The object processor. | ||
*/ | ||
public abstract ObjectProcessor<? super T> processor(); | ||
|
||
public interface Builder<T> { | ||
Builder<T> processor(ObjectProcessor<? super T> processor); | ||
|
||
Builder<T> addNames(String element); | ||
|
||
Builder<T> addNames(String... elements); | ||
|
||
Builder<T> addAllNames(Iterable<String> elements); | ||
|
||
NamedObjectProcessor<T> build(); | ||
} | ||
|
||
public interface Provider extends ObjectProcessor.Provider { | ||
|
||
/** | ||
* The name for each output of the processors. Equivalent to the named processors' | ||
* {@link NamedObjectProcessor#names()}. | ||
* | ||
* @return the names | ||
*/ | ||
List<String> names(); | ||
|
||
/** | ||
* Creates a named object processor that can process the {@code inputType}. This will successfully create a | ||
* named processor when {@code inputType} is one of, or extends from one of, {@link #inputTypes()}. Otherwise, | ||
* an {@link IllegalArgumentException} will be thrown. Equivalent to | ||
* {@code NamedObjectProcessor.of(processor(inputType), names())}. | ||
* | ||
* @param inputType the input type | ||
* @return the object processor | ||
* @param <T> the input type | ||
*/ | ||
default <T> NamedObjectProcessor<? super T> named(Type<T> inputType) { | ||
return NamedObjectProcessor.of(processor(inputType), names()); | ||
} | ||
} | ||
|
||
@Check | ||
final void checkSizes() { | ||
if (names().size() != processor().size()) { | ||
throw new IllegalArgumentException( | ||
String.format("Unmatched sizes; columnNames().size()=%d, processor().size()=%d", | ||
devinrsmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
names().size(), processor().size())); | ||
} | ||
} | ||
} |
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
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
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
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
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,23 @@ | ||
plugins { | ||
id 'java-library' | ||
id 'io.deephaven.project.register' | ||
} | ||
|
||
dependencies { | ||
api project(':extensions-json-jackson') | ||
api project(':engine-processor') | ||
api 'de.undercouch:bson4jackson:2.15.1' | ||
|
||
Classpaths.inheritImmutables(project) | ||
compileOnly 'com.google.code.findbugs:jsr305:3.0.2' | ||
|
||
Classpaths.inheritJacksonPlatform(project, 'testImplementation') | ||
Classpaths.inheritJUnitPlatform(project) | ||
Classpaths.inheritAssertJ(project) | ||
testImplementation 'org.junit.jupiter:junit-jupiter' | ||
testImplementation 'com.fasterxml.jackson.core:jackson-databind' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} |
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 @@ | ||
io.deephaven.project.ProjectType=JAVA_PUBLIC |
30 changes: 30 additions & 0 deletions
30
...nsions/bson-jackson/src/main/java/io/deephaven/bson/jackson/JacksonBsonConfiguration.java
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,30 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.bson.jackson; | ||
|
||
import com.fasterxml.jackson.core.ObjectCodec; | ||
import de.undercouch.bson4jackson.BsonFactory; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
|
||
final class JacksonBsonConfiguration { | ||
private static final BsonFactory DEFAULT_FACTORY; | ||
|
||
static { | ||
// We'll attach an ObjectMapper if it's on the classpath, this allows parsing of AnyOptions | ||
ObjectCodec objectCodec = null; | ||
try { | ||
final Class<?> clazz = Class.forName("com.fasterxml.jackson.databind.ObjectMapper"); | ||
objectCodec = (ObjectCodec) clazz.getDeclaredConstructor().newInstance(); | ||
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | ||
| InvocationTargetException e) { | ||
// ignore | ||
} | ||
DEFAULT_FACTORY = new BsonFactory(objectCodec); | ||
} | ||
|
||
static BsonFactory defaultFactory() { | ||
return DEFAULT_FACTORY; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
extensions/bson-jackson/src/main/java/io/deephaven/bson/jackson/JacksonBsonProvider.java
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,33 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.bson.jackson; | ||
|
||
import de.undercouch.bson4jackson.BsonFactory; | ||
import io.deephaven.json.ValueOptions; | ||
import io.deephaven.json.jackson.JacksonProvider; | ||
|
||
public final class JacksonBsonProvider { | ||
|
||
/** | ||
* Creates a jackson BSON provider using a default factory. | ||
* | ||
* @param options the object options | ||
* @return the jackson BSON provider | ||
* @see #of(ValueOptions, BsonFactory) | ||
*/ | ||
public static JacksonProvider of(ValueOptions options) { | ||
return of(options, JacksonBsonConfiguration.defaultFactory()); | ||
} | ||
|
||
/** | ||
* Creates a jackson BSON provider using the provided {@code factory}. | ||
* | ||
* @param options the object options | ||
* @param factory the jackson BSON factory | ||
* @return the jackson BSON provider | ||
*/ | ||
public static JacksonProvider of(ValueOptions options, BsonFactory factory) { | ||
return JacksonProvider.of(options, factory); | ||
} | ||
} |
Oops, something went wrong.
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.
It throws me off that that this "has an"
ObjectProcessor
rather than "is an"ObjectProcessor
.