storage

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: Apache-2.0 Imports: 27 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ObjectStorageAuthTypeStatic = "static"
)

Variables

View Source
var (
	ErrLockFailed         = redsync.ErrFailed
	ErrLockAlreadyExpired = redsync.ErrLockAlreadyExpired
	ErrManifestInvalid    = errors.New("manifest is invalid")
	ErrNoManifestFound    = errors.New("no manifest found")
)

Functions

This section is empty.

Types

type IKeyStorage

type IKeyStorage interface {
	AddItemsToTablePartition(context.Context, elements.Partition, [][]byte) (int64, error)

	GetTablePartitionItems(context.Context, elements.Partition, int) ([]string, error)
	GetTablePartitions(context.Context, string, uint64, int64) ([]elements.Partition, error)

	GetTablePartitionTimestamp(context.Context, elements.Partition) (time.Time, error)
	SetTablePartitionTimestamp(context.Context, elements.Partition) (bool, error)
	DeleteTablePartitionTimestamp(context.Context, elements.Partition) (bool, error)

	ClaimPartition(context.Context, elements.Partition, time.Duration) (ILock, error)
	ReleasePartitionLock(context.Context, ILock) (bool, error)
}

type ILock

type ILock interface {
	TryLockContext(context.Context) error
	UnlockContext(context.Context) (bool, error)
	Name() string
}

type IManifestStorage

type IManifestStorage interface {
	GetPartitionManifest(context.Context, elements.Partition) (*PartitionManifest, error)
	GetPartitionManifestFile(context.Context, *PartitionManifest, int, string) error
	ReplacePartitionManifest(
		context.Context,
		elements.Partition,
		*PartitionManifest,
		*PartitionManifest, []string) error
	MergePartitionRecordIntoManifest(
		context.Context,
		elements.Partition,
		arrow.Record,
		arrow.Record,
		[]string,
		[]string,
		PartitionManifestOptions) error
}

type IObjectStorage

type IObjectStorage interface {
	Upload(context.Context, string, string, []byte) error
	UploadFile(context.Context, string, string, string) error
	Download(context.Context, string, string) ([]byte, error)
	DownloadFile(context.Context, string, string, string) error
	Delete(context.Context, string, string) error
	ListObjects(context.Context, string, string) ([]string, error)
	CreateBucket(context.Context, string) error
}

type KeyStorage

type KeyStorage struct {
	KeyPrefix string
	// contains filtered or unexported fields
}

func NewKeyStorage

func NewKeyStorage(
	ctx context.Context,
	logger *slog.Logger,
	options KeyStorageOptions,
) (*KeyStorage, error)

func (*KeyStorage) AcquireLock

func (obj *KeyStorage) AcquireLock(ctx context.Context, key string, duration time.Duration) (ILock, error)

func (*KeyStorage) AddItemsToTablePartition

func (obj *KeyStorage) AddItemsToTablePartition(ctx context.Context, partition elements.Partition, items [][]byte) (int64, error)

func (*KeyStorage) ClaimPartition

func (obj *KeyStorage) ClaimPartition(ctx context.Context, partition elements.Partition, duration time.Duration) (ILock, error)

func (*KeyStorage) Close

func (obj *KeyStorage) Close() error

func (*KeyStorage) DeleteTablePartitionTimestamp

func (obj *KeyStorage) DeleteTablePartitionTimestamp(ctx context.Context, partition elements.Partition) (bool, error)

func (*KeyStorage) DerCtx

func (*KeyStorage) GetTablePartitionItems

func (obj *KeyStorage) GetTablePartitionItems(ctx context.Context, partition elements.Partition, count int) ([]string, error)

func (*KeyStorage) GetTablePartitionTimestamp

func (obj *KeyStorage) GetTablePartitionTimestamp(ctx context.Context, partition elements.Partition) (time.Time, error)

func (*KeyStorage) GetTablePartitions

func (obj *KeyStorage) GetTablePartitions(ctx context.Context, tableName string, cursor uint64, count int64) ([]elements.Partition, error)

func (*KeyStorage) Key

func (obj *KeyStorage) Key(key string) string

func (*KeyStorage) ReleaseLock

func (obj *KeyStorage) ReleaseLock(ctx context.Context, lock ILock) (bool, error)

func (*KeyStorage) ReleasePartitionLock

func (obj *KeyStorage) ReleasePartitionLock(ctx context.Context, lock ILock) (bool, error)

func (*KeyStorage) SetTablePartitionTimestamp

func (obj *KeyStorage) SetTablePartitionTimestamp(ctx context.Context, partition elements.Partition) (bool, error)

type KeyStorageOptions

type KeyStorageOptions struct {
	Address   string
	Password  string
	KeyPrefix string
}

type ManifestObject

type ManifestObject struct {
	Key     string `json:"key"`
	Index   int    `json:"index"`
	NumRows int64  `json:"num_rows"`
}

func (*ManifestObject) Validate

func (obj *ManifestObject) Validate() error

type ManifestStorage

type ManifestStorage struct {
	IObjectStorage
	// contains filtered or unexported fields
}

func NewManifestStorage

func NewManifestStorage(
	ctx context.Context,
	logger *slog.Logger,
	mem *memory.GoAllocator,
	objectStorage IObjectStorage,
	options ManifestStorageOptions,
) *ManifestStorage

func (*ManifestStorage) GetPartitionManifest

func (obj *ManifestStorage) GetPartitionManifest(
	ctx context.Context,
	partition elements.Partition,
) (*PartitionManifest, error)

func (*ManifestStorage) GetPartitionManifestFile

func (obj *ManifestStorage) GetPartitionManifestFile(ctx context.Context, manifest *PartitionManifest, index int, filePath string) error

func (*ManifestStorage) MergePartitionRecordIntoManifest

func (obj *ManifestStorage) MergePartitionRecordIntoManifest(
	ctx context.Context,
	partition elements.Partition,
	processedKeyRecord arrow.Record,
	newRecord arrow.Record,
	primaryColumns []string,
	compareColumns []string,
	options PartitionManifestOptions,
) error

func (*ManifestStorage) ReplacePartitionManifest

func (obj *ManifestStorage) ReplacePartitionManifest(
	ctx context.Context,
	partition elements.Partition,
	previousManifest *PartitionManifest,
	manifest *PartitionManifest,
	filePaths []string,
) error

type ManifestStorageOptions

type ManifestStorageOptions struct {
	BucketName string
	KeyPrefix  string
}

type ObjectStorage

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

func NewObjectStorage

func NewObjectStorage(
	ctx context.Context,
	logger *slog.Logger,
	options ObjectStorageOptions,
) (*ObjectStorage, error)

func (*ObjectStorage) CreateBucket

func (obj *ObjectStorage) CreateBucket(ctx context.Context, bucket string) error

func (*ObjectStorage) Delete

func (obj *ObjectStorage) Delete(ctx context.Context, bucket, key string) error

func (*ObjectStorage) Download

func (obj *ObjectStorage) Download(ctx context.Context, bucket, key string) ([]byte, error)

func (*ObjectStorage) DownloadFile

func (obj *ObjectStorage) DownloadFile(ctx context.Context, bucket, key, filePath string) error

func (*ObjectStorage) ListObjects

func (obj *ObjectStorage) ListObjects(ctx context.Context, bucket string, prefix string) ([]string, error)

func (*ObjectStorage) Upload

func (obj *ObjectStorage) Upload(ctx context.Context, bucket, key string, body []byte) error

func (*ObjectStorage) UploadFile

func (obj *ObjectStorage) UploadFile(ctx context.Context, bucket, key, filePath string) error

type ObjectStorageOptions

type ObjectStorageOptions struct {
	Endpoint     string
	Region       string
	AuthKey      string
	AuthSecret   string
	UsePathStyle bool
	AuthType     string
}

func NewObjectStorageOptionsFromStaticCredentials

func NewObjectStorageOptionsFromStaticCredentials(
	endpoint string,
	region string,
	authKey string,
	authSecret string,
	usePathStyle bool,
) *ObjectStorageOptions

type PartitionManifest

type PartitionManifest struct {
	Id           string           `json:"id"`
	TableName    string           `json:"table_name"`
	PartitionKey string           `json:"partition_key"`
	Version      int              `json:"version"`
	Objects      []ManifestObject `json:"objects"`
}

func NewManifestFromBytes

func NewManifestFromBytes(data []byte) (*PartitionManifest, error)

func (*PartitionManifest) SortObjects

func (obj *PartitionManifest) SortObjects()

func (*PartitionManifest) ToBytes

func (obj *PartitionManifest) ToBytes() ([]byte, error)

func (*PartitionManifest) Validate

func (obj *PartitionManifest) Validate() error

type PartitionManifestBuilder

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

func NewPartitionManifestBuilder

func NewPartitionManifestBuilder(tableName string, partitionKey string, version int) *PartitionManifestBuilder

func (*PartitionManifestBuilder) AddFile

func (obj *PartitionManifestBuilder) AddFile(pqf arrowops.ParquetFile)

func (*PartitionManifestBuilder) Files

func (obj *PartitionManifestBuilder) Files() []string

func (*PartitionManifestBuilder) Manifest

type PartitionManifestOptions

type PartitionManifestOptions struct {
	MaxObjects    int
	MaxObjectRows int
}

Jump to

Keyboard shortcuts

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