binarychunk

package
v0.0.0-...-9f7285a Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MAXIMUM_CHUNK_SIZE = 1024 * 1024 * 500

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryReference

type BinaryReference struct {
	Offset int `json:"offset"`
	Length int `json:"len"`
	Buffer int `json:"buffer"`
}

type Builder

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

Builder builds the list of binary data from given sequence of byte arrays.

func NewBuilder

func NewBuilder(compressor Compressor, tmpFolderPath string) *Builder

func (*Builder) Build

func (b *Builder) Build(ctx context.Context, writer io.Writer, progress *progress.TaskProgress) (int, error)

Build amends all the binary buffers to the given writer in KHI format. Returns the written byte size.

func (*Builder) Read

func (b *Builder) Read(ref *BinaryReference) ([]byte, error)

func (*Builder) Write

func (b *Builder) Write(binaryBody []byte) (*BinaryReference, error)

Write amends the givenBinary in some binary chunk. If same body was given previously, it will return the reference from the cache.

type Compressor

type Compressor interface {
	// CompressAll reads all bytes from given reader and returns a reader for the compressed buffer.
	CompressAll(ctx context.Context, reader io.Reader) (io.Reader, error)
	// Dispose releases all allocated resource in Compressor.
	Dispose() error
}

type FileSystemBinaryWriter

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

FileSystemBinaryWriter is a basic implementation of the LargeTextWriter.

func NewFileSystemBinaryWriter

func NewFileSystemBinaryWriter(tmpPath string, bufferIndex int, maxSize int) (*FileSystemBinaryWriter, error)

func (*FileSystemBinaryWriter) CanWrite

func (w *FileSystemBinaryWriter) CanWrite(size int) bool

func (*FileSystemBinaryWriter) Dispose

func (w *FileSystemBinaryWriter) Dispose() error

func (*FileSystemBinaryWriter) GetBinary

func (w *FileSystemBinaryWriter) GetBinary() (io.Reader, error)

func (*FileSystemBinaryWriter) Read

func (w *FileSystemBinaryWriter) Read(ref *BinaryReference) ([]byte, error)

func (*FileSystemBinaryWriter) Write

func (w *FileSystemBinaryWriter) Write(data []byte) (*BinaryReference, error)

type FileSystemGzipCompressor

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

func NewFileSystemGzipCompressor

func NewFileSystemGzipCompressor(temporaryFolder string) *FileSystemGzipCompressor

func (*FileSystemGzipCompressor) CompressAll

func (c *FileSystemGzipCompressor) CompressAll(ctx context.Context, reader io.Reader) (io.Reader, error)

func (*FileSystemGzipCompressor) Dispose

func (c *FileSystemGzipCompressor) Dispose() error

type LargeBinaryWriter

type LargeBinaryWriter interface {
	// Check if the specified text can fit in the buffer
	CanWrite(size int) bool
	// Write the specified text and returns the BinaryReference
	Write(data []byte) (*BinaryReference, error)
	// Read buffer from a BinaryReference
	Read(ref *BinaryReference) ([]byte, error)
	// Obtain the result binary as io.Reader
	GetBinary() (io.Reader, error)
	// Free allocated resource for the writer
	Dispose() error
}

LargeBinaryWriter stores text as a large binary chunk and returns BinaryReference points the buffer location.

Jump to

Keyboard shortcuts

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