Skip to content

Commit

Permalink
modify file under VectorIndex folder and use abbreviation for vector …
Browse files Browse the repository at this point in the history
…index and vector scan
  • Loading branch information
sw1228 authored and Shanfeng Pang committed Apr 16, 2024
1 parent 9a321e3 commit e31254f
Show file tree
Hide file tree
Showing 124 changed files with 1,064 additions and 1,102 deletions.
78 changes: 39 additions & 39 deletions programs/local/LocalServer.cpp
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
#include "LocalServer.h"

#include <sys/resource.h>
#include <Common/logger_useful.h>
#include <base/errnoToString.h>
#include <Poco/Util/XMLConfiguration.h>
#include <Poco/String.h>
#include <Poco/Logger.h>
#include <Poco/NullChannel.h>
#include <Poco/SimpleFileChannel.h>
#include <filesystem>
#include <Access/AccessControl.h>
#include <AggregateFunctions/registerAggregateFunctions.h>
#include <Databases/DatabaseMemory.h>
#include <Storages/System/attachSystemTables.h>
#include <Storages/System/attachInformationSchemaTables.h>
#include <Dictionaries/registerDictionaries.h>
#include <Disks/registerDisks.h>
#include <Formats/FormatFactory.h>
#include <Formats/registerFormats.h>
#include <Functions/UserDefined/IUserDefinedSQLObjectsLoader.h>
#include <Functions/registerFunctions.h>
#include <IO/IOThreadPool.h>
#include <IO/ReadBufferFromFile.h>
#include <IO/ReadBufferFromString.h>
#include <IO/UseSSL.h>
#include <IO/WriteBufferFromFileDescriptor.h>
#include <Interpreters/DatabaseCatalog.h>
#include <Interpreters/JIT/CompiledExpressionCache.h>
#include <Interpreters/ProcessList.h>
#include <Interpreters/Session.h>
#include <Interpreters/loadMetadata.h>
#include <Loggers/Loggers.h>
#include <Parsers/ASTInsertQuery.h>
#include <Parsers/IAST.h>
#include <Storages/System/attachInformationSchemaTables.h>
#include <Storages/System/attachSystemTables.h>
#include <Storages/registerStorages.h>
#include <TableFunctions/registerTableFunctions.h>
#include <VectorIndex/Common/VIBuildMemoryUsageHelper.h>
#include <base/argsToConfig.h>
#include <base/errnoToString.h>
#include <base/getFQDNOrHostName.h>
#include <Common/scope_guard_safe.h>
#include <Interpreters/Session.h>
#include <Access/AccessControl.h>
#include <boost/algorithm/string/replace.hpp>
#include <boost/program_options/options_description.hpp>
#include <sys/resource.h>
#include <Poco/Logger.h>
#include <Poco/NullChannel.h>
#include <Poco/SimpleFileChannel.h>
#include <Poco/String.h>
#include <Poco/Util/XMLConfiguration.h>
#include <Common/Config/ConfigProcessor.h>
#include <Common/ErrorHandlers.h>
#include <Common/Exception.h>
#include <Common/Macros.h>
#include <Common/Config/ConfigProcessor.h>
#include <Common/ThreadStatus.h>
#include <Common/TLDListsHolder.h>
#include <Common/ThreadStatus.h>
#include <Common/logger_useful.h>
#include <Common/quoteString.h>
#include <Common/randomSeed.h>
#include <Loggers/Loggers.h>
#include <IO/ReadBufferFromFile.h>
#include <IO/ReadBufferFromString.h>
#include <IO/WriteBufferFromFileDescriptor.h>
#include <IO/UseSSL.h>
#include <IO/IOThreadPool.h>
#include <Parsers/IAST.h>
#include <Parsers/ASTInsertQuery.h>
#include <Common/ErrorHandlers.h>
#include <Functions/UserDefined/IUserDefinedSQLObjectsLoader.h>
#include <Functions/registerFunctions.h>
#include <AggregateFunctions/registerAggregateFunctions.h>
#include <TableFunctions/registerTableFunctions.h>
#include <Storages/registerStorages.h>
#include <Dictionaries/registerDictionaries.h>
#include <Disks/registerDisks.h>
#include <Formats/registerFormats.h>
#include <Formats/FormatFactory.h>
#include <boost/algorithm/string/replace.hpp>
#include <boost/program_options/options_description.hpp>
#include <base/argsToConfig.h>
#include <filesystem>
#include <VectorIndex/Common/IndexBuildMemoryUsageHelper.h>
#include <Common/scope_guard_safe.h>

#if defined(FUZZING_MODE)
#include <Functions/getFuzzerData.h>
Expand Down Expand Up @@ -447,7 +447,7 @@ try
processConfig();
initTtyBuffer(toProgressOption(config().getString("progress", "default")));

VectorIndex::IndexBuildMemoryUsageHelper::setCacheManagerSizeInBytes(0);
VectorIndex::VIBuildMemoryUsageHelper::setCacheManagerSizeInBytes(0);

applyCmdSettings(global_context);

Expand Down
10 changes: 5 additions & 5 deletions programs/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
#include <filesystem>
#include <unordered_set>

#include <VectorIndex/Common/VectorIndexCommon.h>
#include <VectorIndex/Common/IndexBuildMemoryUsageHelper.h>
#include <VectorIndex/Common/VIBuildMemoryUsageHelper.h>
#include <VectorIndex/Common/VICommon.h>

#include "config.h"
#include "config_version.h"
Expand Down Expand Up @@ -1254,7 +1254,7 @@ try
const size_t vector_index_cache_max_size = static_cast<size_t>(max_memory_usage * vector_index_cache_ratio);
LOG_INFO(log, "vector_index_cache_max_size = {}", formatReadableSizeWithBinarySuffix(vector_index_cache_max_size));

VectorIndex::IndexBuildMemoryUsageHelper::setCacheManagerSizeInBytes(vector_index_cache_max_size);
VectorIndex::VIBuildMemoryUsageHelper::setCacheManagerSizeInBytes(vector_index_cache_max_size);

/// Set vector index build memory limit
float vector_index_build_ratio = server_settings.vector_index_build_size_ratio_of_memory;
Expand All @@ -1267,7 +1267,7 @@ try
const size_t vector_index_build_max_size = static_cast<size_t>(max_memory_usage * vector_index_build_ratio);
LOG_INFO(log, "vector_index_build_max_size = {}", formatReadableSizeWithBinarySuffix(vector_index_build_max_size));

VectorIndex::IndexBuildMemoryUsageHelper::setBuildMemorySizeInBytes(vector_index_build_max_size);
VectorIndex::VIBuildMemoryUsageHelper::setBuildMemorySizeInBytes(vector_index_build_max_size);

// FIXME logging-related things need synchronization -- see the 'Logger * log' saved
// in a lot of places. For now, disable updating log configuration without server restart.
Expand Down Expand Up @@ -1539,7 +1539,7 @@ try
LOG_INFO(log, "Primary key cache size was lowered to {} because the system has low amount of memory",
formatReadableSizeWithBinarySuffix(mark_cache_size));
}
global_context->setPrimaryKeyCacheSize(primary_key_cache_size);
global_context->setPKCacheSize(primary_key_cache_size);

if (server_settings.mmap_cache_size)
global_context->setMMappedFileCache(server_settings.mmap_cache_size);
Expand Down
12 changes: 6 additions & 6 deletions src/Common/SystemLogBase.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#include <Interpreters/AsynchronousInsertLog.h>
#include <Interpreters/AsynchronousMetricLog.h>
#include <Interpreters/CrashLog.h>
#include <Interpreters/FilesystemCacheLog.h>
#include <Interpreters/FilesystemReadPrefetchesLog.h>
#include <Interpreters/MetricLog.h>
#include <Interpreters/OpenTelemetrySpanLog.h>
#include <Interpreters/PartLog.h>
#include <Interpreters/ProcessorsProfileLog.h>
#include <Interpreters/QueryLog.h>
#include <Interpreters/QueryThreadLog.h>
#include <Interpreters/QueryViewsLog.h>
#include <Interpreters/SessionLog.h>
#include <Interpreters/TextLog.h>
#include <Interpreters/TraceLog.h>
#include <Interpreters/FilesystemCacheLog.h>
#include <Interpreters/FilesystemReadPrefetchesLog.h>
#include <Interpreters/ProcessorsProfileLog.h>
#include <Interpreters/ZooKeeperLog.h>
#include <Interpreters/TransactionsInfoLog.h>
#include <Interpreters/AsynchronousInsertLog.h>
#include <VectorIndex/Interpreters/VectorIndexEventLog.h>
#include <Interpreters/ZooKeeperLog.h>
#include <VectorIndex/Interpreters/VIEventLog.h>

#include <Common/MemoryTrackerBlockerInThread.h>
#include <Common/SystemLogBase.h>
Expand Down
2 changes: 1 addition & 1 deletion src/Common/SystemLogBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
M(FilesystemCacheLogElement) \
M(FilesystemReadPrefetchesLogElement) \
M(AsynchronousInsertLogElement) \
M(VectorIndexEventLogElement)
M(VIEventLogElement)

namespace Poco
{
Expand Down
2 changes: 1 addition & 1 deletion src/Interpreters/ActionsDAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <Core/Names.h>
#include <Core/NamesAndTypes.h>
#include <Interpreters/Context_fwd.h>
#include <VectorIndex/Utils/VectorScanUtils.h>
#include <VectorIndex/Utils/CommonUtils.h>
#include <Common/logger_useful.h>

#include "config.h"
Expand Down
2 changes: 1 addition & 1 deletion src/Interpreters/ActionsVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <Core/ColumnNumbers.h>
#include <Core/ColumnWithTypeAndName.h>

#include <VectorIndex/Utils/VectorScanUtils.h>
#include <VectorIndex/Utils/CommonUtils.h>


namespace DB
Expand Down
12 changes: 6 additions & 6 deletions src/Interpreters/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@

#include <Interpreters/Cache/FileCache.h>

#include <VectorIndex/Interpreters/VectorIndexEventLog.h>
#include <VectorIndex/Interpreters/VIEventLog.h>

#if USE_ROCKSDB
#include <rocksdb/table.h>
Expand Down Expand Up @@ -2109,14 +2109,14 @@ void Context::dropIndexUncompressedCache() const
shared->index_uncompressed_cache->reset();
}

void Context::setPrimaryKeyCacheSize(size_t max_size_in_bytes)
void Context::setPKCacheSize(size_t max_size_in_bytes)
{
auto lock = getLock();
shared->primary_key_cache_size = max_size_in_bytes;
}


size_t Context::getPrimaryKeyCacheSize() const
size_t Context::getPKCacheSize() const
{
auto lock = getLock();
return shared->primary_key_cache_size;
Expand Down Expand Up @@ -3018,7 +3018,7 @@ std::shared_ptr<TransactionsInfoLog> Context::getTransactionsInfoLog() const
return shared->system_logs->transactions_info_log;
}

std::shared_ptr<VectorIndexEventLog> Context::getVectorIndexEventLog(const String & part_database) const
std::shared_ptr<VIEventLog> Context::getVectorIndexEventLog(const String & part_database) const
{
auto lock = getLock();

Expand Down Expand Up @@ -4135,12 +4135,12 @@ ReadSettings Context::getReadSettings() const
return res;
}

std::optional<VectorScanDescription> Context::getVecScanDescription() const
std::optional<VSDescription> Context::getVecScanDescription() const
{
return vector_scan_description;
}

void Context::setVecScanDescription(VectorScanDescription & vec_scan_desc) const
void Context::setVecScanDescription(VSDescription & vec_scan_desc) const
{
vector_scan_description = vec_scan_desc;
}
Expand Down
19 changes: 11 additions & 8 deletions src/Interpreters/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <Storages/ColumnsDescription.h>
#include <Storages/IStorage_fwd.h>

#include <VectorIndex/Storages/VectorScanDescription.h>
#include <VectorIndex/Storages/VSDescription.h>

#include "config.h"

Expand Down Expand Up @@ -100,7 +100,7 @@ class ProcessorsProfileLog;
class FilesystemCacheLog;
class FilesystemReadPrefetchesLog;
class AsynchronousInsertLog;
class VectorIndexEventLog;
class VIEventLog;
class IAsynchronousReader;
struct MergeTreeSettings;
struct InitialAllRangesAnnouncement;
Expand Down Expand Up @@ -406,7 +406,9 @@ class Context: public std::enable_shared_from_this<Context>
/// Temporary data for query execution accounting.
TemporaryDataOnDiskScopePtr temp_data_on_disk;

mutable std::optional<VectorScanDescription> vector_scan_description;
/// TODO: will be enhanced similar as scalars.
/// Used when vector scan func exists in right joined table
mutable std::optional<VSDescription> vector_scan_description;

public:
/// Some counters for current query execution.
Expand Down Expand Up @@ -894,8 +896,8 @@ class Context: public std::enable_shared_from_this<Context>
void dropIndexUncompressedCache() const;

/// Primary key cache size limit.
void setPrimaryKeyCacheSize(size_t max_size_in_bytes);
size_t getPrimaryKeyCacheSize() const;
void setPKCacheSize(size_t max_size_in_bytes);
size_t getPKCacheSize() const;

/// Create a cache of index marks of specified size. This can be done only once.
void setIndexMarkCache(size_t cache_size_in_bytes);
Expand Down Expand Up @@ -981,7 +983,7 @@ class Context: public std::enable_shared_from_this<Context>
std::shared_ptr<FilesystemCacheLog> getFilesystemCacheLog() const;
std::shared_ptr<FilesystemReadPrefetchesLog> getFilesystemReadPrefetchesLog() const;
std::shared_ptr<AsynchronousInsertLog> getAsynchronousInsertLog() const;
std::shared_ptr<VectorIndexEventLog> getVectorIndexEventLog(const String & part_database = {}) const;
std::shared_ptr<VIEventLog> getVectorIndexEventLog(const String & part_database = {}) const;

/// Returns an object used to log operations with parts if it possible.
/// Provide table name to make required checks.
Expand Down Expand Up @@ -1152,8 +1154,9 @@ class Context: public std::enable_shared_from_this<Context>

ParallelReplicasMode getParallelReplicasMode() const;

std::optional<VectorScanDescription> getVecScanDescription() const;
void setVecScanDescription(VectorScanDescription & vec_scan_desc) const;
/// Used for vector scan functions
std::optional<VSDescription> getVecScanDescription() const;
void setVecScanDescription(VSDescription & vec_scan_desc) const;
void resetVecScanDescription() const;

private:
Expand Down
8 changes: 4 additions & 4 deletions src/Interpreters/ExpressionAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@

#include <Common/logger_useful.h>

#include <VectorIndex/Common/VectorIndexCommon.h>
#include <VectorIndex/Common/VICommon.h>
#include <VectorIndex/Interpreters/GetVSVisitor.h>
#include <VectorIndex/Interpreters/parseVSParameters.h>
#include <VectorIndex/Utils/VectorIndexUtils.h>
#include <VectorIndex/Utils/VIUtils.h>

namespace DB
{
Expand Down Expand Up @@ -713,7 +713,7 @@ bool ExpressionAnalyzer::makeVectorScanDescriptions(ActionsDAGPtr & actions)
{
if (node->arguments)
getRootActionsNoMakeSet(node->arguments, actions);
VectorScanDescription vector_scan_desc;
VSDescription vector_scan_desc;
vector_scan_desc.column_name = node->getColumnName();
const ASTs & arguments = node->arguments ? node->arguments->children : ASTs();

Expand All @@ -723,7 +723,7 @@ bool ExpressionAnalyzer::makeVectorScanDescriptions(ActionsDAGPtr & actions)
"wrong argument number in distance function");
}

/// Save short column name in VectorScanDescription, exclude database name and table name if exists.
/// Save short column name in VSDescription, exclude database name and table name if exists.
if (auto * identifier = arguments[0]->as<ASTIdentifier>())
vector_scan_desc.search_column_name = identifier->shortName();
else
Expand Down
6 changes: 3 additions & 3 deletions src/Interpreters/ExpressionAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <Storages/IStorage_fwd.h>
#include <Storages/SelectQueryInfo.h>

#include <VectorIndex/Storages/VectorScanDescription.h>
#include <VectorIndex/Storages/VSDescription.h>

#include <Common/logger_useful.h>

Expand Down Expand Up @@ -78,7 +78,7 @@ struct ExpressionAnalyzerData
AggregateDescriptions aggregate_descriptions;

bool has_vector_scan = false;
VectorScanDescriptions vector_scan_descriptions;
VSDescriptions vector_scan_descriptions;

WindowDescriptions window_descriptions;
NamesAndTypesList window_columns;
Expand Down Expand Up @@ -367,7 +367,7 @@ class SelectQueryExpressionAnalyzer : public ExpressionAnalyzer
bool hasConstAggregationKeys() const { return has_const_aggregation_keys; }
const NamesAndTypesLists & aggregationKeysList() const { return aggregation_keys_list; }
const AggregateDescriptions & aggregates() const { return aggregate_descriptions; }
VectorScanDescriptions & vectorScanDescs() { return vector_scan_descriptions; }
VSDescriptions & vectorScanDescs() { return vector_scan_descriptions; }

std::unique_ptr<QueryPlan> getJoinedPlan();

Expand Down
4 changes: 2 additions & 2 deletions src/Interpreters/InterpreterCreateIndexQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <Storages/AlterCommands.h>
#include <Storages/StorageDistributed.h>

#include <VectorIndex/Parsers/ASTVectorIndexDeclaration.h>
#include <VectorIndex/Parsers/ASTVIDeclaration.h>

namespace DB
{
Expand Down Expand Up @@ -82,7 +82,7 @@ BlockIO InterpreterCreateIndexQuery::execute()
command.type = AlterCommand::ADD_VECTOR_INDEX;
command.vec_index_name = create_index.index_name->as<ASTIdentifier &>().name();

auto & ast_vec_index_decl = command.vec_index_decl->as<ASTVectorIndexDeclaration &>();
auto & ast_vec_index_decl = command.vec_index_decl->as<ASTVIDeclaration &>();
command.column_name = ast_vec_index_decl.column;
}
else
Expand Down
Loading

0 comments on commit e31254f

Please sign in to comment.