/
wanted_lso.go
92 lines (83 loc) · 2.12 KB
/
wanted_lso.go
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Package xs contains most of the supported eXtended actions (xactions) with some
// exceptions that include certain storage services (mirror, EC) and extensions (downloader, lru).
/*
* Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
*/
package xs
import (
"fmt"
"github.com/NVIDIA/aistore/api/apc"
"github.com/NVIDIA/aistore/cmn"
"github.com/NVIDIA/aistore/cmn/cos"
"github.com/NVIDIA/aistore/cmn/debug"
"github.com/NVIDIA/aistore/core"
)
// `apc.LsoMsg` flags
var (
allmap map[string]cos.BitFlags
)
func init() {
allmap = make(map[string]cos.BitFlags, len(apc.GetPropsAll))
for i, n := range apc.GetPropsAll {
allmap[n] = cos.BitFlags(1) << i
}
}
func wanted(msg *apc.LsoMsg) (flags cos.BitFlags) {
for prop, fl := range allmap {
if msg.WantProp(prop) {
flags = flags.Set(fl)
}
}
return
}
func (wi *walkInfo) setWanted(e *cmn.LsoEntry, lom *core.LOM) {
var (
custom = e.Custom
version = e.Version
)
for name, fl := range allmap {
if !wi.wanted.IsSet(fl) {
continue
}
switch name {
case apc.GetPropsName:
case apc.GetPropsStatus:
case apc.GetPropsCached: // via obj.SetPresent()
case apc.GetPropsSize:
if e.Size > 0 && lom.SizeBytes() != e.Size {
e.SetVerChanged()
}
e.Size = lom.SizeBytes()
case apc.GetPropsVersion:
e.Version = lom.Version()
case apc.GetPropsChecksum:
e.Checksum = lom.Checksum().Value()
case apc.GetPropsAtime:
e.Atime = cos.FormatNanoTime(lom.AtimeUnix(), wi.msg.TimeFormat)
case apc.GetPropsLocation:
e.Location = lom.Location()
case apc.GetPropsCopies:
e.Copies = int16(lom.NumCopies())
case apc.GetPropsEC:
// TODO?: risk of significant slow-down loading EC metafiles
case apc.GetPropsCustom:
if md := lom.GetCustomMD(); len(md) > 0 {
e.Custom = fmt.Sprintf("%+v", md)
}
default:
debug.Assert(false, name)
}
}
if wi.msg.IsFlagSet(apc.LsVerChanged) && !e.IsVerChanged() {
// slow path: extensive version-changed check
md := cmn.S2CustomMD(custom, version)
if len(md) > 0 {
var oa cmn.ObjAttrs
oa.CustomMD = md
oa.Size = e.Size
if !lom.Equal(&oa) {
e.SetVerChanged()
}
}
}
}