result set

This commit is contained in:
jackdaw@loafle.com 2017-04-26 10:58:56 +09:00
parent 488086b8d2
commit 0aef8f100b
5 changed files with 26 additions and 48 deletions

View File

@ -1,6 +1,7 @@
package com.loafle.overflow.crawler.config;
import java.util.List;
import java.util.Map;
/**
* Created by root on 17. 4. 13.
@ -8,21 +9,29 @@ import java.util.List;
public class Item {
List<String> metrics;
Query query;
List<String> keys;
Map<String,Object> queryInfo;
public List<String> getMetrics() {
return metrics;
}
public void setMetrics(List<String> metrics) {
this.metrics = metrics;
}
public Query getQuery() {
return query;
public List<String> getKeys() {
return keys;
}
public void setQuery(Query query) {
this.query = query;
public void setKeys(List<String> keys) {
this.keys = keys;
}
public Map<String, Object> getQueryInfo() {
return queryInfo;
}
public void setQueryInfo(Map<String, Object> queryInfo) {
this.queryInfo = queryInfo;
}
}

View File

@ -1,29 +0,0 @@
package com.loafle.overflow.crawler.config;
import java.util.List;
import java.util.Map;
/**
* Created by snoop on 2017-04-21.
*/
public class Query {
Map<String,Object> queryInfo;
List<String> keys;
public Map<String, Object> getQueryInfo() {
return queryInfo;
}
public void setQueryInfo(Map<String, Object> queryInfo) {
this.queryInfo = queryInfo;
}
public List<String> getKeys() {
return keys;
}
public void setKeys(List<String> keys) {
this.keys = keys;
}
}

View File

@ -42,7 +42,7 @@ public abstract class OFResultSet {
// methods
static public OFResultSet newInstance(Item item) {
String type = (String) item.getQuery().getQueryInfo().get("parseDirection");
String type = (String) item.getQueryInfo().get("parseDirection");
if (type != null && type.equals("row")) {
return new OFResultSetRow(item);
} else {

View File

@ -16,8 +16,8 @@ public class OFResultSetCol extends OFResultSet{
public void setMeta() {
List<String> meta = this.item.getQuery().getKeys();
List<String> arrayColumns = (List<String>)this.item.getQuery().getQueryInfo().get("arrayColumns");
List<String> meta = this.item.getKeys();
List<String> arrayColumns = (List<String>)this.item.getQueryInfo().get("arrayColumns");
if(this.meta == null) {
this.meta = new HashMap<>();
@ -40,7 +40,7 @@ public class OFResultSetCol extends OFResultSet{
public Map<String, String> parse() {
List<String> metrics = this.item.getMetrics();
List<String> arrayColumns = (List<String>)this.item.getQuery().getQueryInfo().get("arrayColumns");
List<String> arrayColumns = (List<String>)this.item.getQueryInfo().get("arrayColumns");
// this.meta
Map<String, String> resultMap = new HashMap<>();

View File

@ -1,7 +1,6 @@
package com.loafle.overflow.crawler.result;
import com.loafle.overflow.crawler.config.Item;
import com.loafle.overflow.crawler.config.Query;
import java.util.ArrayList;
import java.util.HashMap;
@ -22,9 +21,9 @@ public class OFResultSetRow extends OFResultSet{
List<String> meta = new ArrayList<>();
List<String> arrayColumns = (List<String>) this.item.getQuery().getQueryInfo().get("arrayColumns");
List<String> keyColumns = (List<String>) this.item.getQuery().getQueryInfo().get("keyColumns");
String valueColumn = (String) this.item.getQuery().getQueryInfo().get("valueColumn");
List<String> arrayColumns = (List<String>) this.item.getQueryInfo().get("arrayColumns");
List<String> keyColumns = (List<String>) this.item.getQueryInfo().get("keyColumns");
String valueColumn = (String) this.item.getQueryInfo().get("valueColumn");
if (arrayColumns != null) {
for (String c : arrayColumns) {
meta.add(c);
@ -54,7 +53,7 @@ public class OFResultSetRow extends OFResultSet{
Map<String, String> returnMap = new HashMap<>();
String valueColumn = (String) this.item.getQuery().getQueryInfo().get("valueColumn");
String valueColumn = (String) this.item.getQueryInfo().get("valueColumn");
for (List<String> row : this.rows) {
String key = makeKey(row);
@ -66,12 +65,11 @@ public class OFResultSetRow extends OFResultSet{
private String makeKey(List<String> data) {
Query query = this.item.getQuery();
List<String> metrics = this.item.getMetrics();
List<String> arrayColumns = (List<String>) this.item.getQuery().getQueryInfo().get("arrayColumns");
List<String> keyColumns = (List<String>) this.item.getQuery().getQueryInfo().get("keyColumns");
List<String> keys = query.getKeys();
List<String> arrayColumns = (List<String>) this.item.getQueryInfo().get("arrayColumns");
List<String> keyColumns = (List<String>) this.item.getQueryInfo().get("keyColumns");
List<String> keys = this.item.getKeys();
boolean find = false;
int findIndex = -1;