Commit 611c4de5 authored by dagal's avatar dagal
Browse files

boards x queries

parent 2cd325c5
......@@ -39,10 +39,16 @@ def main(argv):
# gen_q("%s:%s %s:%s" % (nodes[0], nodes[1], nodes[-3], nodes[-2]), fw, 15)
# fw.close()
fw = open(path + "10k-ends-with-x.txt", "w+")
# fw = open(path + "10k-ends-with-x.txt", "w+")
# for s in random.sample(sys.stdin.readlines(), Q):
# nodes = filter(None, re.split(',|:|\n', s))
# gen_q("%s:%s" % (nodes[-3], nodes[-2]), fw, 1)
# fw.close()
fw = open(path + "10k-uses-x.txt", "w+")
for s in random.sample(sys.stdin.readlines(), Q):
nodes = filter(None, re.split(',|:|\n', s))
gen_q("%s:%s" % (nodes[-3], nodes[-2]), fw, 1)
gen_q("%s:%s" % (nodes[0], nodes[1]), fw, 7)
fw.close()
def main2(argv):
......
......@@ -143,14 +143,17 @@
#../benchmark indexes/madrid_lines indexes/madrid_lines ./queries/madrid/top-100.txt 0 1000
echo 'TTCTR (psi='$2' lines='$3' times='$4')'
echo 'xy'
../benchmark indexes/$1$2 indexes/$1_$3 indexes/$1_$4 ./queries/madrid/10k-starts-with-x-ends-with-y.txt 0 100000
echo 'start x'
../benchmark indexes/$1$2 indexes/$1_$3 indexes/$1_$4 ./queries/madrid/10k-starts-with-x.txt 0 100000
echo 'end x'
../benchmark indexes/$1$2 indexes/$1_$3 indexes/$1_$4 ./queries/madrid/10k-ends-with-x.txt 0 100000
echo ''
# echo 'xy'
# ../benchmark indexes/$1$2 indexes/$1_$3 indexes/$1_$4 ./queries/madrid/10k-starts-with-x-ends-with-y.txt 0 100000
# echo 'start x'
# ../benchmark indexes/$1$2 indexes/$1_$3 indexes/$1_$4 ./queries/madrid/10k-starts-with-x.txt 0 100000
# echo 'end x'
# ../benchmark indexes/$1$2 indexes/$1_$3 indexes/$1_$4 ./queries/madrid/10k-ends-with-x.txt 0 100000
echo 'board x'
../benchmark indexes/$1$2 indexes/$1_$3 indexes/$1_$4 ./queries/madrid/10k-uses-x.txt 0 100000
# echo ''
#../benchmark indexes/madrid_lines indexes/madrid_lines indexes/madrid_lines ./queries/madrid/10k-starts-with-x-ends-with-y.txt 0 10000
#../benchmark indexes/madrid_lines indexes/madrid_lines indexes/madrid_lines ./queries/madrid/10k-starts-with-x.txt 0 10000
#../benchmark indexes/madrid_lines indexes/madrid_lines indexes/madrid_lines ./queries/madrid/10k-ends-with-x.txt 0 10000
#../benchmark indexes/madrid_lines indexes/madrid_lines indexes/madrid_lines ./queries/madrid/10k-uses-x.txt 0 10000
\ No newline at end of file
This diff is collapsed.
......@@ -34,7 +34,7 @@ QueryType queryTypes[16] = {
{4, 1, true, get_top_k},
{5, 1, false, get_starts_or_ends_with_x},
{6, 1, true, get_top_k_starts},
{7, 1, false, get_uses_x},
{7, 2, false, get_uses_x},
{8, 2, false, get_from_x_to_y_strong},
{9, 2, false, get_from_x_to_y_weak},
{10, 0, false, get_uses_x},
......
......@@ -1260,6 +1260,61 @@ uint inline encodeStop(twcsa *g, uint lineId, uint stopId) {
return mapID(g, STOPS + stopId * STOPS_LINE + lineId, NODE);
}
int get_uses_x(void *index, TimeQuery *query) {
if ((query->subtype & (XY_LINE_START | XY_TIME_START)) != query->subtype) {
return 0;
}
twcsa *g = (twcsa *)index;
ulong numocc = 0, lu = 0, ru = 0;
pair<int, int> res;
const auto lineId = query->values[0];
const auto stopId = query->values[1];
uint u = mapID(g, stopId, NODE);
uint pattern[2] = {u, 0};
const auto linesWM = dynamic_cast<std::vector<WaveletMatrix *>*>((std::vector<WaveletMatrix *>*)g->linesIndex);
if (linesWM == NULL) {
std::cerr << "Either use WM or implement the trackUp operation in the WT!" << std::endl;
throw std::bad_cast();
}
countIntIndex(g->myicsa, pattern, 2, &numocc, &lu, &ru);
const auto stop_offset = lu;
lu = ru+1;
ru = selectStop(g, u+1);
numocc = ru-lu;
if (numocc && query->subtype) {
if (ru < g->n) ru--;
const auto start_time = query->time->h_start;
const auto end_time = query->time->h_end;
std::vector<uint16_t> lines;
numocc = 0;
ulong n = 0;
if ((query->subtype & (XY_LINE_START | XY_TIME_START)) == XY_TIME_START) {
query->subtype |= XY_LINE_START;
lines = g->stopLines->at(query->values[1]);
} else {
lines.push_back(query->values[0]);
}
for (const auto &line : lines) {
n = getRange(linesWM->at(u), lu-stop_offset, ru-stop_offset, line, line, &res);
if (n && query->subtype & XY_TIME_START) {
const auto jcodes = getJCodes(g, line, query->values[1], start_time, end_time);
n = getTimeRange(g, stop_offset+res.first, stop_offset+res.second, jcodes.first, jcodes.second);
}
numocc += n;
}
}
return numocc;
}
int get_starts_with_x(void *index, TimeQuery *query) {
if ((query->subtype & (XY_LINE_START | XY_TIME_START)) != query->subtype) {
return 0;
......@@ -1965,75 +2020,6 @@ int get_starts_or_ends_with_x(void *index, TimeQuery *query) {
}
int get_uses_x(void *index, TimeQuery *query) {
twcsa *g = (twcsa *)index;
ulong numocc = 0, lu = 0, ru = 0;
if (g->baseline) {
const auto u = mapID(g, query->values[0], NODE);
const auto &times = g->baseline->usesX->at(u);
if (query->time) {
numocc = 0;
if (query->time->h_end < query->time->h_start) {
for (auto i = times.begin(); i != times.upper_bound(query->time->h_end); i++) {
numocc += i->second;
}
for (auto i = times.lower_bound(query->time->h_start); i != times.end(); i++) {
numocc += i->second;
}
} else {
for (auto i = times.lower_bound(query->time->h_start); i != times.upper_bound(query->time->h_end); i++) {
numocc += i->second;
}
}
} else {
numocc = times.size() > 0 ? times.begin()->second : 0;
}
return numocc;
}
//notice that:
//select(0) is 0
//select(1) is 1
//select(2) is the first stop after the $
//select(x+1) is where the stops x start
if (query->type->nValues) {
uint u = mapID(g, query->values[0], NODE);
if (u+1 >= g->map_size) {
lu = getSelecticsa(g->myicsa, u+1);
ru = g->n - 1;
} else {
lu = getSelecticsa(g->myicsa, u+1);
ru = getSelecticsa(g->myicsa, u+2)-1;
}
// printf("%lu %lu %lu %lu\n", g->map_size, u, lu, ru);
} else {
lu = getSelecticsa(g->myicsa, 2);
ru = g->n-1;
}
numocc = ru - lu + 1;
if (query->time) {
Sequence *wm = (Sequence *)g->myTimesIndex;
numocc = getRange(g, lu, ru, query->time->h_start, query->time->h_end);
// numocc = getRange(g, lu, ru, query->time->h_start, query->time->h_start);
// numocc = wm->rank(query->time->h_start, ru) - wm->rank(query->time->h_start, lu);
}
// printf("%lu %lu %lu\n", numocc, lu, ru);
return numocc;
}
/**************************/
//** debugging only
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment