kelp: Create a kelp object for interacting with SeaweedFS.

Description Details Public fields Methods

Description

Create a kelp object for interacting with SeaweedFS.

Create a kelp object for interacting with SeaweedFS.

Details

This is a slightly higher level abstraction than seaweed_master() and seaweed_volume().

Public fields

seaweed_url

Base URL for seaweed master.

Methods

Public methods


Method new()

Create client object for sending http requests to seaweed

Usage
kelp$new(seaweed_url)
Arguments
seaweed_url

Root URL of Seaweed

Returns

A new kelp object


Method upload_file()

Upload file to SeaweedFS

Usage
kelp$upload_file(path, collection = NULL)
Arguments
path

Path to file to be uploaded

collection

Collection name, acts as a namespace for files.

Returns

The uploaded file ID.


Method download_file()

Download file from SeaweedFS

If called with an id matching an R object uploaded via kelp$upload_object() then this will download raw bytes from SeaweedFS which can be converted back to R object at later point using unserialize or readRDS.

Usage
kelp$download_file(id, path = tempfile(), collection = NULL)
Arguments
id

SeaweedFS file ID to read

path

Path to download file to

collection

Optional collection name this file belongs to.

Returns

The file contents


Method upload_object()

Upload arbitrary R object to SeaweedFS.

This serializes R object to raw vector of bytes and then saves bytes to SeaweedFS. To recover R object as saved use seaweed_volume$download_object()

Usage
kelp$upload_object(object, collection = NULL)
Arguments
object

Object to be uploaded

collection

Collection name, acts as a namespace.

Returns

The uploaded file ID.


Method download_object()

Download arbitrary R object from SeaweedFS

If data downloaded from SeaweedFS is not unserializable (i.e. it was written using kelp$upload_file()) then this will throw an error. See kelp$download_file() to download as a file.

Usage
kelp$download_object(id, collection = NULL)
Arguments
id

SeaweedFS file ID to download

collection

Optional collection name this file belongs to.

Returns

The R object.


Method upload_raw()

Upload vector of raw bytes to SeaweedFS.

Usage
kelp$upload_raw(raw, collection = NULL)
Arguments
raw

Object to be uploaded

collection

Collection name, acts as a namespace.

Returns

The uploaded file ID.


Method download_raw()

Download vector of raw bytes from SeaweedFS

Usage
kelp$download_raw(id, collection = NULL)
Arguments
id

SeaweedFS file ID to download

collection

Optional collection name this file belongs to.

Returns

Vector of raw bytes.


Method delete()

Delete file from SeaweedFS

Usage
kelp$delete(id, collection = NULL)
Arguments
id

SeaweedFS file ID to delete

collection

Optional collection name this file belongs to. This helps speedup lookup - only the single id will be deleted. See kelp$delete_collection() to remove an entire collection.

Returns

Nothing, called for side effects


Method delete_collection()

Delete a collection of files

Usage
kelp$delete_collection(collection)
Arguments
collection

Collection name.

Returns

Nothing, called for side effects


mrc-ide/kelp documentation built on Dec. 21, 2021, 10:04 p.m.