This is an automated email from the ASF dual-hosted git repository.

twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 70fac378 Add search metadata encoding for numeric fields (#2086)
70fac378 is described below

commit 70fac378e9f966f8209c5195cdd2aaa214a87a0e
Author: Twice <[email protected]>
AuthorDate: Fri Feb 2 00:16:06 2024 +0900

    Add search metadata encoding for numeric fields (#2086)
---
 .../search_encoding.h}                             | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/types/redis_search_encoding.h b/src/search/search_encoding.h
similarity index 81%
rename from src/types/redis_search_encoding.h
rename to src/search/search_encoding.h
index 303a8414..a0517902 100644
--- a/src/types/redis_search_encoding.h
+++ b/src/search/search_encoding.h
@@ -33,9 +33,11 @@ enum class SearchSubkeyType : uint8_t {
 
   // field metadata for different types
   TAG_FIELD_META = 64 + 1,
+  NUMERIC_FIELD_META = 64 + 2,
 
   // field indexing for different types
   TAG_FIELD = 128 + 1,
+  NUMERIC_FIELD = 128 + 2,
 };
 
 inline std::string ConstructSearchPrefixesSubkey() { return 
{(char)SearchSubkeyType::PREFIXES}; }
@@ -70,8 +72,8 @@ inline std::string 
ConstructTagFieldMetadataSubkey(std::string_view field_name)
 }
 
 struct SearchTagFieldMetadata {
-  char separator;
-  bool case_sensitive;
+  char separator = ',';
+  bool case_sensitive = false;
 
   void Encode(std::string *dst) const {
     PutFixed8(dst, separator);
@@ -89,6 +91,12 @@ struct SearchTagFieldMetadata {
   }
 };
 
+inline std::string ConstructNumericFieldMetadataSubkey(std::string_view 
field_name) {
+  std::string res = {(char)SearchSubkeyType::NUMERIC_FIELD_META};
+  res.append(field_name);
+  return res;
+}
+
 inline std::string ConstructTagFieldSubkey(std::string_view field_name, 
std::string_view tag, std::string_view key) {
   std::string res = {(char)SearchSubkeyType::TAG_FIELD};
   PutFixed32(&res, field_name.size());
@@ -100,4 +108,14 @@ inline std::string 
ConstructTagFieldSubkey(std::string_view field_name, std::str
   return res;
 }
 
+inline std::string ConstructNumericFieldSubkey(std::string_view field_name, 
double number, std::string_view key) {
+  std::string res = {(char)SearchSubkeyType::NUMERIC_FIELD};
+  PutFixed32(&res, field_name.size());
+  res.append(field_name);
+  PutDouble(&res, number);
+  PutFixed32(&res, key.size());
+  res.append(key);
+  return res;
+}
+
 }  // namespace redis

Reply via email to