mimo

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrReadingDataRow is returned when an error occurs while reading a data row.
	ErrReadingDataRow = errors.New("error while reading datarow")

	// ErrOrphanRow is returned when a original row does not have a masked version, or the other way around.
	ErrOrphanRow = errors.New("error datarow is orphan")
)

Functions

This section is empty.

Types

type ColumnConfig added in v0.2.0

type ColumnConfig struct {
	Exclude      []any        // exclude values from the masking rate computation (default: exclude only nil values)
	CoherentWith []string     // list of fields from witch the coherent rate is computed (default: the current field)
	Constraints  []Constraint // list of constraints to validate
}

func NewDefaultColumnConfig added in v0.2.0

func NewDefaultColumnConfig(columnname string) ColumnConfig

type Config added in v0.2.0

type Config struct {
	ColumnNames   []string
	ColumnConfigs map[string]ColumnConfig
}

func NewConfig added in v0.2.0

func NewConfig() Config

type Constraint added in v0.2.0

type Constraint struct {
	Target ConstraintTarget
	Type   ConstraintType
	Value  float64
}

type ConstraintTarget added in v0.2.0

type ConstraintTarget int
const (
	MaskingRate ConstraintTarget = iota
	CohenrentRate
	IdentifiantRate
)

type ConstraintType added in v0.2.0

type ConstraintType int
const (
	ShouldEqual ConstraintType = iota
	ShouldBeGreaterThan
	ShouldBeGreaterThanOrEqualTo
	ShouldBeLowerThan
	ShouldBeLessThanOrEqualTo
)

type DataRow

type DataRow map[string]any

type DataRowReader

type DataRowReader interface {
	ReadDataRow() (DataRow, error)
}

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

func NewDriver

func NewDriver(realReader DataRowReader, maskedReader DataRowReader, subs ...EventSubscriber) Driver

func (*Driver) Analyze

func (d *Driver) Analyze() (Report, error)

func (*Driver) Configure added in v0.2.0

func (d *Driver) Configure(c Config)

type EventSubscriber

type EventSubscriber interface {
	NewField(fieldname string)
	FirstNonMaskedValue(fieldname string, value any)
}

type Metrics

type Metrics struct {
	TotalCount  int64        // TotalCount is the number of values analyzed
	NilCount    int64        // NilCount is the number of null values in real data
	EmptyCount  int64        // EmptyCount is the number of empty values in real data (empty string or numbers at 0 value)
	MaskedCount int64        // MaskedCount is the number of non-blank real values masked
	Coherence   Multimap     // Coherence is a multimap used to compute the coherence rate
	Identifiant Multimap     // Identifiant is a multimap used to compute the identifiable rate
	Constraints []Constraint // Constraints is the set of rules to validate
}

func NewMetrics

func NewMetrics(constraints ...Constraint) Metrics

func (Metrics) BlankCount

func (m Metrics) BlankCount() int64

BlankCount is the number of blank (null or empty) values in real data.

func (Metrics) CoherenceRateValidate added in v0.2.0

func (m Metrics) CoherenceRateValidate() int

CoherenceRateValidate returns :

  • -1 if at least one constraint fail on the CoherenceRate,
  • 0 if no constraint exist on the CoherenceRate,
  • 1 if all constraints succeed on the CoherenceRate,

func (Metrics) IdentifiantRateValidate added in v0.2.0

func (m Metrics) IdentifiantRateValidate() int

IdentifiantRateValidate returns :

  • -1 if at least one constraint fail on the IdentifiantRate,
  • 0 if no constraint exist on the IdentifiantRate,
  • 1 if all constraints succeed on the IdentifiantRate,

func (Metrics) K

func (m Metrics) K() int

K is the minimum number of value pseudonym was attributed.

func (Metrics) MaskedRate

func (m Metrics) MaskedRate() float64

MaskedRate is equal to

Number of non-blank real values masked
  / (Number of values analyzed - Number of blank (null or empty) values in real data) ).

func (Metrics) MaskedRateValidate added in v0.2.0

func (m Metrics) MaskedRateValidate() int

MaskedRateValidate returns :

  • -1 if at least one constraint fail on the MaskedRate,
  • 0 if no constraint exist on the MaskedRate,
  • 1 if all constraints succeed on the MaskedRate,

func (Metrics) NonBlankCount

func (m Metrics) NonBlankCount() int64

NonBlankCount is the number of non-blank (non-null and non-empty) values in real data.

func (Metrics) NonMaskedCount

func (m Metrics) NonMaskedCount() int64

NonMaskedCount is the number of non-blank (non-null and non-empty) values in real data that were not masked.

func (*Metrics) Update

func (m *Metrics) Update(
	fieldname string,
	realValue any,
	maskedValue any,
	coherenceValue []any,
	subs Suscribers,
	config ColumnConfig,
) bool

func (Metrics) Validate added in v0.2.0

func (m Metrics) Validate() int

Validate returns :

  • -1 if at least one constraint fail,
  • 0 if no constraint exist,
  • 1 if all constraints succeed ,

type Multimap

type Multimap map[string]map[string]int

func (Multimap) Add

func (m Multimap) Add(key string, value string)

Add a key/value pair to the multimap.

func (Multimap) Count

func (m Multimap) Count(key string) int

Count the number of values associated to key.

func (Multimap) CountMin

func (m Multimap) CountMin() int

CountMin returns the minimum count of values associated to a key across the map.

func (Multimap) Rate

func (m Multimap) Rate() float64

Rate return the percentage of keys that have a count of 1.

type Report

type Report struct {
	Metrics map[string]Metrics
	// contains filtered or unexported fields
}

func NewReport

func NewReport(subs []EventSubscriber, config Config) Report

func (Report) ColumnMetric

func (r Report) ColumnMetric(colname string) Metrics

func (Report) Columns

func (r Report) Columns() []string

func (Report) Update

func (r Report) Update(realRow DataRow, maskedRow DataRow)

type Suscribers

type Suscribers []EventSubscriber

func (Suscribers) PostFirstNonMaskedValue

func (subs Suscribers) PostFirstNonMaskedValue(fieldname string, value any)

func (Suscribers) PostNewField

func (subs Suscribers) PostNewField(fieldname string)

Jump to

Keyboard shortcuts

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