Documentation
¶
Index ¶
- func ValidateQueryConfigs(configs []QueryConfig) error
- type And
- type Config
- type DB
- type Difference
- type HasRating
- type HasTag
- type NamedQuery
- type Or
- type Photo
- type Query
- type QueryConfig
- type RelationalOperator
- type Selector
- type SelectorConfig
- type SelectorProperty
- type SelectorPropertyMap
- type SelectorVisitor
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateQueryConfigs ¶ added in v0.2.0
func ValidateQueryConfigs(configs []QueryConfig) error
Types ¶
type And ¶
type And struct {
Operands []Selector
}
And is a selector for selecting photos that meet ALL of the specified sub selectors.
func (And) Accept ¶
func (s And) Accept(v SelectorVisitor) (interface{}, error)
type Config ¶ added in v0.2.0
type Config struct { MountPoint string `json:"mountPoint,omitempty"` DB DB `json:"db"` LogLevel string `json:"logLevel,omitempty"` Queries []QueryConfig `json:"queries,omitempty"` }
type Difference ¶
Difference is a selector that selects all of the photos that match Starting selector except for any photos that match the Excluding selector.
func (Difference) Accept ¶
func (s Difference) Accept(v SelectorVisitor) (interface{}, error)
type HasRating ¶ added in v0.2.0
type HasRating struct { Operator RelationalOperator Rating float64 }
HasRating is a selector for selecting photos that have a specific rating
More generally speaking HasRating can use any comparison operator, so for example we can select photos that have a rating greater than or equal to 4
func (HasRating) Accept ¶ added in v0.2.0
func (s HasRating) Accept(v SelectorVisitor) (interface{}, error)
type HasTag ¶
type HasTag struct {
Tag Tag
}
HasTag is a Selector for selecting photos that have a specific tag.
func (HasTag) Accept ¶
func (s HasTag) Accept(v SelectorVisitor) (interface{}, error)
type NamedQuery ¶ added in v0.2.0
func ConfigToQuery ¶ added in v0.2.0
func ConfigToQuery(config QueryConfig) (NamedQuery, error)
ConfigToQuery takes a QueryConfig and transforms it into a NamedQuery.
Ideally we would just directly deserialize the JSON into a NamedQuery object, however the fact that the NamedQuery has a Selector which is an interface makes this a little more complicated. Go json.Unmarshal doesn't support deserializing JSON into the correct interface type because for a given blob of JSON json.Unmarshal doesn't know what struct that fulfils that interface it should deserialize it into. I could do this by making Query implement the json.Unmarshaler interface, but then all the selectors that can have children selectors also need to implement the json.Unmarshaler interface. So it just seemed easier in the long run to declare a few custom struct that can handle any selector AND that json.Unmarshal can handle for me. Then I just need to implement that transform to the actual query. Not sure if this all payed off, perhaps I should just suck it up and implement json.Unmarshaler. But it works, so I am going to leave it as is for now.
func ConfigsToQueries ¶ added in v0.2.0
func ConfigsToQueries(configs []QueryConfig) ([]NamedQuery, error)
type Or ¶
type Or struct {
Operands []Selector
}
And is a selector for selecting photos that meet ANY of the specified sub selectors.
func (Or) Accept ¶
func (s Or) Accept(v SelectorVisitor) (interface{}, error)
type Photo ¶
type Photo struct { // Absolute path to the photo Path string // ID should be a unique ID to all photos in that may be returned by a photo // database. // // The purpose of this ID is that frequently in photo libraries there can be // multiple photos with the same names, but since we are flattening multiple // directory hierarchies into a single folder it leaves the real possibility // of name collisions. This means we need a unique identifier to be used for // photos so that even if photos are named the same thing in the folder they // exist in we can give them a unique name in the tag folder we are // flattening the photos into. // // As such this ID will be used for the name of the FUSE file system. // // Note that care must be given for this ID to actually be unique. In my // initial implementation I was using the Digikam uniqueHash, which is a md5 // hash of the first and last 100 kb of the photo ( // https://github.com/KDE/digikam/blob/33d0457e20adda97c003f3dee652a1749406ff9f/core/libs/dimg/loaders/dimgloader.cpp#L333 // ). This means that if a photo is copied somewhere we can have two files // with the same hash. In this case we will just ignore once of the results, // since both photos are the same it is ok to drop one of them from the // results, so we sort of have a nice built in duplicate detection and // rejection. We could instead use the photo ID, but for some reason I // prefer using the md5 hash based naming since it is a nice stable way of // identifying an photo even if it moves around in a way that can't be // detected by the digikam DB. ID string }
func (Photo) UniqueStableName ¶
UniqueStableName generates a unique and stable name for a photo using the unique ID provided by the DB.
type Query ¶
type Query struct {
Selector Selector
}
Query represents the query for photos within our database.
type QueryConfig ¶ added in v0.2.0
type QueryConfig struct { Name string `json:"name,omitempty"` Selector SelectorConfig `json:"selector"` }
type RelationalOperator ¶ added in v0.2.0
type RelationalOperator string
const ( Equal RelationalOperator = "==" NotEqual RelationalOperator = "!=" LessThan RelationalOperator = "<" LessThanOrEqual RelationalOperator = "<=" GreaterThan RelationalOperator = ">" GreaterThanOrEqual RelationalOperator = ">=" )
func (RelationalOperator) Validate ¶ added in v0.2.0
func (ro RelationalOperator) Validate() error
type Selector ¶
type Selector interface { // In order to support efficient conversion of a Selector into whatever // internal query representation our database needs to use we use a visitor // pattern that can accept a visitor and produce any sort of IR that database // needs to use. Accept(v SelectorVisitor) (interface{}, error) }
Selector represents a method of selecting specific photos within our database.
type SelectorConfig ¶ added in v0.2.0
type SelectorConfig struct { Type string `json:"type,omitempty"` Properties SelectorPropertyMap `json:"properties,omitempty"` }
type SelectorProperty ¶ added in v0.2.0
type SelectorProperty struct { Number float64 `json:"number,omitempty"` Strings []string `json:"strings,omitempty"` String string `json:"string,omitempty"` Selectors []SelectorConfig `json:"selectors,omitempty"` Selector *SelectorConfig `json:"selector,omitempty"` }
type SelectorPropertyMap ¶ added in v0.2.0
type SelectorPropertyMap map[string]SelectorProperty