ExcerptTailer tailer;try { tailer = chronicle.createTailer();} catch (IOException e) { logger.log(Level.WARNING, "Could not create ExcerptTailer. Check exception", e); return Collections.EMPTY_LIST;} tailer.toStart(); Collection<RestDataHolder> result = new ArrayList<RestDataHolder>();
while(true) { if(!tailer.nextIndex()) break;//no more data
Object obj = tailer.readObject(); tailer.finish();
if(!(obj instanceof RestDataHolder)) continue;//should be treated as exception though RestDataHolder data = (RestDataHolder)obj; if(!accountId.equals(data.getAccountId())) continue;
...
There is two approaches.
- add the accountId to the start of the message to speed up the scan. If the field is monotonically increasing a binary search is supported.
- you can add a Map as an index for fast lookups.
--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Chronicle is already much more efficient with Externalizable than Java Serialization however it only exposes a basic set of methods. If you use BytesMarshallable it gives you the full range of methods Bytes offers. Ie. If you don't see an opportunity to use one of the alternative methods Bytes offers there us no benefit.
Reasons you might use Bytes;
- compressed data types. Eg stop bit encoding
- object pooling built in to avoid garbage.
- do your own object management to avoid garbage completely.
Apologies for hijacking, but how does one implement the binary index on the first [monotonic] field ? Is that built in ?
We support binary search or range searches. You provide a comparator and the binary search will find an index where the entry returns 0 or the point which is -1 below and +1 above.
For a range search it finds the point where -1 and 0 are returned as well as 0 and +1 are returned. This will allow you to find the entries for a particular hour for example.