digest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Separator = ","

Separator for CSV. Not configurable for now.

Variables

This section is empty.

Functions

func Compare

func Compare(baseDigest, newDigest map[uint64]uint64) (additions []uint64, modifications []uint64)

Compare compares two Digest maps and returns the additions and modification keys as arrays.

func Create

func Create(config *Config) (map[uint64]uint64, map[uint64]string, error)

Create can create a Digest using the Configurations passed. It returns the digest as a map[uint64]uint64. It can also keep track of the Source line.

Types

type Config

type Config struct {
	KeyPositions []int
	Key          Positions
	Value        Positions
	Reader       io.Reader
	Writer       io.Writer
	SourceMap    bool
}

Config represents configurations that can be passed to create a Digest.

func NewConfig

func NewConfig(r io.Reader, createSourceMap bool, primaryKey Positions, valueColumns Positions) *Config

NewConfig creates an instance of Config struct.

type Digest

type Digest struct {
	Key   uint64
	Value uint64
	Row   string
}

Digest represents the binding of the key of each csv line and the digest that gets created for the entire line

func CreateDigest

func CreateDigest(csv []string, pKey Positions, pRow Positions) Digest

CreateDigest creates a Digest for each line of csv. There will be one Digest per line

type Positions

type Positions []int

Positions represents positions of columns in a CSV array.

func (Positions) Items

func (p Positions) Items() []int

Items returns the elements of the Positions array as an array of int

func (Positions) Length

func (p Positions) Length() int

Length returns the size of the Positions array.

func (Positions) MapToValue

func (p Positions) MapToValue(csv []string) string

MapToValue plucks the values from CSV from their respective positions and concatenates them using Separator as a string.

Jump to

Keyboard shortcuts

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