mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
Cosmetics: whitespaces
This commit is contained in:
parent
0f1765a273
commit
fb26a9e6d4
@ -60,8 +60,8 @@ ApproximateNearestNeighborCondition::ApproximateNearestNeighborCondition(const S
|
||||
bool ApproximateNearestNeighborCondition::alwaysUnknownOrTrue(String metric) const
|
||||
{
|
||||
if (!index_is_useful)
|
||||
return true; // Query isn't supported
|
||||
// If query is supported, check metrics for match
|
||||
return true; /// query isn't supported
|
||||
/// If query is supported, check if distance function of index is the same as distance function in query
|
||||
return !(stringToMetric(metric) == query_information->metric);
|
||||
}
|
||||
|
||||
@ -138,11 +138,11 @@ bool ApproximateNearestNeighborCondition::checkQueryStructure(const SelectQueryI
|
||||
|
||||
void ApproximateNearestNeighborCondition::traverseAST(const ASTPtr & node, RPN & rpn)
|
||||
{
|
||||
// If the node is ASTFunction, it may have children nodes
|
||||
/// If the node is ASTFunction, it may have children nodes
|
||||
if (const auto * func = node->as<ASTFunction>())
|
||||
{
|
||||
const ASTs & children = func->arguments->children;
|
||||
// Traverse children nodes
|
||||
/// Traverse children nodes
|
||||
for (const auto& child : children)
|
||||
traverseAST(child, rpn);
|
||||
}
|
||||
@ -253,7 +253,7 @@ void ApproximateNearestNeighborCondition::traverseOrderByAST(const ASTPtr & node
|
||||
/// Returns true and stores ANNExpr if the query has valid ORDERBY clause
|
||||
bool ApproximateNearestNeighborCondition::matchRPNOrderBy(RPN & rpn, ApproximateNearestNeighborInformation & ann_info)
|
||||
{
|
||||
// ORDER BY clause must have at least 3 expressions
|
||||
/// ORDER BY clause must have at least 3 expressions
|
||||
if (rpn.size() < 3)
|
||||
return false;
|
||||
|
||||
|
@ -23,18 +23,17 @@ namespace DB
|
||||
struct ApproximateNearestNeighborInformation
|
||||
{
|
||||
using Embedding = std::vector<float>;
|
||||
Embedding reference_vector;
|
||||
|
||||
enum class Metric : uint8_t
|
||||
{
|
||||
Unknown,
|
||||
L2
|
||||
};
|
||||
Metric metric;
|
||||
|
||||
Embedding reference_vector;
|
||||
Metric metric;
|
||||
String column_name;
|
||||
UInt64 limit;
|
||||
|
||||
float distance = -1.0;
|
||||
};
|
||||
|
||||
@ -51,7 +50,7 @@ struct ApproximateNearestNeighborInformation
|
||||
///
|
||||
/// Queries without LIMIT count are not supported
|
||||
/// If the query is both of type 1. and 2., than we can't use the index and alwaysUnknownOrTrue returns true.
|
||||
/// reference_vector should have float coordinates, e.g. (0.2, 0.1, .., 0.5)
|
||||
/// reference_vector should have float coordinates, e.g. [0.2, 0.1, .., 0.5]
|
||||
///
|
||||
/// If the query matches one of these two types, then this class extracts the main information needed for ANN indexes from the query.
|
||||
///
|
||||
@ -73,19 +72,11 @@ public:
|
||||
/// Returns false if query can be speeded up by an ANN index, true otherwise.
|
||||
bool alwaysUnknownOrTrue(String metric) const;
|
||||
|
||||
/// Distance should be calculated regarding to referenceVector
|
||||
std::vector<float> getReferenceVector() const;
|
||||
|
||||
/// Reference vector's dimension count
|
||||
size_t getDimensions() const;
|
||||
|
||||
String getColumnName() const;
|
||||
|
||||
ApproximateNearestNeighborInformation::Metric getMetricType() const;
|
||||
|
||||
UInt64 getIndexGranularity() const { return index_granularity; }
|
||||
|
||||
/// Length's value from LIMIT clause
|
||||
UInt64 getLimit() const;
|
||||
|
||||
private:
|
||||
@ -126,18 +117,14 @@ private:
|
||||
|
||||
explicit RPNElement(Function function_ = FUNCTION_UNKNOWN)
|
||||
: function(function_)
|
||||
, func_name("Unknown")
|
||||
, float_literal(std::nullopt)
|
||||
, identifier(std::nullopt)
|
||||
{}
|
||||
|
||||
Function function;
|
||||
String func_name;
|
||||
String func_name = "Unknown";
|
||||
|
||||
std::optional<float> float_literal;
|
||||
std::optional<String> identifier;
|
||||
std::optional<int64_t> int_literal;
|
||||
|
||||
std::optional<Array> array_literal;
|
||||
|
||||
UInt32 dim = 0;
|
||||
@ -165,7 +152,7 @@ private:
|
||||
/// Returns true and stores Length if we have valid LIMIT clause in query
|
||||
static bool matchRPNLimit(RPNElement & rpn, UInt64 & limit);
|
||||
|
||||
/* Matches dist function, reference vector, column name */
|
||||
/// Matches dist function, reference vector, column name
|
||||
static bool matchMainParts(RPN::iterator & iter, const RPN::iterator & end, ApproximateNearestNeighborInformation & ann_info);
|
||||
|
||||
/// Gets float or int from AST node
|
||||
|
@ -232,11 +232,11 @@ MergeTreeIndexPtr hypothesisIndexCreator(const IndexDescription & index);
|
||||
void hypothesisIndexValidator(const IndexDescription & index, bool attach);
|
||||
|
||||
#if USE_USEARCH
|
||||
MergeTreeIndexPtr usearchIndexCreator(const IndexDescription& index);
|
||||
void usearchIndexValidator(const IndexDescription& index, bool attach);
|
||||
MergeTreeIndexPtr usearchIndexCreator(const IndexDescription & index);
|
||||
void usearchIndexValidator(const IndexDescription & index, bool attach);
|
||||
#endif
|
||||
|
||||
MergeTreeIndexPtr fullTextIndexCreator(const IndexDescription& index);
|
||||
void fullTextIndexValidator(const IndexDescription& index, bool attach);
|
||||
MergeTreeIndexPtr fullTextIndexCreator(const IndexDescription & index);
|
||||
void fullTextIndexValidator(const IndexDescription & index, bool attach);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user