Comments (2)
The base64url(url safe and no padding) is the stateless solution for these, with some trade off for readability(when debug maybe).
I'll try this amd close the issue, thanks for immediately reply.
from fjall.
There are two issues with this:
(1) The name cannot contain :
. That's just down to how a partition is referenced in sealed journals, where it looks like:
partition1:max_seqno
partition2:max_seqno
...
Having a :
would break it. That's also why a PartitionKey
is a Arc<str>
and not a Arc<[u8]>
. I don't really feel like supporting space feels right either.
(2) The partition name needs to be filename-safe, because it is stored in the file system as a directory, so on Linux that would disqualify /
and on Windows it would disqualify a whole bunch of characters like ?
, <
, >
, ...
There are two solutions though you could consider:
Manifest table
Keep track of partitions in a manifest table and map your typenames to internal IDs. Keys and values can be any arbitrary byte sequence. Then you can lookup the internal partition ID using your typename, like:
let manifest = keyspace.open_partition("manifest", Default::default())?;
// Register partition for "Dense<K, V, ()>"
manifest.insert("Dense<K, V, ()>", nanoid!())?;
// Get partition
let partition_name = manifest.get("Dense<K, V, ()>")?.expect("should exist");
let partition = keyspace.open_partition(partition_name, Default::default())?;
// Delete partition
manifest.remove("Dense<K, V, ()>")?;
keyspace.delete_partition(partition)?;
// ...
Considering you probably only have a handful of partitions, the manifest is very small, so it easily fits into memory for fast lookups.
For nicer usage, you could wrap it in a newtype, like
use fjall::{Keyspace, PartitionHandle};
#[derive(Clone)]
struct Manifest(PartitionHandle);
impl Manifest {
pub fn new(keyspace: &Keyspace) -> fjall::Result<Self> {
let partition = keyspace.open_partition("manifest", Default::default())?;
Ok(Self(partition))
}
// ... implement get and set for typenames
}
This is something I'm doing in Smoltable
: https://github.com/marvin-j97/smoltable/blob/main/server/src/manifest.rs
Encoding
Encode your typename into a partition name that is valid. One example I could think of would be:
// Pseudo code
let typename = "Dense<K, V, D>";
let partition_name = base64url(typename.as_bytes()); // or maybe MD5
let partition = keyspace.open_partition(partition_name, Default::default())?;
// ...
from fjall.
Related Issues (15)
- Bloom Filters HOT 4
- Data partitioning/Column families HOT 1
- Periodic (maintenance) compaction
- `tree.get` function returned the unexpected value HOT 1
- Optional TTL for FIFO strategy
- Improve & validate write buffer size handling
- Move to org and split into multiple repos
- Transactions HOT 2
- Make Keyspace loading PWD independent
- delete_range/delete_prefix
- WiscKey-like key-value separation
- Optimistic concurrency control through sequence number HOT 1
- Dependency Dashboard
- Find MSRV
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fjall.