Search in sources :

Example 1 with SearchRouteParam

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());
}
Also used : ShardRouteParam(com.xiaomi.linden.thrift.common.ShardRouteParam) EarlyParam(com.xiaomi.linden.thrift.common.EarlyParam) SearchRouteParam(com.xiaomi.linden.thrift.common.SearchRouteParam) LindenSearchRequest(com.xiaomi.linden.thrift.common.LindenSearchRequest) Test(org.junit.Test)

Aggregations

EarlyParam (com.xiaomi.linden.thrift.common.EarlyParam)1 LindenSearchRequest (com.xiaomi.linden.thrift.common.LindenSearchRequest)1 SearchRouteParam (com.xiaomi.linden.thrift.common.SearchRouteParam)1 ShardRouteParam (com.xiaomi.linden.thrift.common.ShardRouteParam)1 Test (org.junit.Test)1