Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ install:
before_script:
# first, run source_validator
- python script/validators/source_validator.py
# enable aliases and make python3 point to python
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then alias python3=python && shopt -s expand_aliases; fi

# build peloton (override this value to execute tests)
script:
Expand Down
5 changes: 5 additions & 0 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ llvm_map_components_to_libnames(LLVM_LIBRARIES core mcjit nativecodegen native)
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
list(APPEND Peloton_LINKER_LIBS ${LLVM_LIBRARIES})

# --[ FFI
find_package(Libffi)
include_directories(SYSTEM ${LIBFFI_INCLUDE_DIRS})
list(APPEND Peloton_LINKER_LIBS ${LIBFFI_LIBRARIES})

# --[ IWYU

# Generate clang compilation database
Expand Down
39 changes: 39 additions & 0 deletions cmake/Modules/FindLibffi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# - Try to find Libffi
#
# A Portable Foreign Function Interface Library (https://sourceware.org/libffi)
#
# Usage:
# LIBFFI_INCLUDE_DIRS, location of header files
# LIBFFI_LIBRARIES, location of library
# LIBFFI_FOUND, indicates if libffi was found

# Look for the header file.
execute_process(COMMAND brew --prefix libffi OUTPUT_VARIABLE LIBFFI_BREW_PREFIX)

find_library(LIBFFI_LIBRARY NAMES ffi libffi
PATHS /usr /usr/local /opt/local
PATH_SUFFIXES lib lib64 x86_64-linux-gnu lib/x86_64-linux-gnu
)

find_path(LIBFFI_INCLUDE_DIR ffi.h
PATHS /usr /usr/local /opt/local /usr/include/ffi
PATH_SUFFIXES include include/ffi include/x86_64-linux-gnu x86_64-linux-gnu
HINT LIBFFI_BREW_PREFIX
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBFFI DEFAULT_MSG LIBFFI_LIBRARY LIBFFI_INCLUDE_DIR)


# Copy the results to the output variables.
IF(LIBFFI_FOUND)
SET(LIBFFI_LIBRARIES ${LIBFFI_LIBRARY})
SET(LIBFFI_INCLUDE_DIRS ${LIBFFI_INCLUDE_DIR})
ELSE(LIBFFI_FOUND)
SET(LIBFFI_LIBRARIES)
SET(LIBFFI_INCLUDE_DIRS)
ENDIF(LIBFFI_FOUND)

MARK_AS_ADVANCED(LIBFFI_INCLUDE_DIRS LIBFFI_LIBRARIES)

message(STATUS "Found Libffi (include: ${LIBFFI_INCLUDE_DIRS}, library: ${LIBFFI_LIBRARIES})")
6 changes: 4 additions & 2 deletions script/installation/packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ if [ "$DISTRO" = "UBUNTU" ]; then
libedit-dev \
libssl-dev \
postgresql-client \
libffi6 \
libffi-dev \
libtbb-dev \
python3-pip \
curl \
Expand Down Expand Up @@ -219,11 +221,11 @@ elif [ "$DISTRO" = "DARWIN" ]; then
brew install libedit
brew install llvm@3.7
brew install postgresql
brew install libffi
brew install tbb
brew install curl
brew install wget
brew install python
brew upgrade python
python3 -m ensurepip
brew install eigen
brew install ant
# Brew installs correct version of Protobuf(3.5.1 >= 3.4.0)
Expand Down
29 changes: 1 addition & 28 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,6 @@ set_target_properties(peloton-bin PROPERTIES OUTPUT_NAME peloton)

##################################################################################

# --[ Benchmarks

# --[ tpcc
file(GLOB_RECURSE tpcc_srcs ${PROJECT_SOURCE_DIR}/src/main/tpcc/*.cpp)
add_executable(tpcc EXCLUDE_FROM_ALL ${tpcc_srcs})
target_link_libraries(tpcc peloton)

# --[ ycsb
file(GLOB_RECURSE ycsb_srcs ${PROJECT_SOURCE_DIR}/src/main/ycsb/*.cpp)
add_executable(ycsb EXCLUDE_FROM_ALL ${ycsb_srcs})
target_link_libraries(ycsb peloton)

# --[ sdbench
file(GLOB_RECURSE sdbench_srcs ${PROJECT_SOURCE_DIR}/src/main/sdbench/*.cpp)
add_executable(sdbench EXCLUDE_FROM_ALL ${sdbench_srcs})
target_link_libraries(sdbench peloton)

# --[ tpch
file(GLOB_RECURSE tpch_srcs ${PROJECT_SOURCE_DIR}/src/main/tpch/*.cpp)
add_executable(tpch EXCLUDE_FROM_ALL ${tpch_srcs})
target_link_libraries(tpch peloton)

# --[ logger
#file(GLOB_RECURSE logger_srcs ${PROJECT_SOURCE_DIR}/src/main/logger/*.cpp)
#list(APPEND logger_srcs ${ycsb_srcs})
Expand All @@ -96,16 +74,11 @@ target_link_libraries(tpch peloton)
# --[ link to jemalloc
set(EXE_LINK_LIBRARIES ${JEMALLOC_LIBRARIES})
set(EXE_LINK_FLAGS "-Wl,--no-as-needed")
set(EXE_LIST peloton-bin ycsb tpcc sdbench tpch)
set(EXE_LIST peloton-bin)
foreach(exe_name ${EXE_LIST})
target_link_libraries(${exe_name} ${EXE_LINK_LIBRARIES})
if (LINUX)
set_target_properties(${exe_name} PROPERTIES LINK_FLAGS ${EXE_LINK_FLAGS})
endif ()
endforeach()

# --[ benchmark

add_custom_target(benchmark)
add_dependencies(benchmark tpcc ycsb sdbench)

2 changes: 1 addition & 1 deletion src/binder/bind_node_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void BindNodeVisitor::Visit(parser::AnalyzeStatement *node) {
void BindNodeVisitor::Visit(expression::TupleValueExpression *expr) {
if (!expr->GetIsBound()) {
std::tuple<oid_t, oid_t, oid_t> col_pos_tuple;
std::shared_ptr<catalog::TableCatalogObject> table_obj = nullptr;
std::shared_ptr<catalog::TableCatalogEntry> table_obj = nullptr;
type::TypeId value_type;
int depth = -1;

Expand Down
16 changes: 9 additions & 7 deletions src/binder/binder_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ void BinderContext::AddRegularTable(const std::string db_name,
const std::string table_alias,
concurrency::TransactionContext *txn) {
// using catalog object to retrieve meta-data
auto table_object = catalog::Catalog::GetInstance()->GetTableObject(
db_name, schema_name, table_name, txn);
auto table_object = catalog::Catalog::GetInstance()->GetTableCatalogEntry(txn,
db_name,
schema_name,
table_name);

if (regular_table_alias_map_.find(table_alias) !=
regular_table_alias_map_.end() ||
Expand Down Expand Up @@ -79,9 +81,9 @@ void BinderContext::AddNestedTable(

bool BinderContext::GetColumnPosTuple(
const std::string &col_name,
std::shared_ptr<catalog::TableCatalogObject> table_obj,
std::shared_ptr<catalog::TableCatalogEntry> table_obj,
std::tuple<oid_t, oid_t, oid_t> &col_pos_tuple, type::TypeId &value_type) {
auto column_object = table_obj->GetColumnObject(col_name);
auto column_object = table_obj->GetColumnCatalogEntry(col_name);
if (column_object == nullptr) {
return false;
}
Expand Down Expand Up @@ -138,7 +140,7 @@ bool BinderContext::GetColumnPosTuple(

bool BinderContext::GetRegularTableObj(
std::shared_ptr<BinderContext> current_context, std::string &alias,
std::shared_ptr<catalog::TableCatalogObject> &table_obj, int &depth) {
std::shared_ptr<catalog::TableCatalogEntry> &table_obj, int &depth) {
while (current_context != nullptr) {
auto iter = current_context->regular_table_alias_map_.find(alias);
if (iter != current_context->regular_table_alias_map_.end()) {
Expand Down Expand Up @@ -174,9 +176,9 @@ void BinderContext::GenerateAllColumnExpressions(
std::vector<std::unique_ptr<expression::AbstractExpression>> &exprs) {
for (auto &entry : regular_table_alias_map_) {
auto &table_obj = entry.second;
auto col_cnt = table_obj->GetColumnObjects().size();
auto col_cnt = table_obj->GetColumnCatalogEntries().size();
for (size_t i = 0; i < col_cnt; i++) {
auto col_obj = table_obj->GetColumnObject(i);
auto col_obj = table_obj->GetColumnCatalogEntry(i);
auto tv_expr = new expression::TupleValueExpression(
std::string(col_obj->GetColumnName()), std::string(entry.first));
tv_expr->SetValueType(col_obj->GetColumnType());
Expand Down
2 changes: 0 additions & 2 deletions src/brain/modelgen/LSTM.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ def __repr__(self):

def main():
parser = argparse.ArgumentParser(description='LSTM Model Generator')


parser.add_argument('--nfeats', type=int, default=3, help='Input feature length(input to encoder/linear layer)')
parser.add_argument('--nencoded', type=int, default=20, help='Encoded feature length(input to LSTM)')
parser.add_argument('--nhid', type=int, default=20, help='Number of LSTM Hidden units')
Expand Down
7 changes: 5 additions & 2 deletions src/brain/query_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ void QueryLogger::LogQuery(std::string query_string, uint64_t timestamp) {

// Log query + fingerprint
auto &query_history_catalog = catalog::QueryHistoryCatalog::GetInstance();
query_history_catalog.InsertQueryHistory(
query_string, fingerprint.GetFingerprint(), timestamp, nullptr, txn);
query_history_catalog.InsertQueryHistory(txn,
query_string,
fingerprint.GetFingerprint(),
timestamp,
nullptr);

// We're done
txn_manager.CommitTransaction(txn);
Expand Down
79 changes: 42 additions & 37 deletions src/catalog/abstract_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "planner/seq_scan_plan.h"

#include "executor/executor_context.h"
#include "executor/create_executor.h"
#include "executor/delete_executor.h"
#include "executor/index_scan_executor.h"
#include "executor/insert_executor.h"
Expand All @@ -44,48 +45,48 @@
namespace peloton {
namespace catalog {

AbstractCatalog::AbstractCatalog(oid_t catalog_table_oid,
std::string catalog_table_name,
AbstractCatalog::AbstractCatalog(storage::Database *pg_catalog,
catalog::Schema *catalog_table_schema,
storage::Database *pg_catalog) {
oid_t catalog_table_oid,
std::string catalog_table_name) {
// set database_oid
database_oid = pg_catalog->GetOid();
database_oid_ = pg_catalog->GetOid();
// Create catalog_table_
catalog_table_ = storage::TableFactory::GetDataTable(
database_oid, catalog_table_oid, catalog_table_schema, catalog_table_name,
database_oid_, catalog_table_oid, catalog_table_schema, catalog_table_name,
DEFAULT_TUPLES_PER_TILEGROUP, true, false, true);
// Add catalog_table_ into pg_catalog database
pg_catalog->AddTable(catalog_table_, true);
}

AbstractCatalog::AbstractCatalog(const std::string &catalog_table_ddl,
concurrency::TransactionContext *txn) {
// get catalog table schema
AbstractCatalog::AbstractCatalog(concurrency::TransactionContext *txn,
const std::string &catalog_table_ddl) {
// Execute create catalog table
auto &peloton_parser = parser::PostgresParser::GetInstance();
std::unique_ptr<executor::ExecutorContext> context(
new executor::ExecutorContext(txn));
auto create_plan = std::dynamic_pointer_cast<planner::CreatePlan>(
optimizer::Optimizer().BuildPelotonPlanTree(
peloton_parser.BuildParseTree(catalog_table_ddl), txn));
auto catalog_table_schema = create_plan->GetSchema();
auto catalog_table_name = create_plan->GetTableName();
auto catalog_schema_name = create_plan->GetSchemaName();
auto catalog_database_name = create_plan->GetDatabaseName();
PELOTON_ASSERT(catalog_schema_name == std::string(CATALOG_SCHEMA_NAME));
// create catalog table
Catalog::GetInstance()->CreateTable(
catalog_database_name, catalog_schema_name, catalog_table_name,
std::unique_ptr<catalog::Schema>(catalog_table_schema), txn, true);
executor::CreateExecutor executor(create_plan.get(), context.get());

executor.Init();
executor.Execute();

// get catalog table oid
auto catalog_table_object = Catalog::GetInstance()->GetTableObject(
catalog_database_name, catalog_schema_name, catalog_table_name, txn);
auto catalog_table_object =
Catalog::GetInstance()->GetTableCatalogEntry(txn,
create_plan->GetDatabaseName(),
create_plan->GetSchemaName(),
create_plan->GetTableName());

// set catalog_table_
try {
catalog_table_ = storage::StorageManager::GetInstance()->GetTableWithOid(
catalog_table_object->GetDatabaseOid(),
catalog_table_object->GetTableOid());
// set database_oid
database_oid = catalog_table_object->GetDatabaseOid();
database_oid_ = catalog_table_object->GetDatabaseOid();
} catch (CatalogException &e) {
LOG_TRACE("Can't find table %d! Return false",
catalog_table_object->GetTableOid());
Expand All @@ -97,8 +98,8 @@ AbstractCatalog::AbstractCatalog(const std::string &catalog_table_ddl,
* @param txn TransactionContext
* @return Whether insertion is Successful
*/
bool AbstractCatalog::InsertTuple(std::unique_ptr<storage::Tuple> tuple,
concurrency::TransactionContext *txn) {
bool AbstractCatalog::InsertTuple(concurrency::TransactionContext *txn,
std::unique_ptr<storage::Tuple> tuple) {
if (txn == nullptr)
throw CatalogException("Insert tuple requires transaction");

Expand Down Expand Up @@ -137,9 +138,9 @@ bool AbstractCatalog::InsertTuple(std::unique_ptr<storage::Tuple> tuple,
* @param txn TransactionContext
* @return Whether deletion is Successful
*/
bool AbstractCatalog::DeleteWithIndexScan(
oid_t index_offset, std::vector<type::Value> values,
concurrency::TransactionContext *txn) {
bool AbstractCatalog::DeleteWithIndexScan(concurrency::TransactionContext *txn,
oid_t index_offset,
std::vector<type::Value> values) {
if (txn == nullptr)
throw CatalogException("Delete tuple requires transaction");

Expand Down Expand Up @@ -189,9 +190,10 @@ bool AbstractCatalog::DeleteWithIndexScan(
*/
std::unique_ptr<std::vector<std::unique_ptr<executor::LogicalTile>>>
AbstractCatalog::GetResultWithIndexScan(
std::vector<oid_t> column_offsets, oid_t index_offset,
std::vector<type::Value> values,
concurrency::TransactionContext *txn) const {
concurrency::TransactionContext *txn,
std::vector<oid_t> column_offsets,
oid_t index_offset,
std::vector<type::Value> values) const {
if (txn == nullptr) throw CatalogException("Scan table requires transaction");

// Index scan
Expand Down Expand Up @@ -238,9 +240,10 @@ AbstractCatalog::GetResultWithIndexScan(
* @return Unique pointer of vector of logical tiles
*/
std::unique_ptr<std::vector<std::unique_ptr<executor::LogicalTile>>>
AbstractCatalog::GetResultWithSeqScan(std::vector<oid_t> column_offsets,
expression::AbstractExpression *predicate,
concurrency::TransactionContext *txn) {
AbstractCatalog::GetResultWithSeqScan(
concurrency::TransactionContext *txn,
expression::AbstractExpression *predicate,
std::vector<oid_t> column_offsets) {
if (txn == nullptr) throw CatalogException("Scan table requires transaction");

// Sequential scan
Expand Down Expand Up @@ -272,8 +275,9 @@ AbstractCatalog::GetResultWithSeqScan(std::vector<oid_t> column_offsets,
* Note: Use catalog::Catalog::CreateIndex() if you can, only ColumnCatalog and
* IndexCatalog should need this
*/
void AbstractCatalog::AddIndex(const std::vector<oid_t> &key_attrs,
oid_t index_oid, const std::string &index_name,
void AbstractCatalog::AddIndex(const std::string &index_name,
oid_t index_oid,
const std::vector<oid_t> &key_attrs,
IndexConstraintType index_constraint) {
auto schema = catalog_table_->GetSchema();
auto key_schema = catalog::Schema::CopySchema(schema, key_attrs);
Expand Down Expand Up @@ -307,10 +311,11 @@ void AbstractCatalog::AddIndex(const std::vector<oid_t> &key_attrs,
* @param index_offset Offset of index for scan
* @return true if successfully executes
*/
bool AbstractCatalog::UpdateWithIndexScan(
std::vector<oid_t> update_columns, std::vector<type::Value> update_values,
std::vector<type::Value> scan_values, oid_t index_offset,
concurrency::TransactionContext *txn) {
bool AbstractCatalog::UpdateWithIndexScan(concurrency::TransactionContext *txn,
oid_t index_offset,
std::vector<type::Value> scan_values,
std::vector<oid_t> update_columns,
std::vector<type::Value> update_values) {
if (txn == nullptr) throw CatalogException("Scan table requires transaction");

std::unique_ptr<executor::ExecutorContext> context(
Expand Down
Loading