Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

Commit

Permalink
Fix a bug of filter side in HashJoinOperator
Browse files Browse the repository at this point in the history
  • Loading branch information
jianqiao committed Jun 5, 2018
1 parent dfefe62 commit 97bef17
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 18 deletions.
11 changes: 6 additions & 5 deletions autofix_cmakelists.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import os
import re
import sys

from collections import defaultdict

Expand Down Expand Up @@ -1356,7 +1357,7 @@ def __init__(self, path):
self.path = path

if "CMakeLists.txt" in os.listdir(path):
with open(self.path + "/CMakeLists.txt", "rb") as file:
with open(self.path + "/CMakeLists.txt", "r") as file:
self.root = CMakeGroup(LineStream(file.readlines()))
self.newfile = False
else:
Expand Down Expand Up @@ -1524,8 +1525,8 @@ def addMissingSubdirectories(self, global_ctx):
continue

if name in subdirectories:
print "Warning: Possibly duplicated add_subdirectory(" + \
name + ") in", self.path
sys.stdout.write("Warning: Possibly duplicated add_subdirectory(" +
name + ") in" + self.path)

subdirectories[name] = node

Expand Down Expand Up @@ -1690,7 +1691,7 @@ def writeToFile(self):
if len(output) == 0:
return

with open(self.path + "/CMakeLists.txt", "wb") as file:
with open(self.path + "/CMakeLists.txt", "w") as file:
file.write("".join(output))
file.close()

Expand Down Expand Up @@ -1754,7 +1755,7 @@ def __init__(self, path, name):
self.includes = []

# Parse include items
with open(self.path + "/" + self.name, "rb") as file:
with open(self.path + "/" + self.name, "r") as file:
dependencies = []

for line in file:
Expand Down
59 changes: 59 additions & 0 deletions query_optimizer/tests/execution_generator/Join.test
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,62 @@ WHERE b.x > 10
+-----------+--------------------+------------------------+----------------+
| 6| 61| 601| C6|
+-----------+--------------------+------------------------+----------------+
==

# Semi-join w/o residual predicates
SELECT SUM(x)
FROM a
WHERE w IN (SELECT w FROM b);
--
+--------------------+
|SUM(x) |
+--------------------+
| 900|
+--------------------+
==

# Semi-join w/ residual predicates
SELECT SUM(x)
FROM a
WHERE EXISTS (
SELECT *
FROM b
WHERE a.w = b.w
AND a.x < b.x
);
--
+--------------------+
|SUM(x) |
+--------------------+
| 500|
+--------------------+
==

# Anti-join w/o residual predicates
SELECT SUM(x)
FROM a
WHERE w NOT IN (SELECT w FROM b);
--
+--------------------+
|SUM(x) |
+--------------------+
| 1000|
+--------------------+
==

# Anti-join w residual predicates
SELECT SUM(x)
FROM a
WHERE NOT EXISTS (
SELECT *
FROM b
WHERE a.w = b.w
AND a.x < b.x
);
--
+--------------------+
|SUM(x) |
+--------------------+
| 1400|
+--------------------+
==
12 changes: 6 additions & 6 deletions relational_operators/HashJoinOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,9 @@ void HashSemiJoinWorkOrder::executeWithResidualPredicate() {
build_store.createValueAccessor());
for (const std::pair<tuple_id, tuple_id> &hash_match
: build_block_entry.second) {
// For each pair, 1st element is a tuple ID from the build relation in the
// given build block, 2nd element is a tuple ID from the probe relation.
if (filter.get(hash_match.second)) {
// For each pair, 1st element is a tuple ID from the probe relation, 2nd
// element is a tuple ID from the build relation in the given build block.
if (filter.get(hash_match.first)) {
// We have already found matches for this tuple that belongs to the
// probe side, skip it.
continue;
Expand All @@ -744,7 +744,7 @@ void HashSemiJoinWorkOrder::executeWithResidualPredicate() {
hash_match.first,
*build_accessor,
hash_match.second)) {
filter.set(hash_match.second);
filter.set(hash_match.first);
}
}
}
Expand Down Expand Up @@ -949,7 +949,7 @@ void HashAntiJoinWorkOrder::executeWithResidualPredicate() {
std::unique_ptr<ValueAccessor> build_accessor(build_store.createValueAccessor());
for (const std::pair<tuple_id, tuple_id> &hash_match
: build_block_entry.second) {
if (!existence_map->get(hash_match.second)) {
if (!existence_map->get(hash_match.first)) {
// We have already seen this tuple, skip it.
continue;
}
Expand All @@ -959,7 +959,7 @@ void HashAntiJoinWorkOrder::executeWithResidualPredicate() {
hash_match.second)) {
// Note that the existence map marks a match as false, as needed by the
// anti join definition.
existence_map->set(hash_match.second, false);
existence_map->set(hash_match.first, false);
}
}
}
Expand Down
13 changes: 6 additions & 7 deletions storage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,6 @@ target_link_libraries(quickstep_storage_BasicColumnStoreValueAccessor
quickstep_utility_BitVector
quickstep_utility_Macros
quickstep_utility_PtrVector)
if (ENABLE_NETWORK_CLI)
target_link_libraries(quickstep_storage_BlockWire_proto
${PROTOBUF_LIBRARY})
endif()
target_link_libraries(quickstep_storage_BloomFilterIndexSubBlock
glog
quickstep_catalog_CatalogAttribute
Expand Down Expand Up @@ -1102,7 +1098,10 @@ if (ENABLE_DISTRIBUTED)
endif()

if (ENABLE_NETWORK_CLI)
target_link_libraries(quickstep_storage_BlockWire_proto
${PROTOBUF_LIBRARY})
target_link_libraries(quickstep_storage_DataProviderThread
${GRPCPLUSPLUS_LIBRARIES}
glog
quickstep_catalog_CatalogDatabase
quickstep_catalog_CatalogRelation
Expand All @@ -1118,12 +1117,12 @@ if (ENABLE_NETWORK_CLI)
quickstep_threading_Thread
quickstep_threading_ThreadUtil
quickstep_utility_Macros
tmb
${GRPCPLUSPLUS_LIBRARIES})
tmb)
target_link_libraries(quickstep_storage_StorageManager
${GRPCPLUSPLUS_LIBRARIES}
quickstep_storage_BlockWire_proto)
endif()

if (QUICKSTEP_HAVE_FILE_MANAGER_HDFS)
target_link_libraries(quickstep_storage_FileManagerHdfs
${LIBHDFS3_LIBRARIES}
Expand Down Expand Up @@ -1581,9 +1580,9 @@ if (ENABLE_NETWORK_CLI)
quickstep_queryexecution_WorkerDirectory
quickstep_queryoptimizer_QueryProcessor
quickstep_queryoptimizer_tests_TestDatabaseLoader
quickstep_storage_BlockWire_proto
quickstep_storage_DataProviderThread
quickstep_storage_StorageConstants
quickstep_storage_BlockWire_proto
tmb)
add_test(DataProviderThread_unittest DataProviderThread_unittest)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data_provider_thread_test_data)
Expand Down

0 comments on commit 97bef17

Please sign in to comment.