1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
12 // BlockSegment is a portion of a block stored in Keep. It is used in
13 // the replace_segments API.
14 type BlockSegment struct {
20 func (bs *BlockSegment) UnmarshalJSON(data []byte) error {
22 if err := json.Unmarshal(data, &s); err != nil {
25 _, err := fmt.Sscanf(s, "%s %d %d", &bs.Locator, &bs.Offset, &bs.Length)
29 // MarshalText enables encoding/json to use BlockSegment as a map key.
30 func (bs BlockSegment) MarshalText() ([]byte, error) {
31 return []byte(fmt.Sprintf("%s %d %d", bs.Locator, bs.Offset, bs.Length)), nil
34 func (bs BlockSegment) StripAllHints() BlockSegment {
35 bs.Locator = stripAllHints(bs.Locator)