How do I control what objects are displayed in the console?
In the Deephaven IDE, the console doesn't automatically open a panel for a variable whose name starts with an underscore. The variable still exists and you can open it manually.
Consider the following query that creates three named tables:
When this query runs, panels for cryptoTrades, lastTrades, and lastTradesWithPriceTimesSize open in the IDE. However, if you do not want to display lastTrades, you can add a leading underscore to the table name:
Variables that a Groovy script assigns without def or a type go into the script's binding. The binding is the set of named variables that the console keeps after the script finishes and that the IDE can display. In the following example, lastTrades is defined with def, so it is a local variable and is not added to the binding.
Declaring the variable with an explicit type, such as Table, has the same effect as def: the variable is local to the script and isn't added to the binding.
In both versions, lastTrades is no longer in the binding, but there are still references to that table itself, as it is still feeding the lastTradesWithPriceTimesSize table. lastTrades falls between cryptoTrades and lastTradesWithPriceTimesSize in your query graph, the chain of tables that Deephaven updates in order as data changes. However, generally speaking, this does not improve memory usage or performance, since you will still have a reference to the table. With ticking tables, the query graph keeps upstream tables alive as long as a downstream table needs them. With static tables, intermediate results may be eligible for cleanup sooner.
You can display only the final table in the query by chaining the operations together:
You may have fewer intermediate table objects that are visible to you at the end of the script, but the query still creates the same number of tables and does the same amount of work:
- Read a CSV into a table,
- take the last row for each
Instrument, and - add a
PriceTimesSizecolumn.
Variables in loops
How many variables you keep in scope matters more than whether they're displayed. In a loop, reusing one variable name lets earlier tables be cleaned up:
Here, t and result are in the binding, but because they are replaced on each iteration, the tables created by previous iterations can be cleaned up. However, putting the results for each individual date in the binding with publishVariable prevents this cleanup because a brand new variable is being added to the binding on every iteration: