You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package com.fr.plugin.db.redis.core.visit.impl;
|
|
|
|
|
|
|
|
import com.fr.base.TableData;
|
|
|
|
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
|
|
|
|
import com.fr.stable.ParameterProvider;
|
|
|
|
import com.fr.stable.script.CalculatorProvider;
|
|
|
|
import redis.clients.jedis.Jedis;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by richie on 2017/5/2.
|
|
|
|
*/
|
|
|
|
public class ListVisitor extends AbstractVisitor<String> {
|
|
|
|
@Override
|
|
|
|
public List<List<String>> getContent(CalculatorProvider calculator, ParameterProvider[] ps, Jedis client, String query, int rowCount) throws Exception {
|
|
|
|
|
|
|
|
String[] arr = query.trim().split(TOKEN_SPACE);
|
|
|
|
if (arr.length < 4) {
|
|
|
|
throw new IllegalArgumentException("Illegal query:" + query);
|
|
|
|
}
|
|
|
|
long start = Long.parseLong(trimCommand(arr[2]));
|
|
|
|
long end = Long.parseLong(trimCommand(arr[3]));
|
|
|
|
if (rowCount != TableData.RESULT_ALL) {
|
|
|
|
end = start + rowCount;
|
|
|
|
}
|
|
|
|
List<String> data = client.lrange(arr[1], start, end);
|
|
|
|
List<List<String>> result = new ArrayList<List<String>>();
|
|
|
|
result.add(data);
|
|
|
|
result.add(data);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String keyWord() {
|
|
|
|
return "lrange";
|
|
|
|
}
|
|
|
|
}
|