Files
scylladb/cql3/functions/token_fct.hh
Avi Kivity 0ae22a09d4 LICENSE: Update to version 1.1
Updated terms of non-commercial use (must be a never-customer).
2026-04-12 19:46:33 +03:00

45 lines
1.1 KiB
C++

/*
* Modified by ScyllaDB
*
* Copyright (C) 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: (LicenseRef-ScyllaDB-Source-Available-1.1 and Apache-2.0)
*/
#pragma once
#include "native_scalar_function.hh"
#include "dht/i_partitioner.hh"
#include "unimplemented.hh"
namespace cql3 {
namespace functions {
class token_fct: public native_scalar_function {
private:
schema_ptr _schema;
public:
token_fct(schema_ptr s)
: native_scalar_function("token",
dht::token::get_token_validator(),
s->partition_key_type()->types())
, _schema(s) {
}
bytes_opt execute(std::span<const bytes_opt> parameters) override {
if (std::any_of(parameters.begin(), parameters.end(), [](const auto& param){ return !param; })) {
return std::nullopt;
}
auto key = partition_key::from_optional_exploded(*_schema, parameters);
auto tok = dht::get_token(*_schema, key);
warn(unimplemented::cause::VALIDATION);
return tok.data();
}
};
}
}