Allow custom compaction filters

I find this quite useful. I added a very simple implementation with a test, but not sure if it's the best way to do it.