@Test public void testLocateForIntersection() { ConditionContext ctx = new ShardingContext("appId", "logicDbName", set("1", "2", "3"), new Hints(), ConditionList.andList()).create(new ColumnCondition(OperatorEnum.EQUAL, "tableName", "col", "")); assertEquals(set(), test2.locateForIntersection(ctx, OperatorEnum.EQUAL, "2", OperatorEnum.EQUAL, "3")); assertEquals(set("2"), test2.locateForIntersection(ctx, OperatorEnum.EQUAL, "2", OperatorEnum.EQUAL, "2")); }
protected Set<String> locateForIntersection(CTX context, OperatorEnum op1, Object value1, OperatorEnum op2, Object value2) { Set<String> range = new HashSet<>(locateShards(createConditionContext(context, op1, value1))); range.retainAll(locateShards(createConditionContext(context, op2, value2))); return range; }
AbstractConditionShardLocator { protected Set<String> locateForIntersection(CTX context, OperatorEnum op1, Object value1, OperatorEnum op2, Object value2) { Set<String> range = new HashSet<>(locateShards(createConditionContext(context, op1, value1))); range.retainAll(locateShards(createConditionContext(context, op2, value2))); return range; } }
AbstractConditionShardLocator { protected Set<String> locateForIntersection(CTX context, OperatorEnum op1, Object value1, OperatorEnum op2, Object value2) { Set<String> range = new HashSet<>(locateShards(createConditionContext(context, op1, value1))); range.retainAll(locateShards(createConditionContext(context, op2, value2))); return range; }  }
AbstractConditionShardLocator { protected Set<String> locateForIntersection(CTX context, OperatorEnum op1, Object value1, OperatorEnum op2, Object value2) { Set<String> range = new HashSet<>(locateShards(createConditionContext(context, op1, value1))); range.retainAll(locateShards(createConditionContext(context, op2, value2))); return range; }  abstract Set<String> locateForEqual(CTX context); abstract Set<String> locateForNotEqual(CTX ctx); abstract Set<String> locateForGreaterThan(CTX context); abstract Set<String> locateForGreaterThanOrEqual(CTX ctx); abstract Set<String> locateForLessThan(CTX context); abstract Set<String> locateForLessThanOrEqual(CTX ctx); abstract Set<String> locateForBetween(CTX ctx); abstract Set<String> locateForNotBetween(CTX ctx); abstract Set<String> locateForIn(CTX context); abstract Set<String> locateForNotIn(CTX context); abstract Set<String> locateForLike(CTX context); abstract Set<String> locateForNotLike(CTX context); abstract Set<String> locateForIsNull(CTX context); abstract Set<String> locateForIsNotNull(CTX context); Set<String> getAllShards(CTX context); Set<String> locateShards(CTX context); }
AbstractConditionShardLocator { protected Set<String> locateForIntersection(CTX context, OperatorEnum op1, Object value1, OperatorEnum op2, Object value2) { Set<String> range = new HashSet<>(locateShards(createConditionContext(context, op1, value1))); range.retainAll(locateShards(createConditionContext(context, op2, value2))); return range; }  abstract Set<String> locateForEqual(CTX context); abstract Set<String> locateForNotEqual(CTX ctx); abstract Set<String> locateForGreaterThan(CTX context); abstract Set<String> locateForGreaterThanOrEqual(CTX ctx); abstract Set<String> locateForLessThan(CTX context); abstract Set<String> locateForLessThanOrEqual(CTX ctx); abstract Set<String> locateForBetween(CTX ctx); abstract Set<String> locateForNotBetween(CTX ctx); abstract Set<String> locateForIn(CTX context); abstract Set<String> locateForNotIn(CTX context); abstract Set<String> locateForLike(CTX context); abstract Set<String> locateForNotLike(CTX context); abstract Set<String> locateForIsNull(CTX context); abstract Set<String> locateForIsNotNull(CTX context); Set<String> getAllShards(CTX context); Set<String> locateShards(CTX context);  }