MimirAnalytics.Mapper behaviour (mimir_analytics v0.8.1)

Copy Markdown View Source

Shared ingest behaviour for session, evaluation and gateway files. Summaries count rows by table; already-ingested and rejected contents return their corresponding status atoms.

Summary

Types

A decoded-JSON boundary value: Jason.decode!/1 output, before any Row.*.new/1 coercion. Mappers narrow this to typed Row.t() structs at the edge; nothing past that boundary should carry a bare source map.

Rows written per table this ingest touched, keyed by table name.

Callbacks

Ingest one source file (or, for mappers that accept directories, a directory of them) into store. Idempotent by file contents: re-ingesting contents the ledger already holds, under any name, returns :already_ingested without touching the store. A mapper that records rejections returns :already_rejected for contents it rejected before.

Types

source_map()

@type source_map() :: %{optional(String.t()) => term()}

A decoded-JSON boundary value: Jason.decode!/1 output, before any Row.*.new/1 coercion. Mappers narrow this to typed Row.t() structs at the edge; nothing past that boundary should carry a bare source map.

summary()

@type summary() :: %{rows: %{required(String.t()) => non_neg_integer()}}

Rows written per table this ingest touched, keyed by table name.

Callbacks

ingest(store, path_or_dir)

@callback ingest(store :: MimirAnalytics.Store.t(), path_or_dir :: Path.t()) ::
  {:ok, summary()} | :already_ingested | :already_rejected | {:error, term()}

Ingest one source file (or, for mappers that accept directories, a directory of them) into store. Idempotent by file contents: re-ingesting contents the ledger already holds, under any name, returns :already_ingested without touching the store. A mapper that records rejections returns :already_rejected for contents it rejected before.