Subtitle: Following Alice Down the RabbitHole
While poking around my own source code, and the methods of the EasyChart that I override in my own subclass, I noticed a protected method that had avoided my gaze for the past three years: PMIEasyChart.penIterator().
This prompted me to smack my forehead in anguish over a lost opportunity. I recall, sometime in 2015, asking @Carl.Gould how to hook up my Time-Series Cache Module to the EasyChart, as it is much easier to design with than the Classic Chart. He made a casual comment about implementing my own Pen class. I don’t remember the wording, but I recall thinking it was some obscure extension-point-like construct that would make it possible to do so in the existing EasyChart component.
Well, I never figured it out in 2015, and it didn’t seem that important, so I filed it away in my future feature to-do list. Upon seeing that protected method in the Eclipse package explorer, I realized that I couldn’t make the EasyChart use the time-series cache, but I could make the EasyNoteChart use it.
And, since both the time-series cache and the EasyChart’s DB pens are generally intended to work with the wide tables produced by Transaction Groups, my cache’s keying on datasource, table name, timestamp column, and optional WHERE clause is the same as the Pen sorting done within the EasyChart’s QueryGroupKey. Instead of creating a Pen from scratch and adding it alongside the other pen types, I could (and did) simply subclass the DBPen and divert its query operations to the cache subsystem. Sweet! (-:
Ah, but there’s a complication: These are two different modules, and I sell them separately. Someone may want the features of NoteChart but never use transaction groups. So I don’t want to merge them. Instead, I used reflection within NoteChart to find the necessary classes and methods in TS DB Cache, if they are both installed. And for completeness, I added a boolean property to
EasyNoteChart (default true) to enable cache diversion when possible. When so,
penIterator() delivers my
CacheDBPen instead of
DBPen as needed, which neatly ties it into the chart’s data deliver logic.
So, when this new beta of Time-Series Caching is installed alongside the new beta of NoteChart, all the DB pens used in any EasyNoteChart automatically use the cache. But if needed, the new boolean property can be turned off in specific charts to revert to regular queries.
Oh, and since it is a cache module, I made the histogram queries retrieve all relevant columns instead of just t_stamp (but at a lower priority). It makes scrolling in historical mode blistering fast, even with millions of rows of data per pen.
Anyways, ask yourself: Have I ever tried to load so much data into an EasyChart’s DB pen(s) that the query timed out? Have I run Realtime Charts with high resolution data on many clients at once, and brought my database to its knees?