forked from tikv/tikv
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Calvin Neo <[email protected]>
- Loading branch information
Showing
6 changed files
with
77 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
proxy_components/engine_store_ffi/src/core/serverless_extra.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2024 TiKV Project Authors. Licensed under Apache-2.0. | ||
|
||
use std::convert::TryInto; | ||
|
||
use crate::{ | ||
core::common::*, | ||
ffi::interfaces_ffi::{FastAddPeerRes, FastAddPeerStatus}, | ||
}; | ||
|
||
pub struct ServerlessExtra { | ||
shard_ver: u64, | ||
inner_key: Vec<u8>, | ||
enc_key: Vec<u8>, | ||
txn_file_ref: Vec<u8>, | ||
} | ||
|
||
impl ServerlessExtra { | ||
// TODO TXN_FILE_REF | ||
pub fn new(res: &FastAddPeerRes) -> Self { | ||
Self { | ||
shard_ver: res.shard_ver, | ||
inner_key: res.inner_key.view.to_slice().to_vec(), | ||
enc_key: res.enc_key.view.to_slice().to_vec(), | ||
txn_file_ref: res.txn_file_ref.view.to_slice().to_vec(), | ||
} | ||
} | ||
|
||
pub fn mutate_snap(&self, shard_id: u64, changeset: &mut kvenginepb::ChangeSet) { | ||
let snap = changeset.mut_snapshot(); | ||
{ | ||
let props = kvengine::Properties::default(); | ||
props.set(kvengine::ENCRYPTION_KEY, self.get_enc_key()); | ||
props.set(kvengine::TXN_FILE_REF, self.get_txn_file_ref()); | ||
snap.set_properties(props.to_pb(shard_id)); | ||
snap.set_inner_key_off(self.get_inner_key_off()); | ||
} | ||
changeset.set_shard_ver(self.get_shard_ver()); | ||
} | ||
|
||
fn get_shard_ver(&self) -> u64 { | ||
self.shard_ver | ||
} | ||
|
||
fn get_inner_key_off(&self) -> u32 { | ||
if self.inner_key.len() < 4 { | ||
info!("fast path: get error inner key {:?}", self.inner_key); | ||
return 0; | ||
} | ||
u32::from_be_bytes(self.inner_key[0..4].try_into().unwrap()) | ||
} | ||
|
||
fn get_enc_key(&self) -> &[u8] { | ||
&self.enc_key | ||
} | ||
|
||
fn get_txn_file_ref(&self) -> &[u8] { | ||
// load_peer_txn_file_locks | ||
&self.txn_file_ref | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#pragma once | ||
#include <cstdint> | ||
namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 9679186549381427051ull; } | ||
namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 2149052863435660119ull; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters