Skip to content

Commit c142976

Browse files
committed
feat(dataverse): dissociate triple store msg limits struct
1 parent 0498747 commit c142976

File tree

3 files changed

+93
-33
lines changed

3 files changed

+93
-33
lines changed

contracts/okp4-dataverse/src/contract.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub fn instantiate(
5656
code_id: msg.triplestore_config.code_id.u64(),
5757
label: format!("{}_triplestore", msg.name),
5858
msg: to_binary(&okp4_cognitarium::msg::InstantiateMsg {
59-
limits: msg.triplestore_config.limits,
59+
limits: msg.triplestore_config.limits.into(),
6060
})?,
6161
funds: vec![],
6262
salt,
@@ -85,13 +85,12 @@ pub mod query {}
8585
#[cfg(test)]
8686
mod tests {
8787
use super::*;
88-
use crate::msg::TripleStoreConfig;
88+
use crate::msg::{TripleStoreConfig, TripleStoreLimitsInput};
8989
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
9090
use cosmwasm_std::{
9191
Attribute, ContractResult, HexBinary, SubMsg, SystemError, SystemResult, Uint128, Uint64,
9292
WasmQuery,
9393
};
94-
use okp4_cognitarium::msg::StoreLimitsInputBuilder;
9594

9695
#[test]
9796
fn proper_instantiate() {
@@ -111,10 +110,10 @@ mod tests {
111110
_ => SystemResult::Err(SystemError::Unknown {}),
112111
});
113112

114-
let store_limits = StoreLimitsInputBuilder::default()
115-
.max_byte_size(Uint128::from(50000u128))
116-
.build()
117-
.unwrap();
113+
let store_limits = TripleStoreLimitsInput {
114+
max_byte_size: Some(Uint128::from(50000u128)),
115+
..Default::default()
116+
};
118117

119118
let msg = InstantiateMsg {
120119
name: "my-dataverse".to_string(),
@@ -137,7 +136,7 @@ mod tests {
137136
code_id: 17,
138137
label: "my-dataverse_triplestore".to_string(),
139138
msg: to_binary(&okp4_cognitarium::msg::InstantiateMsg {
140-
limits: store_limits,
139+
limits: store_limits.into(),
141140
})
142141
.unwrap(),
143142
funds: vec![],

contracts/okp4-dataverse/src/msg.rs

+64-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use cosmwasm_schema::{cw_serde, QueryResponses};
2-
use cosmwasm_std::{Binary, Uint64};
2+
use cosmwasm_std::{Binary, Uint128, Uint64};
33

44
/// `InstantiateMsg` is used to initialize a new instance of the dataverse.
55
#[cw_serde]
@@ -132,8 +132,69 @@ pub struct TripleStoreConfig {
132132
pub code_id: Uint64,
133133

134134
/// Limitations regarding triple store usage.
135-
#[serde(default = "okp4_cognitarium::msg::StoreLimitsInput::default")]
136-
pub limits: okp4_cognitarium::msg::StoreLimitsInput,
135+
pub limits: TripleStoreLimitsInput,
136+
}
137+
138+
/// # TripleStoreLimitsInput
139+
/// Contains requested limitations regarding store usages.
140+
#[cw_serde]
141+
#[derive(Default)]
142+
pub struct TripleStoreLimitsInput {
143+
/// The maximum number of triples the store can contain.
144+
/// Default to [Uint128::MAX] if not set, which can be considered as no limit.
145+
pub max_triple_count: Option<Uint128>,
146+
/// The maximum number of bytes the store can contain.
147+
/// The size of a triple is counted as the sum of the size of its subject, predicate and object,
148+
/// including the size of data types and language tags if any.
149+
/// Default to [Uint128::MAX] if not set, which can be considered as no limit.
150+
pub max_byte_size: Option<Uint128>,
151+
/// The maximum number of bytes the store can contain for a single triple.
152+
/// The size of a triple is counted as the sum of the size of its subject, predicate and object,
153+
/// including the size of data types and language tags if any. The limit is used to prevent
154+
/// storing very large triples, especially literals.
155+
/// Default to [Uint128::MAX] if not set, which can be considered as no limit.
156+
pub max_triple_byte_size: Option<Uint128>,
157+
/// The maximum limit of a query, i.e. the maximum number of triples returned by a select query.
158+
/// Default to 30 if not set.
159+
pub max_query_limit: Option<u32>,
160+
/// The maximum number of variables a query can select.
161+
/// Default to 30 if not set.
162+
pub max_query_variable_count: Option<u32>,
163+
/// The maximum number of bytes an insert data query can contain.
164+
/// Default to [Uint128::MAX] if not set, which can be considered as no limit.
165+
pub max_insert_data_byte_size: Option<Uint128>,
166+
/// The maximum number of triples an insert data query can contain (after parsing).
167+
/// Default to [Uint128::MAX] if not set, which can be considered as no limit.
168+
pub max_insert_data_triple_count: Option<Uint128>,
169+
}
170+
171+
impl From<TripleStoreLimitsInput> for okp4_cognitarium::msg::StoreLimitsInput {
172+
fn from(value: TripleStoreLimitsInput) -> Self {
173+
let mut limits = okp4_cognitarium::msg::StoreLimitsInput::default();
174+
if let Some(max_triple_count) = value.max_triple_count {
175+
limits.max_triple_count = max_triple_count;
176+
}
177+
if let Some(max_byte_size) = value.max_byte_size {
178+
limits.max_byte_size = max_byte_size;
179+
}
180+
if let Some(max_triple_byte_size) = value.max_triple_byte_size {
181+
limits.max_triple_byte_size = max_triple_byte_size;
182+
}
183+
if let Some(max_query_limit) = value.max_query_limit {
184+
limits.max_query_limit = max_query_limit;
185+
}
186+
if let Some(max_query_variable_count) = value.max_query_variable_count {
187+
limits.max_query_variable_count = max_query_variable_count;
188+
}
189+
if let Some(max_insert_data_byte_size) = value.max_insert_data_byte_size {
190+
limits.max_insert_data_byte_size = max_insert_data_byte_size;
191+
}
192+
if let Some(max_insert_data_triple_count) = value.max_insert_data_triple_count {
193+
limits.max_insert_data_triple_count = max_insert_data_triple_count;
194+
}
195+
196+
limits
197+
}
137198
}
138199

139200
/// # RdfFormat

docs/okp4-dataverse.md

+22-22
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Given its role and status, this smart contract serves as the primary access poin
5252
|`name`|*(Required.) * **string**. A unique name to identify the dataverse instance.|
5353
|`triplestore_config`|*(Required.) * **[TripleStoreConfig](#triplestoreconfig)**. The configuration used to instantiate the triple store.|
5454
|`triplestore_config.code_id`|**[Uint64](#uint64)**. The code id that will be used to instantiate the triple store contract in which to store dataverse semantic data. It must implement the cognitarium interface.|
55-
|`triplestore_config.limits`|**[StoreLimitsInput](#storelimitsinput)**. Limitations regarding triple store usage.<br />**Default:** `{"max_byte_size":"340282366920938463463374607431768211455","max_insert_data_byte_size":"340282366920938463463374607431768211455","max_insert_data_triple_count":"340282366920938463463374607431768211455","max_query_limit":30,"max_query_variable_count":30,"max_triple_byte_size":"340282366920938463463374607431768211455","max_triple_count":"340282366920938463463374607431768211455"}`|
55+
|`triplestore_config.limits`|**[TripleStoreLimitsInput](#triplestorelimitsinput)**. Limitations regarding triple store usage.|
5656

5757
## ExecuteMsg
5858

@@ -205,35 +205,35 @@ RDF/XML is a syntax to express RDF information in XML. See the [official RDF/XML
205205
|-------|
206206
|`"rdf_xml"`|
207207

208-
### StoreLimitsInput
208+
### TripleStoreConfig
209209

210-
Contains requested limitations regarding store usages.
210+
`TripleStoreConfig` represents the configuration related to the management of the triple store.
211211

212212
|property|description|
213213
|----------|-----------|
214-
|`max_byte_size`|**[Uint128](#uint128)**. The maximum number of bytes the store can contain. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. Default to [Uint128::MAX] if not set, which can be considered as no limit.|
215-
|`max_insert_data_byte_size`|**[Uint128](#uint128)**. The maximum number of bytes an insert data query can contain. Default to [Uint128::MAX] if not set, which can be considered as no limit.|
216-
|`max_insert_data_triple_count`|**[Uint128](#uint128)**. The maximum number of triples an insert data query can contain (after parsing). Default to [Uint128::MAX] if not set, which can be considered as no limit.|
217-
|`max_query_limit`|**integer**. The maximum limit of a query, i.e. the maximum number of triples returned by a select query. Default to 30 if not set.|
218-
|`max_query_variable_count`|**integer**. The maximum number of variables a query can select. Default to 30 if not set.|
219-
|`max_triple_byte_size`|**[Uint128](#uint128)**. The maximum number of bytes the store can contain for a single triple. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. The limit is used to prevent storing very large triples, especially literals. Default to [Uint128::MAX] if not set, which can be considered as no limit.|
220-
|`max_triple_count`|**[Uint128](#uint128)**. The maximum number of triples the store can contain. Default to [Uint128::MAX] if not set, which can be considered as no limit.|
214+
|`code_id`|*(Required.) * **[Uint64](#uint64)**. The code id that will be used to instantiate the triple store contract in which to store dataverse semantic data. It must implement the cognitarium interface.|
215+
|`limits`|*(Required.) * **[TripleStoreLimitsInput](#triplestorelimitsinput)**. Limitations regarding triple store usage.|
216+
|`limits.max_byte_size`|**[Uint128](#uint128)\|null**. The maximum number of bytes the store can contain. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. Default to [Uint128::MAX] if not set, which can be considered as no limit.|
217+
|`limits.max_insert_data_byte_size`|**[Uint128](#uint128)\|null**. The maximum number of bytes an insert data query can contain. Default to [Uint128::MAX] if not set, which can be considered as no limit.|
218+
|`limits.max_insert_data_triple_count`|**[Uint128](#uint128)\|null**. The maximum number of triples an insert data query can contain (after parsing). Default to [Uint128::MAX] if not set, which can be considered as no limit.|
219+
|`limits.max_query_limit`|**integer\|null**. The maximum limit of a query, i.e. the maximum number of triples returned by a select query. Default to 30 if not set.|
220+
|`limits.max_query_variable_count`|**integer\|null**. The maximum number of variables a query can select. Default to 30 if not set.|
221+
|`limits.max_triple_byte_size`|**[Uint128](#uint128)\|null**. The maximum number of bytes the store can contain for a single triple. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. The limit is used to prevent storing very large triples, especially literals. Default to [Uint128::MAX] if not set, which can be considered as no limit.|
222+
|`limits.max_triple_count`|**[Uint128](#uint128)\|null**. The maximum number of triples the store can contain. Default to [Uint128::MAX] if not set, which can be considered as no limit.|
221223

222-
### TripleStoreConfig
224+
### TripleStoreLimitsInput
223225

224-
`TripleStoreConfig` represents the configuration related to the management of the triple store.
226+
Contains requested limitations regarding store usages.
225227

226228
|property|description|
227229
|----------|-----------|
228-
|`code_id`|*(Required.) * **[Uint64](#uint64)**. The code id that will be used to instantiate the triple store contract in which to store dataverse semantic data. It must implement the cognitarium interface.|
229-
|`limits`|**[StoreLimitsInput](#storelimitsinput)**. Limitations regarding triple store usage.|
230-
|`limits.max_byte_size`|**[Uint128](#uint128)**. The maximum number of bytes the store can contain. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. Default to [Uint128::MAX] if not set, which can be considered as no limit.<br />**Default:** `"340282366920938463463374607431768211455"`|
231-
|`limits.max_insert_data_byte_size`|**[Uint128](#uint128)**. The maximum number of bytes an insert data query can contain. Default to [Uint128::MAX] if not set, which can be considered as no limit.<br />**Default:** `"340282366920938463463374607431768211455"`|
232-
|`limits.max_insert_data_triple_count`|**[Uint128](#uint128)**. The maximum number of triples an insert data query can contain (after parsing). Default to [Uint128::MAX] if not set, which can be considered as no limit.<br />**Default:** `"340282366920938463463374607431768211455"`|
233-
|`limits.max_query_limit`|**integer**. The maximum limit of a query, i.e. the maximum number of triples returned by a select query. Default to 30 if not set.<br />**Default:** `30`|
234-
|`limits.max_query_variable_count`|**integer**. The maximum number of variables a query can select. Default to 30 if not set.<br />**Default:** `30`|
235-
|`limits.max_triple_byte_size`|**[Uint128](#uint128)**. The maximum number of bytes the store can contain for a single triple. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. The limit is used to prevent storing very large triples, especially literals. Default to [Uint128::MAX] if not set, which can be considered as no limit.<br />**Default:** `"340282366920938463463374607431768211455"`|
236-
|`limits.max_triple_count`|**[Uint128](#uint128)**. The maximum number of triples the store can contain. Default to [Uint128::MAX] if not set, which can be considered as no limit.<br />**Default:** `"340282366920938463463374607431768211455"`|
230+
|`max_byte_size`|**[Uint128](#uint128)\|null**. The maximum number of bytes the store can contain. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. Default to [Uint128::MAX] if not set, which can be considered as no limit.|
231+
|`max_insert_data_byte_size`|**[Uint128](#uint128)\|null**. The maximum number of bytes an insert data query can contain. Default to [Uint128::MAX] if not set, which can be considered as no limit.|
232+
|`max_insert_data_triple_count`|**[Uint128](#uint128)\|null**. The maximum number of triples an insert data query can contain (after parsing). Default to [Uint128::MAX] if not set, which can be considered as no limit.|
233+
|`max_query_limit`|**integer\|null**. The maximum limit of a query, i.e. the maximum number of triples returned by a select query. Default to 30 if not set.|
234+
|`max_query_variable_count`|**integer\|null**. The maximum number of variables a query can select. Default to 30 if not set.|
235+
|`max_triple_byte_size`|**[Uint128](#uint128)\|null**. The maximum number of bytes the store can contain for a single triple. The size of a triple is counted as the sum of the size of its subject, predicate and object, including the size of data types and language tags if any. The limit is used to prevent storing very large triples, especially literals. Default to [Uint128::MAX] if not set, which can be considered as no limit.|
236+
|`max_triple_count`|**[Uint128](#uint128)\|null**. The maximum number of triples the store can contain. Default to [Uint128::MAX] if not set, which can be considered as no limit.|
237237

238238
### Turtle
239239

@@ -271,4 +271,4 @@ let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```
271271
272272
---
273273
274-
*Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-dataverse.json` (`bee536f5330fd1e5`)*
274+
*Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-dataverse.json` (`569cd8a4d521dc5f`)*

0 commit comments

Comments
 (0)