use of com.xiaomi.linden.thrift.common.SearchRouteParam in project linden by XiaoMi.
the class TestBQL method testRoute.
@Test
public void testRoute() {
String bql = "SELECT * FROM linden where title = 'sed' route by 0, 1, 2, replica_key '12345'";
LindenSearchRequest lindenRequest = compiler.compile(bql).getSearchRequest();
SearchRouteParam routeParam = new SearchRouteParam();
routeParam.addToShardParams(new ShardRouteParam(0));
routeParam.addToShardParams(new ShardRouteParam(1));
routeParam.addToShardParams(new ShardRouteParam(2));
routeParam.setReplicaRouteKey("12345");
Assert.assertEquals(routeParam, lindenRequest.getRouteParam());
bql = "SELECT * FROM linden where title = 'sed' route by 0 in top 500, 1, 2, $a, $shard in top 500, 3 in top $max";
lindenRequest = compiler.compile(bql).getSearchRequest();
routeParam = new SearchRouteParam();
routeParam.addToShardParams(new ShardRouteParam(0).setEarlyParam(new EarlyParam(500)));
routeParam.addToShardParams(new ShardRouteParam(1));
routeParam.addToShardParams(new ShardRouteParam(2));
routeParam.addToShardParams(new ShardRouteParam(3));
Assert.assertEquals(routeParam, lindenRequest.getRouteParam());
bql = "SELECT * FROM linden where title = 'sed' route by (0,1) in top 10000, ($shard) in top 1000, 2";
lindenRequest = compiler.compile(bql).getSearchRequest();
routeParam = new SearchRouteParam();
routeParam.addToShardParams(new ShardRouteParam(0).setEarlyParam(new EarlyParam().setMaxNum(10000)));
routeParam.addToShardParams(new ShardRouteParam(1).setEarlyParam(new EarlyParam().setMaxNum(10000)));
routeParam.addToShardParams(new ShardRouteParam(2));
Assert.assertEquals(routeParam, lindenRequest.getRouteParam());
}
Aggregations