Skip to content

Commit 2f3c28c

Browse files
committed
Some removal of some entries in error and extend the run_reads test.
1 parent a42dd07 commit 2f3c28c

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

linera-views/src/backends/dynamo_db.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ const VISIBLE_MAX_VALUE_SIZE: usize = RAW_MAX_VALUE_SIZE
130130
- 1
131131
- 1;
132132

133-
/// Fundamental constant in DynamoDB: The maximum size of a key is 1024 bytes
133+
/// Fundamental constant in DynamoDB: The maximum size of a key is 1024 bytes.
134+
/// We decrease by 1 because we append a [1] as prefix.
134135
/// See https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html
135-
const MAX_KEY_SIZE: usize = 1024;
136+
const MAX_KEY_SIZE: usize = 1023;
136137

137138
/// Fundamental constants in DynamoDB: The maximum size of a [`TransactWriteItem`] is 4 MB.
138139
/// See https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactWriteItems.html
@@ -203,7 +204,6 @@ fn build_key_value(
203204

204205
/// Checks that a key is of the correct size
205206
fn check_key_size(key: &[u8]) -> Result<(), DynamoDbStoreInternalError> {
206-
ensure!(!key.is_empty(), DynamoDbStoreInternalError::ZeroLengthKey);
207207
ensure!(
208208
key.len() <= MAX_KEY_SIZE,
209209
DynamoDbStoreInternalError::KeyTooLong
@@ -973,10 +973,6 @@ pub enum DynamoDbStoreInternalError {
973973
#[error("The transact must have length at most MAX_TRANSACT_WRITE_ITEM_SIZE")]
974974
TransactUpperLimitSize,
975975

976-
/// Keys have to be of non-zero length.
977-
#[error("The key must be of strictly positive length")]
978-
ZeroLengthKey,
979-
980976
/// The key must have at most 1024 bytes
981977
#[error("The key must have at most 1024 bytes")]
982978
KeyTooLong,
@@ -985,10 +981,6 @@ pub enum DynamoDbStoreInternalError {
985981
#[error("The key prefix must have at most 1024 bytes")]
986982
KeyPrefixTooLong,
987983

988-
/// Key prefixes have to be of non-zero length.
989-
#[error("The key_prefix must be of strictly positive length")]
990-
ZeroLengthKeyPrefix,
991-
992984
/// The journal is not coherent
993985
#[error(transparent)]
994986
JournalConsistencyError(#[from] JournalConsistencyError),

linera-views/src/test_utils/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub async fn run_reads<S: KeyValueStore>(store: S, key_values: Vec<(Vec<u8>, Vec
176176
store.write_batch(batch).await.unwrap();
177177
for key_prefix in keys
178178
.iter()
179-
.flat_map(|key| (0..key.len()).map(|u| &key[..=u]))
179+
.flat_map(|key| (0..key.len()+1).map(|u| &key[..u]))
180180
{
181181
// Getting the find_keys_by_prefix / find_key_values_by_prefix
182182
let len_prefix = key_prefix.len();

0 commit comments

Comments
 (0)