objstorageprovider

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2024 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFileWritable

func NewFileWritable(file vfs.File) objstorage.Writable

NewFileWritable returns a Writable that uses a file as underlying storage.

func NewRemoteWritable

func NewRemoteWritable(obj io.WriteCloser) objstorage.Writable

NewRemoteWritable creates an objstorage.Writable out of an io.WriteCloser.

func Open

func Open(settings Settings) (objstorage.Provider, error)

Open creates the provider.

func TestingCheckMaxReadahead

func TestingCheckMaxReadahead(rh objstorage.ReadHandle) bool

TestingCheckMaxReadahead returns true if the ReadHandle has switched to OS-level read-ahead.

func UsePreallocatedReadHandle

func UsePreallocatedReadHandle(
	ctx context.Context, readable objstorage.Readable, rh *PreallocatedReadHandle,
) objstorage.ReadHandle

UsePreallocatedReadHandle is equivalent to calling readable.NewReadHandle() but uses the existing storage of a PreallocatedReadHandle when possible (currently this happens if we are reading from a local file). The returned handle still needs to be closed.

Types

type PreallocatedReadHandle

type PreallocatedReadHandle struct {
	// contains filtered or unexported fields
}

PreallocatedReadHandle is used to avoid an allocation in NewReadHandle; see UsePreallocatedReadHandle.

func (*PreallocatedReadHandle) Close

func (rh *PreallocatedReadHandle) Close() error

Close is part of the objstorage.ReadHandle interface.

func (*PreallocatedReadHandle) ReadAt

func (rh *PreallocatedReadHandle) ReadAt(_ context.Context, p []byte, offset int64) error

ReadAt is part of the objstorage.ReadHandle interface.

func (*PreallocatedReadHandle) RecordCacheHit

func (rh *PreallocatedReadHandle) RecordCacheHit(_ context.Context, offset, size int64)

RecordCacheHit is part of the objstorage.ReadHandle interface.

func (*PreallocatedReadHandle) SetupForCompaction

func (rh *PreallocatedReadHandle) SetupForCompaction()

SetupForCompaction is part of the objstorage.ReadHandle interface.

type Settings

type Settings struct {
	Logger base.Logger

	// Local filesystem configuration.
	FS        vfs.FS
	FSDirName string

	// FSDirInitialListing is a listing of FSDirName at the time of calling Open.
	//
	// This is an optional optimization to avoid double listing on Open when the
	// higher layer already has a listing. When nil, we obtain the listing on
	// Open.
	FSDirInitialListing []string

	// Cleaner cleans obsolete files from the local filesystem.
	//
	// The default cleaner uses the DeleteCleaner.
	FSCleaner base.Cleaner

	// NoSyncOnClose decides whether the implementation will enforce a
	// close-time synchronization (e.g., fdatasync() or sync_file_range())
	// on files it writes to. Setting this to true removes the guarantee for a
	// sync on close. Some implementations can still issue a non-blocking sync.
	NoSyncOnClose bool

	// BytesPerSync enables periodic syncing of files in order to smooth out
	// writes to disk. This option does not provide any persistence guarantee, but
	// is used to avoid latency spikes if the OS automatically decides to write
	// out a large chunk of dirty filesystem buffers.
	BytesPerSync int

	// Fields here are set only if the provider is to support remote objects
	// (experimental).
	Remote struct {
		StorageFactory remote.StorageFactory

		// If CreateOnShared is non-zero, sstables are created on remote storage using
		// the CreateOnSharedLocator (when the PreferSharedStorage create option is
		// true).
		CreateOnShared        remote.CreateOnSharedStrategy
		CreateOnSharedLocator remote.Locator

		// CacheSizeBytes is the size of the on-disk block cache for objects
		// on remote storage. If it is 0, no cache is used.
		CacheSizeBytes int64

		// CacheBlockSize is the block size of the cache; if 0, the default of 32KB is used.
		CacheBlockSize int

		// ShardingBlockSize is the size of a shard block. The cache is split into contiguous
		// ShardingBlockSize units. The units are distributed across multiple independent shards
		// of the cache, via a hash(offset) modulo num shards operation. The cache replacement
		// policies operate at the level of shard, not whole cache. This is done to reduce lock
		// contention.
		//
		// If ShardingBlockSize is 0, the default of 1 MB is used.
		ShardingBlockSize int64

		// The number of independent shards the cache leverages. Each shard is the same size,
		// and a hash of filenum & offset map a read to a certain shard. If set to 0,
		// 2*runtime.GOMAXPROCS is used as the shard count.
		CacheShardCount int
	}
}

Settings that must be specified when creating the provider.

func DefaultSettings

func DefaultSettings(fs vfs.FS, dirName string) Settings

DefaultSettings initializes default settings (with no remote storage), suitable for tests and tools.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL