PragmaTwice commented on code in PR #3072:
URL: https://github.com/apache/kvrocks/pull/3072#discussion_r2224521098


##########
src/types/redis_timeseries.cc:
##########
@@ -0,0 +1,134 @@
+/*
+ * 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.
+ *
+ */
+
+#include "redis_timeseries.h"
+
+void TSDownStreamMeta::Encode(std::string *dst) const {
+  PutFixed8(dst, static_cast<uint8_t>(aggregator));
+  PutFixed64(dst, bucket_duration);
+  PutFixed64(dst, alignment);
+  PutFixed64(dst, latest_bucket_idx);
+  PutFixed8(dst, static_cast<uint8_t>(u64_auxs.size()));
+  for (const auto &aux : u64_auxs) {
+    PutFixed64(dst, aux);
+  }
+  for (const auto &aux : f64_auxs) {
+    PutDouble(dst, aux);
+  }
+}
+
+rocksdb::Status TSDownStreamMeta::Decode(Slice *input) {
+  if (input->size() < sizeof(uint8_t) * 2 + sizeof(uint64_t) * 3) {
+    return rocksdb::Status::InvalidArgument("TSDownStreamMeta size is too 
short");
+  }
+
+  GetFixed8(input, reinterpret_cast<uint8_t *>(&aggregator));
+  GetFixed64(input, &bucket_duration);
+  GetFixed64(input, &alignment);
+  GetFixed64(input, &latest_bucket_idx);
+  uint8_t u64_auxs_size = 0;
+  GetFixed8(input, &u64_auxs_size);
+
+  if (input->size() < sizeof(uint64_t) * u64_auxs_size || input->size() % 
sizeof(uint64_t)) {
+    return rocksdb::Status::InvalidArgument("Invalid auxinfo size");
+  }
+
+  for (uint8_t i = 0; i < u64_auxs_size; i++) {
+    uint64_t aux = 0;
+    GetFixed64(input, &aux);
+    u64_auxs.push_back(std::move(aux));
+  }
+  while (input->size() > 0) {
+    double aux = NAN;
+    GetDouble(input, &aux);
+    f64_auxs.push_back(std::move(aux));
+  }
+
+  return rocksdb::Status::OK();
+}
+
+namespace redis {
+TSRevLabelKey::TSRevLabelKey(Slice ns_key, Slice label_key, Slice label_value, 
bool slot_id_encoded)
+    : label_key(label_key), label_value(label_value), 
slot_id_encoded_(slot_id_encoded) {
+  uint8_t namespace_size = 0;
+  GetFixed8(&ns_key, &namespace_size);
+  ns = Slice(ns_key.data(), namespace_size);
+  ns_key.remove_prefix(namespace_size);
+
+  if (slot_id_encoded_) {
+    GetFixed16(&ns_key, &slot_id);
+  }
+  user_key = ns_key;
+}
+
+std::string TSRevLabelKey::Encode() const {

Review Comment:
   Maybe the key type can be put after `ns`.
   
   > Can we temporarily put it in redis_timeseries.h?
   
   Yeah we can put it here.
   



-- 
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: issues-unsubscr...@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to