-
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
Add topic, partition, and timestamp column kafka publishing support #4771
Merged
devinrsmith
merged 10 commits into
deephaven:main
from
devinrsmith:kafka-record-fields-from-column-source
Nov 17, 2023
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
eaec33d
Add topic, partition, and timestamp column kafka publishing support
devinrsmith 988fb4a
Fix NPE
devinrsmith e800f02
review todo
devinrsmith dddd97f
f
devinrsmith c7cef18
f
devinrsmith 2b43f09
Merge remote-tracking branch 'upstream/main' into kafka-record-fields…
devinrsmith 79e9e07
Update after merge
devinrsmith 4ce2e76
More docs
devinrsmith 564530c
Review response
devinrsmith 3f5e5a1
Review response
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -504,6 +504,28 @@ public void describeDifferences(@NotNull List<String> differences, @NotNull fina | |
} | ||
} | ||
|
||
/** | ||
* Checks if {@link #getDataType() dataType} can be cast to {@code destDataType}. If not, this throws a | ||
* {@link ClassCastException}. | ||
* | ||
* @param destDataType the destination data type | ||
*/ | ||
public final void checkCastTo(Class<?> destDataType) { | ||
TypeHelper.checkCastTo("[" + name + "]", dataType, destDataType); | ||
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. This context being passed does not mesh well with the exception message as currently composed. 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. I think you took back this point.
devinrsmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/** | ||
* Checks if {@link #getDataType() dataType} can be cast to {@code destDataType} and checks that | ||
* {@link #getComponentType() componentType} can be cast to {@code destComponentType} (both component types must be | ||
* present and cast-able, or both must be {@code null}). If not, this throws a {@link ClassCastException}. | ||
* | ||
* @param destDataType the destination data type | ||
* @param destComponentType the destination component type, may be {@code null} | ||
*/ | ||
public final void checkCastTo(Class<?> destDataType, @Nullable Class<?> destComponentType) { | ||
TypeHelper.checkCastTo("[" + name + "]", dataType, componentType, destDataType, destComponentType); | ||
} | ||
|
||
public boolean equals(final Object other) { | ||
if (this == other) { | ||
return 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
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
36 changes: 36 additions & 0 deletions
36
engine/api/src/main/java/io/deephaven/engine/table/TypeHelper.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,36 @@ | ||
/** | ||
* Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending | ||
*/ | ||
package io.deephaven.engine.table; | ||
|
||
class TypeHelper { | ||
|
||
// Could be good to move this to io.deephaven.qst.type.Type layer | ||
|
||
public static void checkCastTo(String context, Class<?> srcType, Class<?> destType) { | ||
if (!destType.isAssignableFrom(srcType)) { | ||
throw new ClassCastException(String.format("Cannot convert %s of type %s to type %s", | ||
context, srcType.getName(), destType.getName())); | ||
} | ||
} | ||
|
||
public static void checkCastTo( | ||
String prefix, | ||
Class<?> srcType, | ||
Class<?> srcComponentType, | ||
Class<?> destType, | ||
Class<?> destComponentType) { | ||
checkCastTo(prefix, srcType, destType); | ||
if ((srcComponentType == null && destComponentType == null) || (srcComponentType != null | ||
&& destComponentType != null && destComponentType.isAssignableFrom(srcComponentType))) { | ||
return; | ||
} | ||
throw new ClassCastException(String.format( | ||
"Cannot convert %s componentType of type %s to %s (for %s / %s)", | ||
prefix, | ||
srcComponentType == null ? null : srcComponentType.getName(), | ||
destComponentType == null ? null : destComponentType.getName(), | ||
srcType.getName(), | ||
destType.getName())); | ||
} | ||
} |
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
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.
Usually we just have a
cast
method that returns the type we like and (maybe) validates internally.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.
I think it's a little bit different w/
ColumnDefinition
. In other cases cases wherecast
is used, it is typically done to match types b/c the consumer wants to get data out. In this case,ColumnDefinition
itself doesn't hold any data, it is just parameterized to support explicit typing aroundClass <TYPE> getDataType()
.I don't see a practical use for wanting to actually cast a definition. Furthermore, it breaks the contract:
We do play loose and fast with this in other places;
ColumnSource
suffers from the samegetType
problem - although again,ColumnSource#cast
is usually used to get data out (not b/c somebody wantsgetType
).In some more recent code, I've tried to "do the right thing";
io.deephaven.functions.ToObjectFunction#cast