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.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.Map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by richie on 2017/5/2.
|
|
|
|
*/
|
|
|
|
public class HashVisitor 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);
|
|
|
|
}
|
|
|
|
Map<String, String> map = client.hgetAll(trimCommand(arr[1]));
|
|
|
|
List<String> column1 = new ArrayList<String>();
|
|
|
|
List<String> column2 = new ArrayList<String>();
|
|
|
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
|
column1.add(entry.getKey());
|
|
|
|
column2.add(entry.getValue());
|
|
|
|
}
|
|
|
|
List<List<String>> result = new ArrayList<List<String>>();
|
|
|
|
result.add(column1);
|
|
|
|
result.add(column2);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String keyWord() {
|
|
|
|
return "hgetall";
|
|
|
|
}
|
|
|
|
}
|