26 vector<string>
split(
string& str,
const char* c)
30 cstr =
new char[str.size() + 1];
31 strcpy(cstr, str.c_str());
45 while (origin[start] ==
' ')
47 int end = origin.length() - 1;
48 while (origin[end] ==
' ')
50 return origin.substr(start, end - start + 1);
57 ifstream ifile(fname);
64 while (getline(ifile, line) && (count < num || num < 0))
67 vector<string> nstring =
split(line,
", ");
69 for (i = 0; i < nstring.size(); ++i)
71 int int_value = atoi(
eraseSpace(nstring[i]).c_str());
72 row.push_back(int_value);
77 Logger::log(Logger::INFO,
"Finish reading file!");
78 Logger::log(Logger::DEBUG,
"%d rows are read into memory!",
96 ifstream ifile(file_name);
105 while (getline(ifile, line) && count != 0)
108 vector<string> nstring =
split(line,
", ");
121 data.push_back(attr);
128 Logger::log(Logger::INFO,
"Finish reading query data!");
129 Logger::log(Logger::DEBUG,
"%d attributes are loaded.", total);
134 vector<genie::query::Query>& queries,
int num_of_queries,
int num_of_query_dims,
135 int radius,
int topk,
float selectivity)
139 ifstream ifile(fname);
142 queries.reserve(num_of_queries);
147 while (getline(ifile, line) && j < num_of_queries)
150 vector<string> nstring =
split(line,
", ");
153 for (i = 0; i < nstring.size() && i < (
unsigned int) num_of_query_dims; ++i)
156 int value = atoi(myString.c_str());
158 q.
attr(j, value - radius < 0 ? 0 : value - radius,
159 value + radius, 1, i);
162 if (selectivity > 0.0f)
167 queries.push_back(q);
174 Logger::log(Logger::INFO,
"Finish reading queries!");
175 Logger::log(Logger::DEBUG,
"%d queries are loaded.", num_of_queries);
void topk(int k)
Set top k matches.
const unsigned int GPUGENIE_QUERY_WEIGHT_INDEX
vector< string > split(string &str, const char *c)
The declaration for class inv_table.
string eraseSpace(string origin)
Declaration of query class.
const unsigned int GPUGENIE_QUERY_NUM_OF_FIELDS
const unsigned int GPUGENIE_QUERY_DIM_INDEX
void apply_adaptive_query_range()
Construct query in adaptice range mode.
const unsigned int GPUGENIE_QUERY_SELECTIVITY_INDEX
void read_query(genie::table::inv_table &table, const char *fname, std::vector< genie::query::Query > &queries, int num_of_queries, int num_of_query_dims, int radius, int topk, float selectivity)
struct genie::utility::_GPUGenie_Query_Data attr_t
This file declares functions about file operations.
Record run-time information.
void read_file(std::vector< std::vector< int > > &dest, const char *fname, int num)
const unsigned int GPUGENIE_QUERY_QID_INDEX
void attr(int index, int low, int up, float weight, int order)
Modify the matching range and weight of an attribute.
const unsigned int GPUGENIE_QUERY_VALUE_INDEX
void selectivity(float s)
Set the selectivity.