Skip to content
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

Init snapshot #1

Open
wants to merge 16 commits into
base: as_arrays
Choose a base branch
from

Conversation

mkraice1
Copy link

@mkraice1 mkraice1 commented Nov 7, 2024

No description provided.

src/main/java/io/deephaven/book/PriceBook.java Outdated Show resolved Hide resolved
src/main/java/io/deephaven/book/PriceBook.java Outdated Show resolved Hide resolved
// Begin by getting references to the column sources from the input table to process later.
this.timeSource = source.getColumnSource(timestampColumnName).reinterpret(long.class);
this.timeSource = ReinterpretUtils.instantToLongSource(source.getColumnSource(timestampColumnName));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong reinterpret here. Use timeToEpochLongSource instead. The source is probably, but not necessarily an Instant source, so you need to be more forgiving

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean zonedDateTimeToLongSource? That seems less generic I think?

src/main/java/io/deephaven/book/PriceBook.java Outdated Show resolved Hide resolved
src/main/java/io/deephaven/book/PriceBook.java Outdated Show resolved Hide resolved
src/main/java/io/deephaven/book/PriceBook.java Outdated Show resolved Hide resolved
src/main/java/io/deephaven/book/PriceBook.java Outdated Show resolved Hide resolved
* @return the Map of grouping keys to BookState
*/
final Map<Object, BookState> processInitBook(final Table t, String... groupings) {
final Map<Object, BookState> initStates = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to assert that t is not live, otherwise the calculation below will be suspect.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this do it?
assert !t.isRefreshing();

src/main/java/io/deephaven/book/PriceBook.java Outdated Show resolved Hide resolved
* @return a new table representing the current state of the book. This table will update as the source table updates.
*/
@SuppressWarnings("unused")
public static QueryTable build(@NotNull Table source,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are enough arguments here to warrant switching to a Builder pattern. We could use Immutables to generate the boilerplate builder itself and this method would simply take the result object.

Something like

    public static QueryTable of(@NotNull final BookConfig config)

and used like this

Pricebok.of(BookConfig.newBuilder()
    .thing1()
   .thing2()
   .build())

I realize that there are other factors at play so you might not have time to do this in this review, but we should definitely do this as a follow on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants