mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-03 03:10:26 -05:00
3d9ebdf61e
It turns out that many large chunks are quite compressible, and writing smaller chunks to DynamoDB saves time, and allows more headroom before hitting the provisioned capacity on the backing table. Compressed chunks are tagged with the algorithm used to compress them, though we treat untagged chunks as uncompressed for backward compatibility.
34 lines
916 B
Go
34 lines
916 B
Go
package csv
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/attic-labs/noms/types"
|
|
)
|
|
|
|
// KindSlice is an alias for []types.NomsKind. It's needed because types.NomsKind are really just 8 bit unsigned ints, which are what Go uses to represent 'byte', and this confuses the Go JSON marshal/unmarshal code -- it treats them as byte arrays and base64 encodes them!
|
|
type KindSlice []types.NomsKind
|
|
|
|
func (ks KindSlice) MarshalJSON() ([]byte, error) {
|
|
elems := make([]string, len(ks))
|
|
for i, k := range ks {
|
|
elems[i] = fmt.Sprintf("%d", k)
|
|
}
|
|
return []byte("[" + strings.Join(elems, ",") + "]"), nil
|
|
}
|
|
|
|
func (ks *KindSlice) UnmarshalJSON(value []byte) error {
|
|
elems := strings.Split(string(value[1:len(value)-1]), ",")
|
|
*ks = make(KindSlice, len(elems))
|
|
for i, e := range elems {
|
|
ival, err := strconv.ParseUint(e, 10, 8)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
(*ks)[i] = types.NomsKind(ival)
|
|
}
|
|
return nil
|
|
}
|