csun5285 commented on code in PR #62960:
URL: https://github.com/apache/doris/pull/62960#discussion_r3168763946


##########
be/src/storage/index/inverted/inverted_index_query_param.h:
##########
@@ -0,0 +1,194 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <memory>
+#include <string>
+#include <type_traits>
+
+#include "common/factory_creator.h"
+#include "common/status.h"
+#include "core/data_type/primitive_type.h"
+#include "core/string_ref.h"
+#include "core/type_limit.h"
+#include "storage/index/inverted/inverted_index_reader.h"
+#include "storage/key_coder.h"
+
+namespace doris {
+class Field;
+
+namespace segment_v2 {
+
+// Typed query value passed from FE to InvertedIndexReader.
+// Two disjoint shapes under a common root for unified ownership:
+//   StringQueryParam  — get_string()                            (FullText / 
String readers)
+//   NumericQueryParam — encode_ascending() + encode_min/max_*   
(BkdIndexReader)
+// TypedInvertedIndexQueryParam<PT> picks its base via PT (string vs numeric).
+
+class InvertedIndexQueryParam {
+public:
+    virtual ~InvertedIndexQueryParam() = default;
+};
+
+class StringQueryParam : public InvertedIndexQueryParam {
+public:
+    virtual void get_string(std::string* out) const = 0;
+};
+
+class NumericQueryParam : public InvertedIndexQueryParam {
+public:
+    // Encode _value through KeyCoder ascending. encode_min/max encode the 
type's
+    // sentinel for the open side of BKD half-bounded ranges.
+    virtual void encode_ascending(const KeyCoder* coder, std::string* out) 
const = 0;
+    virtual void encode_min_ascending(const KeyCoder* coder, std::string* out) 
const = 0;
+    virtual void encode_max_ascending(const KeyCoder* coder, std::string* out) 
const = 0;
+};
+
+template <PrimitiveType PT>
+class TypedInvertedIndexQueryParam : public NumericQueryParam {
+    ENABLE_FACTORY_CREATOR(TypedInvertedIndexQueryParam);
+
+public:
+    // Storage type aligned with KeyCoder's view. Override per-PT when
+    // PrimitiveTypeTraits disagrees with KeyCoder on signedness — otherwise
+    // type_limit<storage_val>::min/max produces broken sentinels.
+    //   TYPE_DATETIME: PrimitiveTypeTraits=uint64_t but KeyCoder=int64_t. With
+    //   uint64_t, type_limit::max() = UINT64_MAX is read as -1 and encodes
+    //   smaller than any real datetime — broken +inf.
+    using storage_val = std::conditional_t<PT == TYPE_DATETIME, int64_t,

Review Comment:
   这个地方就是KeyCoder=int64_t



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to