offlineCalculate
Generates bucket data on the server for fast online query.
int offlineCalculate(
DG_TeeCtx *dgTeeCtx,
DG_PairList *pairList,
DG_BucketMap **bucketMap
)
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
dgTeeCtx |
KCAL context |
Context initialized in section initTeeCtx. |
Input |
pairList |
Input query structure (key-value structured object) |
- |
Input |
bucketMap |
Bucket data generated |
- |
Output |
Member |
Type |
Description |
|---|---|---|
dgPair |
Indicates the key-value structured arrays, DG_Pair. |
Compute nodes 0 and 1 |
size |
Indicates the number of key-value structures, represented as an unsigned long integer. |
- |
Member |
Type |
Description |
|---|---|---|
key |
Key value represented as a DG_String |
Key in the query structure |
value |
Value corresponding to the key, represented as a DG_String |
Value in the query structure |
Member |
Type |
Description |
|---|---|---|
str |
char * |
Data in the defined DG_String |
size |
unsigned long |
Size of the data in the defined DG_String |
Return Values
- Success: 0 is returned.
- Failure: The error code is returned.
Error Codes
Error Code |
Value |
Description |
Remarks |
|---|---|---|---|
DG_SUCCESS |
0 |
Success |
- |
DG_FAILURE |
1 |
Failure |
Failed to write key-value pairs to the bucket. |
DG_ERR_MALLOC_FAIL |
51 |
Memory allocation failure |
- |
DG_ERR_MPC_TEE_INVALID_NODE_INFO |
4503 |
Invalid TEE node information |
- |
DG_ERR_MPC_TEE_INVALID_PARAM |
4501 |
Parameter verification failure |
dgCfg is null or the dgTeeCtx double pointer is null. |
Dependency
- This API depends on the KCAL configuration in section DataGuard APIs for Configuring an Operation Set, and the configured dgCfg is used as the input parameter of this API.
- pirOpts depends on the successful initialization in section DG_InitPirOpts of the function group for the PIR operator.
- #include "data_guard_mpc.h": required header file
Example
#include "data_guard_mpc.h"
void BuildDgPairList(std::vector<std::pair<std::string, std::string>>& data, DG_PairList **pairList) {
auto size = data.size();
*pairList = new DG_PairList;
(*pairList)->dgPair = new DG_Pair[size];
for (unsigned long i = 0; i < size; ++i) {
(*pairList)->dgPair[i].key = BuildPairString(data[i].first);
(*pairList)->dgPair[i].value = BuildPairString(data[i].second);
}
(*pairList)->size = data.size();
}
DG_PairList *pairList = nullptr;
DG_BucketMap *bucketMap = nullptr;
unsigned int size;
BuildDgPairList(datas, &pairList);
// pirOpts is the result of the successful DG_InitPirOpts call, and dgTee is the result of the successful initTeeCtx call.
rv = pirOpts.offlineCalculate(dgTee, pairList, &bucketMap);
if (rv != 0) {
return rv;
}
Call the offlineCalculate API using the pirOpts output of the successful DG_InitPirOpts call.