forked from fanruan/demo-tabledata-redis
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.
38 lines
1.2 KiB
38 lines
1.2 KiB
package com.fr.plugin.db.redis.core.visit.impl; |
|
|
|
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; |
|
import java.util.Set; |
|
|
|
/** |
|
* Created by richie on 2017/5/2. |
|
*/ |
|
public class SetVisitor 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 < 2) { |
|
throw new IllegalArgumentException("Illegal query:" + query); |
|
} |
|
Set<String> data = client.smembers(trimCommand(arr[1])); |
|
List<String> column = new ArrayList<String>(); |
|
for (String element : data) { |
|
column.add(element); |
|
} |
|
List<List<String>> result = new ArrayList<List<String>>(); |
|
result.add(column); |
|
result.add(column); |
|
return result; |
|
} |
|
|
|
@Override |
|
public String keyWord() { |
|
return "smembers"; |
|
} |
|
}
|
|
|