index

package
v1.0.1-0...-fed4e36 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package index contains files responsible for maintaining the database document index

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveReferences

func ResolveReferences(jsonVal interface{}, depthLeft int) interface{}

ResolveReferences tries to find key references and if found, replace the references with their corresponding value

Types

type File

type File struct {
	FileName string
	// contains filtered or unexported fields
}

File stores the filename as well as a read-write mutex

func (*File) Delete

func (f *File) Delete() error

Delete tries to remove the file

func (*File) GetByteArray

func (f *File) GetByteArray() ([]byte, error)

GetByteArray returns the byte array of given file

func (*File) ReplaceContent

func (f *File) ReplaceContent(str string) error

ReplaceContent changes the contents of file f to be str

func (*File) ResolvePath

func (f *File) ResolvePath() string

ResolvePath returns a string representing the path to file

func (*File) ToMap

func (f *File) ToMap() (res map[string]interface{}, err error)

type FileIndex

type FileIndex struct {
	FileSystem af.Fs
	// contains filtered or unexported fields
}

FileIndex is holds the actual index mapping for keys to files

var I *FileIndex

I is the global database index which keeps track of which files are where

func NewFileIndex

func NewFileIndex(dir string) *FileIndex

NewFileIndex returns a reference to a new file index

func (*FileIndex) Delete

func (i *FileIndex) Delete(file *File) error

Delete deletes the given file and then removes it from I

func (*FileIndex) List

func (i *FileIndex) List() (res []string)

List returns all keys in database

func (*FileIndex) Lookup

func (i *FileIndex) Lookup(key string) (*File, bool)

Lookup returns the file with that key Returns (File, true) if file exists otherwise, returns new File, false

func (*FileIndex) Put

func (i *FileIndex) Put(file *File, bytes []byte) error

Put creates/updates file in the fileindex

func (*FileIndex) Regenerate

func (i *FileIndex) Regenerate()

Regenerate rebuilds the current file index from current directory by crawling it for any .json files

func (*FileIndex) RegenerateNew

func (i *FileIndex) RegenerateNew(dir string)

RegenerateNew rebuilds the file index at a new given directory

func (*FileIndex) SetFileSystem

func (i *FileIndex) SetFileSystem(fs af.Fs)

SetFileSystem sets the file system for the given FileIndex

Jump to

Keyboard shortcuts

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