aboutsummaryrefslogtreecommitdiffstats
path: root/skate
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-04-26 18:39:55 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-04-26 18:39:55 +0200
commitf4d0387f9ec190caab96b952762bc999d1ad63aa (patch)
treea906f4ce10e7f6b7a9e35cfd9a5b3c683b54cb52 /skate
parentfaea941faff358802a8950af54d05ac88264b8f3 (diff)
downloadrefcat-f4d0387f9ec190caab96b952762bc999d1ad63aa.tar.gz
refcat-f4d0387f9ec190caab96b952762bc999d1ad63aa.zip
rename FieldMapper to Mapper
In our context, we are for now only mapping a blob to a number of fields.
Diffstat (limited to 'skate')
-rw-r--r--skate/cmd/skate-map/main.go2
-rw-r--r--skate/map.go8
2 files changed, 5 insertions, 5 deletions
diff --git a/skate/cmd/skate-map/main.go b/skate/cmd/skate-map/main.go
index e72cc0c..ffe1017 100644
--- a/skate/cmd/skate-map/main.go
+++ b/skate/cmd/skate-map/main.go
@@ -25,7 +25,7 @@ var (
func main() {
flag.Parse()
// XXX: introduce prefixes
- availableMappers := map[string]skate.FieldMapper{
+ availableMappers := map[string]skate.Mapper{
"id": skate.Identity,
"ff": skate.CreateFixedMapper(*extraValue),
"title": skate.MapperTitle,
diff --git a/skate/map.go b/skate/map.go
index 9cad1e4..2cb4ebc 100644
--- a/skate/map.go
+++ b/skate/map.go
@@ -31,13 +31,13 @@ type PartialDoc struct {
Year string `json:"release_year"`
}
-// FieldMapper maps a blob to an arbitrary number of fields, e.g. for (key,
+// Mapper maps a blob to an arbitrary number of fields, e.g. for (key,
// doc). We want fields, but we do not want to bake in TSV into each function.
-type FieldMapper func([]byte) ([][]byte, error)
+type Mapper func([]byte) ([][]byte, error)
// TSV serialized the result of a field mapper as TSV. This is a slim adapter,
// e.g. to parallel.Processor, which expects this function signature.
-func (f FieldMapper) TSV(p []byte) ([]byte, error) {
+func (f Mapper) TSV(p []byte) ([]byte, error) {
fields, err := f(p)
if err != nil {
return nil, err
@@ -63,7 +63,7 @@ func Identity(p []byte) ([][]byte, error) {
// CreateFixedMapper extract the value from a given fixed top level json key.
// Returns a function that maps doc to (v, doc).
-func CreateFixedMapper(field string) FieldMapper {
+func CreateFixedMapper(field string) Mapper {
f := func(p []byte) ([][]byte, error) {
var (
doc map[string]interface{}