From 4e0c11bca6db97f49ef76f9d014b0170f5751697 Mon Sep 17 00:00:00 2001 From: Matt Wheeler Date: Tue, 28 Jan 2014 12:20:04 -0800 Subject: [PATCH] SENSEI-279 Partition filter in sensei request feature --- .../search/node/AbstractConsistentHashBroker.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sensei-core/src/main/java/com/senseidb/search/node/AbstractConsistentHashBroker.java b/sensei-core/src/main/java/com/senseidb/search/node/AbstractConsistentHashBroker.java index 94556ea67..0a78e1c38 100644 --- a/sensei-core/src/main/java/com/senseidb/search/node/AbstractConsistentHashBroker.java +++ b/sensei-core/src/main/java/com/senseidb/search/node/AbstractConsistentHashBroker.java @@ -1,5 +1,6 @@ package com.senseidb.search.node; +import com.google.common.collect.Sets; import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.HashMap; @@ -227,7 +228,14 @@ public RESULT call() throws Exception { @SuppressWarnings("unchecked") protected List doCall(REQUEST req) { - Set shards = router.getShards(); + Set allShards = router.getShards(); + + Set shards = req.getPartitions(); + if (shards == null || shards.isEmpty()) { + shards = allShards; + } else { + shards = Sets.intersection(allShards, shards); + } Map, REQUEST> serviceToRequest = new HashMap, REQUEST>();