mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-21 19:39:04 -05:00
noms cat fixes
This commit is contained in:
@@ -23,9 +23,9 @@ package chunks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/liquidata-inc/dolt/go/store/constants"
|
||||
"sync"
|
||||
|
||||
"github.com/liquidata-inc/dolt/go/store/constants"
|
||||
"github.com/liquidata-inc/dolt/go/store/d"
|
||||
"github.com/liquidata-inc/dolt/go/store/hash"
|
||||
)
|
||||
@@ -39,12 +39,18 @@ type MemoryStorage struct {
|
||||
data map[hash.Hash]Chunk
|
||||
rootHash hash.Hash
|
||||
mu sync.RWMutex
|
||||
version string
|
||||
}
|
||||
|
||||
// NewView vends a MemoryStoreView backed by this MemoryStorage. It's
|
||||
// initialized with the currently "persisted" root.
|
||||
func (ms *MemoryStorage) NewView() ChunkStore {
|
||||
return &MemoryStoreView{storage: ms, rootHash: ms.rootHash}
|
||||
version := ms.version
|
||||
if version == "" {
|
||||
version = constants.FormatDefaultString
|
||||
}
|
||||
|
||||
return &MemoryStoreView{storage: ms, rootHash: ms.rootHash, version: version}
|
||||
}
|
||||
|
||||
// Get retrieves the Chunk with the Hash h, returning EmptyChunk if it's not
|
||||
@@ -109,6 +115,7 @@ type MemoryStoreView struct {
|
||||
pending map[hash.Hash]Chunk
|
||||
rootHash hash.Hash
|
||||
mu sync.RWMutex
|
||||
version string
|
||||
|
||||
storage *MemoryStorage
|
||||
}
|
||||
@@ -177,7 +184,7 @@ func (ms *MemoryStoreView) HasMany(ctx context.Context, hashes hash.HashSet) (ha
|
||||
}
|
||||
|
||||
func (ms *MemoryStoreView) Version() string {
|
||||
return constants.NomsVersion
|
||||
return ms.version
|
||||
}
|
||||
|
||||
func (ms *MemoryStoreView) Put(ctx context.Context, c Chunk) error {
|
||||
|
||||
@@ -159,9 +159,6 @@ func runCat(ctx context.Context, args []string) int {
|
||||
//Want a clean db every loop
|
||||
sp, _ := spec.ForDatabase("mem")
|
||||
db := sp.GetDatabase(ctx)
|
||||
value, err := types.DecodeValue(chunk, db)
|
||||
|
||||
d.PanicIfError(err)
|
||||
|
||||
fmt.Printf(" chunk[%d].raw.len: %d\n", cidx, len(currCD.compressed))
|
||||
|
||||
@@ -179,12 +176,32 @@ func runCat(ctx context.Context, args []string) int {
|
||||
}
|
||||
|
||||
if !catNoShow {
|
||||
value, err := types.DecodeValue(chunk, db)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(" error reading value (Could be a format issue).")
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf(" chunk[%d].value.kind: %s\n", cidx, value.Kind())
|
||||
fmt.Printf(" chunk[%d].value:\n\n", cidx)
|
||||
printValue(ctx, os.Stdout, value, filepath.Dir(chunkFile)+"::#"+b32Hash)
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
refIdx := 0
|
||||
err = types.WalkRefs(chunk, db.Format(), func(ref types.Ref) error {
|
||||
if refIdx == 0 {
|
||||
fmt.Printf(" chunk[%d] references chunks:\n", cidx)
|
||||
}
|
||||
|
||||
fmt.Printf(" Ref Hash: %s\n", ref.TargetHash().String())
|
||||
refIdx++
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
d.PanicIfError(err)
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
@@ -289,6 +306,7 @@ func parseChunks(bytes []byte, pos int, sizes []int) (int, []chunkData) {
|
||||
var cd []chunkData
|
||||
for i := len(sizes) - 1; i >= 0; i-- {
|
||||
uncompressed, err := snappy.Decode(nil, chunkBytes[i])
|
||||
d.PanicIfError(err)
|
||||
|
||||
cd = append(cd, chunkData{
|
||||
compressed: chunkBytes[i],
|
||||
|
||||
Reference in New Issue
Block a user