Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Move ArrowResultSetConverter to ResultSet library.
Browse files Browse the repository at this point in the history
Signed-off-by: ienkovich <[email protected]>
  • Loading branch information
ienkovich committed Jun 28, 2023
1 parent 84d38f1 commit 4793f42
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 71 deletions.
4 changes: 0 additions & 4 deletions omniscidb/QueryEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ set(query_engine_source_files
ArithmeticIR.cpp
ArrayIR.cpp
ArrayOps.cpp
ArrowResultSetConverter.cpp
ArrowResultSet.cpp
BitmapGenerators.cpp
CalciteDeserializerUtils.cpp
CardinalityEstimator.cpp
CaseIR.cpp
Expand Down Expand Up @@ -318,7 +315,6 @@ set(QUERY_ENGINE_LIBS
SchemaMgr
SqliteConnector
SQLite::SQLite3
${Arrow_LIBRARIES}
)

list(APPEND QUERY_ENGINE_LIBS ${llvm_libs} ${ZLIB_LIBRARIES})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "QueryEngine/ArrowResultSet.h"
#include "ArrowResultSet.h"

#include <arrow/api.h>
#include <arrow/io/memory.h>
Expand Down Expand Up @@ -331,43 +331,15 @@ void ArrowResultSet::resultSetArrowLoopback(
}

std::unique_ptr<ArrowResultSet> result_set_arrow_loopback(
const ExecutionResult& results) {
// NOTE(wesm): About memory ownership

// After calling ReadRecordBatch, the buffers inside arrow::RecordBatch now
// share ownership of the memory in serialized_arrow_output.records (zero
// copy). Not necessary to retain these buffers. Same is true of any
// dictionaries contained in serialized_arrow_output.schema; the arrays
// reference that memory (zero copy).
return std::make_unique<ArrowResultSet>(results.getRows(), results.getTargetsMeta());
}

std::unique_ptr<ArrowResultSet> result_set_arrow_loopback(
const ExecutionResult* results,
const std::shared_ptr<ResultSet>& rows,
const ExecutorDeviceType device_type) {
return results ? std::make_unique<ArrowResultSet>(
rows, results->getTargetsMeta(), device_type)
: std::make_unique<ArrowResultSet>(rows, device_type);
}

std::unique_ptr<ArrowResultSet> result_set_arrow_loopback(
const ExecutionResult* results,
const std::shared_ptr<ResultSet>& rows,
const ExecutorDeviceType device_type,
const size_t min_result_size_for_bulk_dictionary_fetch,
const double max_dictionary_to_result_size_ratio_for_bulk_dictionary_fetch) {
std::vector<hdk::ir::TargetMetaInfo> dummy_targets_meta;
return results ? std::make_unique<ArrowResultSet>(
rows,
results->getTargetsMeta(),
device_type,
min_result_size_for_bulk_dictionary_fetch,
max_dictionary_to_result_size_ratio_for_bulk_dictionary_fetch)
: std::make_unique<ArrowResultSet>(
rows,
dummy_targets_meta,
device_type,
min_result_size_for_bulk_dictionary_fetch,
max_dictionary_to_result_size_ratio_for_bulk_dictionary_fetch);
return std::make_unique<ArrowResultSet>(
rows,
dummy_targets_meta,
device_type,
min_result_size_for_bulk_dictionary_fetch,
max_dictionary_to_result_size_ratio_for_bulk_dictionary_fetch);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

#pragma once

#include "CompilationOptions.h"
#include "Descriptors/RelAlgExecutionDescriptor.h"

#include "DataMgr/DataMgr.h"
#include "IR/TargetMetaInfo.h"
#include "ResultSet/ResultSet.h"
Expand Down Expand Up @@ -183,26 +180,11 @@ ArrowResultSetRowIterator::value_type ArrowResultSetRowIterator::operator*() con
return result_set_->getRowAt(crt_row_idx_);
}

class ExecutionResult;

// The following result_set_arrow_loopback methods are used by our test
// framework (ExecuteTest specifically) to take results from the executor,
// serialize them to Arrow and then deserialize them to an ArrowResultSet,
// which can then be used by the test framework.

std::unique_ptr<ArrowResultSet> result_set_arrow_loopback(const ExecutionResult& results);

std::unique_ptr<ArrowResultSet> result_set_arrow_loopback(
const ExecutionResult* results,
const std::shared_ptr<ResultSet>& rows,
const ExecutorDeviceType device_type = ExecutorDeviceType::CPU);

// This version of result_set_arrow_loopback allows setting the parameters that
// drive the choice between dense and sparse dictionary conversion, used for
// Select.ArrowDictionaries tests in ExecuteTest

std::unique_ptr<ArrowResultSet> result_set_arrow_loopback(
const ExecutionResult* results,
const std::shared_ptr<ResultSet>& rows,
const ExecutorDeviceType device_type,
const size_t min_result_size_for_bulk_dictionary_fetch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
// project headers
#include "ArrowResultSet.h"
#include "BitmapGenerators.h"
#include "Execute.h"

#include "Shared/ArrowUtil.h"
#include "Shared/DateConverters.h"
#include "Shared/thread_count.h"
#include "Shared/toString.h"
#include "StringDictionary/StringDictionaryProxy.h"

// arrow headers
#include "arrow/api.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Copyright (C) 2023 Intel Corporation
* Copyright 2021 OmniSci, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "BitmapGenerators.h"
#include <immintrin.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Copyright (C) 2023 Intel Corporation
* Copyright 2021 OmniSci, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef BITMAP_GENERATORS_h
#define BITMAP_GENERATORS_h

Expand All @@ -23,4 +30,4 @@ size_t gen_null_bitmap_64(uint8_t* bitmap,
const uint64_t* data,
size_t size,
const uint64_t null_val);
#endif
#endif
5 changes: 4 additions & 1 deletion omniscidb/ResultSet/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
set(result_set_source_files
ArrowResultSet.cpp
ArrowResultSetConverter.cpp
BitmapGenerators.cpp
ColSlotContext.cpp
QueryMemoryDescriptor.cpp
ResultSet.cpp
Expand All @@ -11,4 +14,4 @@ set(result_set_source_files

add_library(ResultSet ${result_set_source_files})

target_link_libraries(ResultSet DataMgr IR Logger Utils StringDictionary ${Folly_LIBRARIES})
target_link_libraries(ResultSet DataMgr IR Logger Utils StringDictionary ${Folly_LIBRARIES} ${Arrow_LIBRARIES})
2 changes: 1 addition & 1 deletion omniscidb/Tests/ArrowBasedExecuteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#include "ArrowSQLRunner/SQLiteComparator.h"
#include "TestHelpers.h"

#include "QueryEngine/ArrowResultSet.h"
#include "QueryEngine/Execute.h"
#include "QueryEngine/ResultSetReductionJIT.h"
#include "ResultSet/ArrowResultSet.h"
#include "Shared/scope.h"

#include <gtest/gtest.h>
Expand Down
1 change: 0 additions & 1 deletion omniscidb/Tests/ArrowSQLRunner/ArrowSQLRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ class ArrowSQLRunnerImpl {
double max_dictionary_to_result_size_ratio_for_bulk_dictionary_fetch) {
auto results = run_multiple_agg(query_string, device_type);
auto arrow_omnisci_results = result_set_arrow_loopback(
nullptr,
results,
device_type,
min_result_size_for_bulk_dictionary_fetch,
Expand Down
2 changes: 1 addition & 1 deletion omniscidb/Tests/ArrowSQLRunner/ArrowSQLRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

#include "ArrowStorage/ArrowStorage.h"
#include "IR/Context.h"
#include "QueryEngine/ArrowResultSet.h"
#include "QueryEngine/CompilationOptions.h"
#include "QueryEngine/Descriptors/RelAlgExecutionDescriptor.h"
#include "ResultSet/ArrowResultSet.h"
#include "ResultSetRegistry/ResultSetRegistry.h"
#include "Shared/Config.h"

Expand Down
2 changes: 1 addition & 1 deletion omniscidb/Tests/ArrowSQLRunner/SQLiteComparator.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#include "QueryEngine/ArrowResultSet.h"
#include "ResultSet/ArrowResultSet.h"
#include "Shared/sqltypes.h"
#include "SqliteConnector/SqliteConnector.h"

Expand Down
2 changes: 1 addition & 1 deletion omniscidb/Tests/ArrowStorageSqlTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include "Calcite/CalciteJNI.h"
#include "DataMgr/DataMgrBufferProvider.h"
#include "DataMgr/DataMgrDataProvider.h"
#include "QueryEngine/ArrowResultSet.h"
#include "QueryEngine/RelAlgExecutor.h"
#include "ResultSet/ArrowResultSet.h"

#include "ArrowSQLRunner/ArrowSQLRunner.h"

Expand Down
2 changes: 1 addition & 1 deletion omniscidb/Tests/CorrelatedSubqueryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include "TestHelpers.h"

#include "ConfigBuilder/ConfigBuilder.h"
#include "QueryEngine/ArrowResultSet.h"
#include "QueryEngine/Execute.h"
#include "QueryEngine/RelAlgExecutor.h"
#include "ResultSet/ArrowResultSet.h"
#include "Shared/file_delete.h"
#include "Shared/scope.h"

Expand Down
2 changes: 1 addition & 1 deletion omniscidb/Tests/FromTableReorderingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

#include "TestHelpers.h"

#include "../QueryEngine/ArrowResultSet.h"
#include "../QueryEngine/Descriptors/RelAlgExecutionDescriptor.h"
#include "../QueryEngine/Execute.h"
#include "../QueryEngine/FromTableReordering.h"
#include "../ResultSet/ArrowResultSet.h"
#include "../Shared/scope.h"
#include "../SqliteConnector/SqliteConnector.h"

Expand Down
2 changes: 1 addition & 1 deletion omniscidb/Tests/NoCatalogSqlTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "Calcite/CalciteJNI.h"
#include "DataMgr/DataMgrBufferProvider.h"
#include "DataMgr/DataMgrDataProvider.h"
#include "QueryEngine/ArrowResultSet.h"
#include "QueryEngine/RelAlgExecutor.h"
#include "ResultSet/ArrowResultSet.h"
#include "SchemaMgr/SimpleSchemaProvider.h"
#include "Shared/scope.h"

Expand Down
2 changes: 1 addition & 1 deletion omniscidb/Tests/ResultSetArrowConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "ArrowSQLRunner/ArrowSQLRunner.h"
#include "ArrowTestHelpers.h"

#include "QueryEngine/ArrowResultSet.h"
#include "ResultSet/ArrowResultSet.h"
#include "Shared/ArrowUtil.h"
#include "Shared/InlineNullValues.h"
#include "Shared/scope.h"
Expand Down
2 changes: 1 addition & 1 deletion omniscidb/Tests/TestHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#define TEST_HELPERS_H_

#include "Logger/Logger.h"
#include "QueryEngine/ArrowResultSet.h"
#include "QueryEngine/Descriptors/RelAlgExecutionDescriptor.h"
#include "ResultSet/ArrowResultSet.h"

#include <gtest/gtest.h>
#include <boost/algorithm/string.hpp>
Expand Down
2 changes: 1 addition & 1 deletion python/pyhdk/_execute.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ cdef extern from "omniscidb/IR/TargetMetaInfo.h":
const string& get_resname()
const CType* type()

cdef extern from "omniscidb/QueryEngine/ArrowResultSet.h":
cdef extern from "omniscidb/ResultSet/ArrowResultSet.h":
cdef cppclass CArrowResultSetConverter "ArrowResultSetConverter":
CArrowResultSetConverter(const CResultSetPtr&, const vector[string]&, int)

Expand Down

0 comments on commit 4793f42

Please sign in to comment.