-
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.
- Loading branch information
1 parent
5f197a9
commit 0206145
Showing
8 changed files
with
199 additions
and
4 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
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,28 @@ | ||
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,28 @@ | ||
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
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