Skip to content

Commit 3cec455

Browse files
authored
Update main.rs
1 parent ff984e0 commit 3cec455

File tree

1 file changed

+4
-3
lines changed
  • examples/secondary-index/src

1 file changed

+4
-3
lines changed

examples/secondary-index/src/main.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn create_item(
1414
batch.insert(table, &id, format!("{name} [{year}]"));
1515

1616
let ts_bytes = year.to_be_bytes();
17-
let key = format_bytes!(b"{}#{}", ts_bytes, id.as_bytes());
17+
let key = format_bytes!(b"{}\0{}", ts_bytes, id.as_bytes());
1818

1919
batch.insert(index, &key, "");
2020

@@ -30,6 +30,7 @@ fn main() -> fjall::Result<()> {
3030

3131
let mut batch = keyspace.batch();
3232
create_item(&mut batch, &items, &sec, "Remain in Light", 1_980)?;
33+
create_item(&mut batch, &items, &sec, "Seventeen Seconds", 1_980)?;
3334
create_item(&mut batch, &items, &sec, "Power, Corruption & Lies", 1_983)?;
3435
create_item(&mut batch, &items, &sec, "Hounds of Love", 1_985)?;
3536
create_item(&mut batch, &items, &sec, "Black Celebration", 1_986)?;
@@ -47,7 +48,7 @@ fn main() -> fjall::Result<()> {
4748

4849
// Get items from 1990 to 2000 (exclusive)
4950
let lo = 1_990_u64;
50-
let hi = 1_999_u64;
51+
let hi = 1_999_u64;#
5152

5253
println!("Searching for [{lo} - {hi}]");
5354

@@ -57,7 +58,7 @@ fn main() -> fjall::Result<()> {
5758
let (k, _) = kv?;
5859

5960
// Get ID
60-
let primary_key = k.split(|&c| c == b'#').nth(1).unwrap();
61+
let primary_key = k.split(|&c| c == b'\0').nth(1).unwrap();
6162

6263
// Get from primary index
6364
let item = items.get(primary_key)?.unwrap();

0 commit comments

Comments
 (0)