-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libfaasm: add support for general S3 API (#126)
* libfaasm: add support for general s3 API * s3: add function to get number of buckets * s3: add remaining basic functions * nits: run clang-format * gh: bump minor code version * libfaasm: remove un-implemented symbols * s3: temporarily commit the workflow functions * wc: more functions * s3: untrack wc functions * s3: build functions as part of gha * func(demo): update chain_output function for new signature * func: separate threaded/non-threaded targets
- Loading branch information
1 parent
4d9f40c
commit 4590053
Showing
17 changed files
with
283 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
SYSROOT_VERSION=0.5.0 | ||
SYSROOT_CLI_IMAGE=faasm.azurecr.io/cpp-sysroot:0.5.0 | ||
SYSROOT_VERSION=0.6.0 | ||
SYSROOT_CLI_IMAGE=faasm.azurecr.io/cpp-sysroot:0.6.0 | ||
COMPOSE_PROJECT_NAME=cpp-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.5.0 | ||
0.6.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
set(FAASM_USER s3) | ||
|
||
function(s3_func exec_name dir_path) | ||
faasm_func(${exec_name} ${dir_path}) | ||
set(ALL_DEMO_FUNCS ${ALL_DEMO_FUNCS} ${exec_name} PARENT_SCOPE) | ||
endfunction(s3_func) | ||
|
||
s3_func(get_num_buckets get_num_buckets.cpp) | ||
s3_func(list_buckets list_buckets.cpp) | ||
s3_func(get_num_keys get_num_keys.cpp) | ||
s3_func(list_keys list_keys.cpp) | ||
s3_func(add_key_bytes add_key_bytes.cpp) | ||
s3_func(get_key_bytes get_key_bytes.cpp) | ||
|
||
# Custom target to group all the demo functions | ||
add_custom_target(s3_all_funcs DEPENDS ${ALL_DEMO_FUNCS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
extern "C" | ||
{ | ||
#include "faasm/host_interface.h" | ||
} | ||
|
||
#include <faasm/faasm.h> | ||
#include <stdio.h> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
// Get bucket and key from command line | ||
if (argc != 3) { | ||
printf("error: must invoke function with two arguments: bucketName " | ||
"keyName\n"); | ||
return 1; | ||
} | ||
|
||
char* bucketName = argv[1]; | ||
char* keyName = argv[2]; | ||
|
||
// Get the bytes to add as input | ||
int inputSize = faasmGetInputSize(); | ||
uint8_t keyBytes[inputSize]; | ||
faasmGetInput(keyBytes, inputSize); | ||
|
||
int ret = | ||
__faasm_s3_add_key_bytes(bucketName, keyName, (void*)keyBytes, inputSize); | ||
|
||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
extern "C" | ||
{ | ||
#include "faasm/host_interface.h" | ||
} | ||
|
||
#include <faasm/faasm.h> | ||
#include <stdio.h> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
// Get bucket and key from command line | ||
if (argc != 3) { | ||
printf("error: must invoke function with two arguments: bucketName " | ||
"keyName\n"); | ||
return 1; | ||
} | ||
|
||
char* bucketName = argv[1]; | ||
char* keyName = argv[2]; | ||
|
||
uint8_t* keyBytes; | ||
int keyBytesLen; | ||
|
||
int ret = | ||
__faasm_s3_get_key_bytes(bucketName, keyName, &keyBytes, &keyBytesLen); | ||
printf("Got %s/%s: %s\n", bucketName, keyName, (char*)keyBytes); | ||
faasmSetOutput((char*)keyBytes, keyBytesLen); | ||
|
||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
extern "C" | ||
{ | ||
#include "faasm/host_interface.h" | ||
} | ||
|
||
#include <faasm/faasm.h> | ||
#include <stdio.h> | ||
#include <string> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
int numBuckets = __faasm_s3_get_num_buckets(); | ||
|
||
printf("Got %i buckets!\n", numBuckets); | ||
|
||
std::string numBucketsStr = std::to_string(numBuckets); | ||
faasmSetOutput(numBucketsStr.c_str(), numBucketsStr.size()); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
extern "C" | ||
{ | ||
#include "faasm/host_interface.h" | ||
} | ||
|
||
#include <faasm/faasm.h> | ||
#include <stdio.h> | ||
#include <string> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
// Get the bucket name as an input | ||
int inputSize = faasmGetInputSize(); | ||
char bucketName[inputSize]; | ||
faasmGetInput((uint8_t*)bucketName, inputSize); | ||
|
||
int numKeys = __faasm_s3_get_num_keys(bucketName); | ||
|
||
printf("Bucket %s has %i keys!\n", bucketName, numKeys); | ||
|
||
std::string numKeysStr = std::to_string(numKeys); | ||
faasmSetOutput(numKeysStr.c_str(), numKeysStr.size()); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
extern "C" | ||
{ | ||
#include "faasm/host_interface.h" | ||
} | ||
|
||
#include <faasm/faasm.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
int numBuckets = __faasm_s3_get_num_buckets(); | ||
|
||
char* bucketsBuffer[numBuckets]; | ||
int bucketsBufferLens[numBuckets]; | ||
__faasm_s3_list_buckets(bucketsBuffer, bucketsBufferLens); | ||
|
||
int totalSize = 0; | ||
for (int i = 0; i < numBuckets; i++) { | ||
totalSize += bucketsBufferLens[i]; | ||
} | ||
totalSize += numBuckets - 1; | ||
|
||
// Prepare the output: instead of a newline use a '|' character | ||
char outBuffer[totalSize]; | ||
|
||
printf("Got %i buckets!\n", numBuckets); | ||
int offset = 0; | ||
for (int i = 0; i < numBuckets; i++) { | ||
strncpy(outBuffer + offset, bucketsBuffer[i], bucketsBufferLens[i]); | ||
offset += bucketsBufferLens[i]; | ||
if (i < numBuckets - 1) { | ||
outBuffer[offset] = (char)'|'; | ||
offset += 1; | ||
} | ||
printf("Bucket %i: %s\n", i, bucketsBuffer[i]); | ||
} | ||
|
||
faasmSetOutput(outBuffer, totalSize); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
extern "C" | ||
{ | ||
#include "faasm/host_interface.h" | ||
} | ||
|
||
#include <faasm/faasm.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
// Get the bucket name as an input | ||
int inputSize = faasmGetInputSize(); | ||
char bucketName[inputSize]; | ||
faasmGetInput((uint8_t*)bucketName, inputSize); | ||
|
||
int numKeys = __faasm_s3_get_num_keys(bucketName); | ||
|
||
char* keysBuffer[numKeys]; | ||
int keysBufferLens[numKeys]; | ||
__faasm_s3_list_keys(bucketName, keysBuffer, keysBufferLens); | ||
|
||
int totalSize = 0; | ||
for (int i = 0; i < numKeys; i++) { | ||
totalSize += keysBufferLens[i]; | ||
} | ||
totalSize += numKeys - 1; | ||
|
||
// Prepare the output: instead of a newline use a '|' character | ||
char outBuffer[totalSize]; | ||
|
||
printf("Bucket %s has %i keys!\n", bucketName, numKeys); | ||
int offset = 0; | ||
for (int i = 0; i < numKeys; i++) { | ||
strncpy(outBuffer + offset, keysBuffer[i], keysBufferLens[i]); | ||
offset += keysBufferLens[i]; | ||
if (i < numKeys - 1) { | ||
outBuffer[offset] = (char)'|'; | ||
offset += 1; | ||
} | ||
printf("Key %i: %s\n", i, keysBuffer[i]); | ||
} | ||
|
||
faasmSetOutput(outBuffer, totalSize); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters