diff options
Diffstat (limited to 'skate/map.go')
-rw-r--r-- | skate/map.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/skate/map.go b/skate/map.go index 1a8feef..ef9c018 100644 --- a/skate/map.go +++ b/skate/map.go @@ -44,6 +44,17 @@ type PartialRef struct { Year string `json:"release_year"` } +// cdxSummary is an ad-hoc CDX summary format, created currently by skate-cdx-lookup. +type cdxSummary struct { + Line string `json:"line"` + NumRows int64 `json:"numRows"` + Summary struct { + Delta int64 `json:"delta"` + Last string `json:"last"` + Ok string `json:"ok"` + } `json:"summary"` +} + // 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 Mapper func([]byte) ([][]byte, error) @@ -316,6 +327,16 @@ func MapperOpenLibraryReleaseNormalizedISBN(p []byte) (fields [][]byte, err erro return [][]byte{key, p}, nil } +func MapperCdxSummary(p []byte) (fields [][]byte, err error) { + var ( + cdx cdxSummary + ) + if err := json.Unmarshal(p, &cdx); err != nil { + return nil, err + } + return [][]byte{[]byte(cdx.Line), p}, nil +} + // MapperPartial works on partial documents. func MapperPartial(p []byte) (fields [][]byte, err error) { // TODO: Group by some normlized container name or identifier. |