Documentation ¶
Overview ¶
Package datacapture contains tools for interacting with Viam datacapture files.
Index ¶
- Constants
- Variables
- func BuildCaptureMetadata(compType resource.Subtype, compName string, compModel resource.Model, ...) (*v1.DataCaptureMetadata, error)
- func GetAllReadings(filePath string) ([]*v1.SensorData, error)
- func GetFileExt(dataType v1.DataType, methodName string, parameters map[string]string) string
- func IsDataCaptureFile(f *os.File) bool
- type Buffer
- type File
- func (f *File) Close() error
- func (f *File) Delete() error
- func (f *File) Flush() error
- func (f *File) GetPath() string
- func (f *File) ReadMetadata() *v1.DataCaptureMetadata
- func (f *File) ReadNext() (*v1.SensorData, error)
- func (f *File) Reset()
- func (f *File) Size() int64
- func (f *File) WriteNext(data *v1.SensorData) error
Constants ¶
const ( InProgressFileExt = ".prog" FileExt = ".capture" )
FileExt defines the file extension for Viam data capture files.
Variables ¶
var MaxFileSize = int64(64 * 1024)
MaxFileSize is the maximum size in bytes of a data capture file.
Functions ¶
func BuildCaptureMetadata ¶
func BuildCaptureMetadata(compType resource.Subtype, compName string, compModel resource.Model, method string, additionalParams map[string]string, tags []string, ) (*v1.DataCaptureMetadata, error)
BuildCaptureMetadata builds a DataCaptureMetadata object and returns error if additionalParams fails to convert to anypb map.
func GetAllReadings ¶ added in v0.2.9
func GetAllReadings(filePath string) ([]*v1.SensorData, error)
GetAllReadings returns all readings in the file at filePath.
func GetFileExt ¶ added in v0.0.9
GetFileExt gets the file extension for a capture file.
func IsDataCaptureFile ¶
IsDataCaptureFile returns whether or not f is a data capture file.
Types ¶
type Buffer ¶ added in v0.2.9
type Buffer struct { Directory string MetaData *v1.DataCaptureMetadata // contains filtered or unexported fields }
Buffer is a persistent queue of SensorData backed by a series of datacapture.Files.
func NewBuffer ¶ added in v0.2.9
func NewBuffer(dir string, md *v1.DataCaptureMetadata) *Buffer
NewBuffer returns a new Buffer.
func (*Buffer) Flush ¶ added in v0.2.9
Flush flushes all buffered data to disk and marks any in progress file as complete.
func (*Buffer) Write ¶ added in v0.2.9
func (b *Buffer) Write(item *v1.SensorData) error
Write writes item onto b. Binary sensor data is written to its own file. Tabular data is written to disk in MaxFileSize sized files. Files that are still being written to are indicated with the extension InProgressFileExt. Files that have finished being written to are indicated by FileExt.
type File ¶ added in v0.1.6
type File struct {
// contains filtered or unexported fields
}
File is the data structure containing data captured by collectors. It is backed by a file on disk containing length delimited protobuf messages, where the first message is the CaptureMetadata for the file, and ensuing messages contain the captured data.
func NewFile ¶ added in v0.1.6
func NewFile(dir string, md *v1.DataCaptureMetadata) (*File, error)
NewFile creates a new File with the specified md in the specified directory.
func ReadFile ¶ added in v0.1.6
ReadFile creates a File struct from a passed os.File previously constructed using NewFile.
func (*File) ReadMetadata ¶ added in v0.1.6
func (f *File) ReadMetadata() *v1.DataCaptureMetadata
ReadMetadata reads and returns the metadata in f.