Skip to content

Commit 0e99b6d

Browse files
committed
fix: more formats and comments
1 parent 60e640d commit 0e99b6d

9 files changed

Lines changed: 16 additions & 27 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ cosmian_crypto_core = { version = "10.2", default-features = false, features = [
3030
criterion = { version = "0.6" }
3131
smol-macros = { version = "0.1" }
3232
tokio = { version = "1.46" }
33-
futures = "0.3.31" # Todo: this is a temporary approach
33+
futures = "0.3.31"

crate/findex/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test-utils = ["agnostic-lite", "criterion"]
2121
[dependencies]
2222
aes = "0.8"
2323
cosmian_crypto_core.workspace = true
24-
cosmian_sse_memories = { path = "../memories", version = "8.0.2" }
24+
cosmian_sse_memories = { path = "../memories", version = "8.0.2" } # Should be above 8.0.2 to have batching features.
2525
xts-mode = "0.5"
2626
futures.workspace = true
2727
# Optional dependencies for testing and benchmarking.

crate/findex/src/adt.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ pub trait VectorADT: Send {
5151
fn read(&self) -> impl Send + Future<Output = Result<Vec<Self::Value>, Self::Error>>;
5252
}
5353

54-
/// This trait extends the functionality of the standard `IndexADT` by
55-
/// providing methods that operate on multiple keywords or entries
56-
/// simultaneously to cut network's overhead and improve performance.
54+
/// This trait extends the functionality of the standard `IndexADT` by providing methods that operate
55+
/// on multiple keywords or entries simultaneously.
5756
#[cfg(feature = "batch")]
5857
pub trait IndexBatcher<Keyword, Value> {
5958
type Error: std::error::Error;

crate/findex/src/batcher_findex.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<
3939
}
4040
}
4141

42-
// Insert or delete are both an unbounded number of calls to `guarded_write` on
42+
// Both insert and delete operations make an unbounded number of calls to `guarded_write` on
4343
// the memory layer.
4444
async fn batch_insert_or_delete<Keyword>(
4545
&self,
@@ -54,10 +54,8 @@ impl<
5454

5555
for (guard_keyword, bindings) in entries {
5656
let memory = memory.clone();
57-
// Create a temporary Findex instance using the shared batching layer
57+
// Create a temporary Findex instance using the shared batching layer.
5858
let findex = Findex::<WORD_LENGTH, Value, EncodingError, _>::new(
59-
// This (cheap) Arc clone is necessary because `decrement_capacity` is called
60-
// below and needs to be able to access the Arc.
6159
memory.clone(),
6260
*self.encode,
6361
*self.decode,
@@ -121,7 +119,6 @@ impl<
121119

122120
for keyword in keywords {
123121
let memory = memory.clone();
124-
// Create a temporary Findex instance using the shared batching layer.
125122
let findex = Findex::<WORD_LENGTH, Value, EncodingError, _>::new(
126123
memory,
127124
*self.encode,
@@ -132,7 +129,6 @@ impl<
132129
futures.push(future);
133130
}
134131

135-
// Execute all futures concurrently and collect results.
136132
futures::future::try_join_all(futures)
137133
.await
138134
.map_err(|e| BatchFindexError::Findex(e))

crate/findex/src/benches.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ use cosmian_crypto_core::{Secret, reexport::rand_core::CryptoRngCore};
1010
use cosmian_sse_memories::{ADDRESS_LENGTH, Address, MemoryADT};
1111
use criterion::{BenchmarkId, Criterion};
1212

13-
use crate::{
14-
Findex, IndexADT, WORD_LENGTH, dummy_decode, dummy_encode,
15-
encryption_layer::MemoryEncryptionLayer,
16-
};
13+
use crate::{Findex, IndexADT, MemoryEncryptionLayer, WORD_LENGTH, dummy_decode, dummy_encode};
1714

1815
const MAX_VAL: usize = 1_000;
1916

crate/findex/src/error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// TODO
21
use std::fmt::{Debug, Display};
32

43
#[cfg(feature = "batch")]

crate/findex/src/findex.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ mod tests {
144144
use cosmian_sse_memories::{ADDRESS_LENGTH, Address, InMemory};
145145
use smol_macros::Executor;
146146

147-
use crate::{
148-
Findex, IndexADT, dummy_decode, dummy_encode, encryption_layer::MemoryEncryptionLayer,
149-
};
147+
use crate::{Findex, IndexADT, MemoryEncryptionLayer, dummy_decode, dummy_encode};
150148

151149
// Define a byte type, and use `Value` as an alias for 8-bytes values of
152150
// that type.

crate/findex/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ mod benches;
1717
pub use adt::IndexADT;
1818
#[cfg(feature = "test-utils")]
1919
pub use benches::*;
20-
21-
#[cfg(feature = "batch")]
22-
mod batcher_findex;
23-
#[cfg(feature = "batch")]
24-
pub use adt::IndexBatcher;
25-
#[cfg(feature = "batch")]
26-
pub use batcher_findex::FindexBatcher;
2720
pub use encoding::{
2821
Decoder, Encoder,
2922
generic_encoding::{generic_decode, generic_encode},
@@ -37,6 +30,13 @@ pub use encryption_layer::{KEY_LENGTH, MemoryEncryptionLayer};
3730
pub use error::Error;
3831
pub use findex::{Findex, Op};
3932

33+
#[cfg(feature = "batch")]
34+
mod batcher_findex;
35+
#[cfg(feature = "batch")]
36+
pub use adt::IndexBatcher;
37+
#[cfg(feature = "batch")]
38+
pub use batcher_findex::FindexBatcher;
39+
4040
#[cfg(feature = "test-utils")]
4141
pub mod reexport {
4242
// Re-exporting the most commonly used runtime interfaces for convenience.

crate/findex/src/ovec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ mod tests {
218218
use cosmian_sse_memories::{ADDRESS_LENGTH, Address, InMemory};
219219

220220
use crate::{
221+
MemoryEncryptionLayer,
221222
adt::tests::{test_vector_concurrent, test_vector_sequential},
222-
encryption_layer::MemoryEncryptionLayer,
223223
ovec::IVec,
224224
};
225225

0 commit comments

Comments
 (0)