Idempotence layer on bloom filters

April 10, 2018

TLDR: we run several applications consuming multiple real-time streams. These applications implement idempotence using Redis sets. In this post I describe our journey moving to bloom filters (using the ReBloom module), which brought down our memory usage by almost 10x. Let’s briefly define idempotence: An operation is said to be idempotent when applying it multiple times has the same effect. There are some reasons why applications consuming a real-time stream must have an idempotence layer, e. ... Read more

Find self-references in (possibly nested) collections

March 16, 2018

I found a nice trick reading part of the ElasticSearch client for Java. Say you are given an object (could be a map, a list, an array or anything) and you need to make sure the same reference does not show up in any of the children objects (or theirs). Here is how this the ElasticSearch guys solved this problem: static void ensureNoSelfReferences(Object value) { ensureNoSelfReferences(value, Collections.newSetFromMap(new IdentityHashMap<>())); } static void ensureNoSelfReferences(final Object value, final Set<Object> ancestors) { if (value ! ... Read more

Mutability and Java 8's method references

March 12, 2018

Method references is a nice feature introduced in Java 8. It lets you make your lambdas even more concise: // from... someStream .map(item -> obj.someMethod(item)) .moreStuff... // to... someStream .map(obj::someMethod) .moreStuff... Some linting tools will even suggest you replace your lambdas with method references but, watch out, that sometimes have some unadverted consequences. For instance, this is a piece of actual code I was working one: private List<Application> applications() { return applications . ... Read more

Merge multi-project test coverage: Gradle + Jacoco + Sonarqube

March 8, 2018

I’m assuming you got here because you are using Gradle with Jacoco and noticed that integrating it with Sonarqube does not work perfectly out of the box. Specifically, when your project has multiple modules, you might have seen that Sonarqube’s coverage report ignores code in module A covered by tests in module B. In fact, this is a problem that you will find even if you are not using Sonarqube: Jacoco itself will not merge test reports by default, which makes it extra hard to find a solution online. ... Read more

© 2017 | Powered by Hugo ♥ | Art by Clip Art ETC