-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.go
More file actions
75 lines (59 loc) · 1.96 KB
/
Copy pathinfo.go
File metadata and controls
75 lines (59 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (C) 2022 CGI France
//
// This file is part of SIGO.
//
// SIGO is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// SIGO is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SIGO. If not, see <http://www.gnu.org/licenses/>.
package sigo
func NewSequenceDebugger(key string) SequenceDebugger { return SequenceDebugger{map[string]int{}, key} }
type SequenceDebugger struct {
cache map[string]int
key string
}
type InfosRecord struct {
original Record
infos map[string]interface{}
}
func (ir InfosRecord) QuasiIdentifer() ([]float64, error) {
return ir.original.QuasiIdentifer()
}
func (ir InfosRecord) Sensitives() []interface{} {
return ir.original.Sensitives()
}
func (ir InfosRecord) Row() map[string]interface{} {
original := ir.original.Row()
for k, v := range ir.infos {
original[k] = v
}
return original
}
// id returns the path of cluster c coverts to integer.
func (d SequenceDebugger) id(c Cluster) int {
count := len(d.cache)
if d.cache[c.ID()] == 0 {
d.cache[c.ID()] = count + 1
}
return d.cache[c.ID()]
}
// Information returns an InfosRecord which is a record
// with the identifier of the cluster in which the record rec is located.
func (d SequenceDebugger) Information(rec Record, cluster Cluster) Record {
infos := make(map[string]interface{})
infos[d.key] = d.id(cluster)
return InfosRecord{original: rec, infos: infos}
}
func NewNoDebugger() Debugger { return NoDebugger{} }
type NoDebugger struct{}
func (d NoDebugger) Information(rec Record, cluster Cluster) Record {
return rec
}