Skip to content

Init snapshot#1

Open
mkraice1 wants to merge 18 commits into
deephaven-examples:as_arraysfrom
mkraice1:init_snapshot
Open

Init snapshot#1
mkraice1 wants to merge 18 commits into
deephaven-examples:as_arraysfrom
mkraice1:init_snapshot

Conversation

@mkraice1

@mkraice1 mkraice1 commented Nov 7, 2024

Copy link
Copy Markdown

No description provided.

Comment thread src/main/java/io/deephaven/book/PriceBook.java Outdated
Comment thread src/main/java/io/deephaven/book/PriceBook.java Outdated

// 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
Copy Markdown
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
Copy Markdown
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?

Comment thread src/main/java/io/deephaven/book/PriceBook.java Outdated
Comment thread src/main/java/io/deephaven/book/PriceBook.java Outdated
Comment thread src/main/java/io/deephaven/book/PriceBook.java Outdated
Comment thread src/main/java/io/deephaven/book/PriceBook.java Outdated
* @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
Copy Markdown
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
Copy Markdown
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();

Comment thread src/main/java/io/deephaven/book/PriceBook.java Outdated
* @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
Copy Markdown
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