Skip to content

Commit

Permalink
TempFilesystemBase
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunrd0 committed Nov 22, 2023
1 parent aaa6f6e commit 5a34f35
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
52 changes: 26 additions & 26 deletions tiledb/sm/filesystem/filesystem_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,24 @@
#ifndef TILEDB_FILESYSTEMBASE_H
#define TILEDB_FILESYSTEMBASE_H

#include "ls_scanner.h"
#include "tiledb/common/filesystem/directory_entry.h"
#include "uri.h"

#include <vector>

namespace tiledb::sm {

class VFS;
class TempFilesystemBase {
public:
template <FilePredicate F, DirectoryPredicate D>
LsObjects ls_filtered(
const URI&, F, D = tiledb::sm::accept_all_dirs, bool = false) const {
return {};
}
};

class FilesystemBase {
class FilesystemBase : TempFilesystemBase {
public:
FilesystemBase() = default;

Expand All @@ -58,47 +66,47 @@ class FilesystemBase {
* @param uri The URI of the directory.
* @return Status
*/
virtual Status create_dir(const URI& uri) const = 0;
virtual Status create_dir(const URI&) const = 0;

/**
* Creates an empty file.
*
* @param uri The URI of the file.
* @return Status
*/
virtual Status touch(const URI& uri) const = 0;
virtual Status touch(const URI&) const = 0;

/**
* Checks if a directory exists.
*
* @param uri The URI to check for existence.
* @return True if the directory exists, else False.
*/
virtual bool is_dir(const URI& uri) const = 0;
virtual bool is_dir(const URI&) const = 0;

/**
* Checks if a file exists.
*
* @param uri The URI to check for existence.
* @return True if the file exists, else False.
*/
virtual bool is_file(const URI& uri) const = 0;
virtual bool is_file(const URI&) const = 0;

/**
* Removes a given directory (recursive)
*
* @param uri The uri of the directory to be removed
* @return Status
*/
virtual Status remove_dir(const URI& uri) const = 0;
virtual Status remove_dir(const URI&) const = 0;

/**
* Deletes a file.
*
* @param uri The URI of the file.
* @return Status
*/
virtual Status remove_file(const URI& uri) const = 0;
virtual Status remove_file(const URI&) const = 0;

/**
* Retrieves the size of a file.
Expand All @@ -107,7 +115,7 @@ class FilesystemBase {
* @param size The file size to be retrieved.
* @return Status
*/
virtual Status file_size(const URI& uri, uint64_t* size) const = 0;
virtual Status file_size(const URI&, uint64_t*) const = 0;

/**
* Retrieves all the entries contained in the parent.
Expand All @@ -118,17 +126,18 @@ class FilesystemBase {
virtual tuple<
Status,
optional<std::vector<common::filesystem::directory_entry>>>
ls_with_sizes(const URI& parent) const = 0;
ls_with_sizes(const URI&) const = 0;

/**
* Renames a file.
* Both URI must be of the same backend type. (e.g. both s3://, file://, etc)
* Both URI must be of the same backend type. (e.g. both s3://, file://,
* etc)
*
* @param old_uri The old URI.
* @param new_uri The new URI.
* @return Status
*/
virtual Status move_file(const URI& old_uri, const URI& new_uri) const = 0;
virtual Status move_file(const URI&, const URI&) const = 0;

/**
* Copies a file.
Expand All @@ -138,7 +147,7 @@ class FilesystemBase {
* @param new_uri The new URI.
* @return Status
*/
virtual Status copy_file(const URI& old_uri, const URI& new_uri) const = 0;
virtual Status copy_file(const URI&, const URI&) const = 0;

/**
* Copies directory.
Expand All @@ -148,7 +157,7 @@ class FilesystemBase {
* @param new_uri The new URI.
* @return Status
*/
virtual Status copy_dir(const URI& old_uri, const URI& new_uri) const = 0;
virtual Status copy_dir(const URI&, const URI&) const = 0;

/**
* Reads from a file.
Expand All @@ -160,20 +169,15 @@ class FilesystemBase {
* @param use_read_ahead Whether to use the read-ahead cache.
* @return Status
*/
virtual Status read(
const URI& uri,
uint64_t offset,
void* buffer,
uint64_t nbytes,
bool use_read_ahead = true) = 0;
virtual Status read(const URI&, uint64_t, void*, uint64_t, bool = true) = 0;

/**
* Syncs (flushes) a file. Note that for S3 this is a noop.
*
* @param uri The URI of the file.
* @return Status
*/
virtual Status sync(const URI& uri) = 0;
virtual Status sync(const URI&) = 0;

/**
* Writes the contents of a buffer into a file.
Expand All @@ -184,11 +188,7 @@ class FilesystemBase {
* @param remote_global_order_write Remote global order write
* @return Status
*/
virtual Status write(
const URI& uri,
const void* buffer,
uint64_t buffer_size,
bool remote_global_order_write = false) = 0;
virtual Status write(const URI&, const void*, uint64_t, bool = false) = 0;
};

} // namespace tiledb::sm
Expand Down
5 changes: 3 additions & 2 deletions tiledb/sm/filesystem/s3.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#ifdef HAVE_S3

#include "filesystem_base.h"
#include "ls_scanner.h"
#include "tiledb/common/common.h"
#include "tiledb/common/filesystem/directory_entry.h"
Expand Down Expand Up @@ -464,7 +465,7 @@ class S3Scanner : public LsScanner<F, D> {
// If the request returned no results, we've reached the end of the scan.
// We hit this case when the number of objects in the bucket is a multiple
// of the current max_keys.
begin_ = end_;
return end_;
}

return begin_;
Expand Down Expand Up @@ -506,7 +507,7 @@ class S3Scanner : public LsScanner<F, D> {
* This class implements the various S3 filesystem functions. It also
* maintains buffer caches for writing into the various attribute files.
*/
class S3 {
class S3 : public TempFilesystemBase {
private:
/** Forward declaration */
struct MultiPartUploadState;
Expand Down

0 comments on commit 5a34f35

Please sign in to comment.