/* Deals with parsing Manifest Text. */
// Inspired by the Manifest class in arvados/sdk/ruby/lib/arvados/keep.rb
/* Deals with parsing Manifest Text. */
// Inspired by the Manifest class in arvados/sdk/ruby/lib/arvados/keep.rb
-func firstBlock(offsets []uint64, range_start uint64) int {
- // range_start/block_start is the inclusive lower bound
- // range_end/block_end is the exclusive upper bound
+func firstBlock(offsets []uint64, rangeStart uint64) int {
+ // rangeStart/blockStart is the inclusive lower bound
+ // rangeEnd/blockEnd is the exclusive upper bound
sortedfiles = append(sortedfiles, k)
}
sort.Strings(sortedfiles)
sortedfiles = append(sortedfiles, k)
}
sort.Strings(sortedfiles)
for _, segment := range stream[streamfile] {
b, _ := ParseBlockLocator(segment.Locator)
if _, ok := blocks[b.Digest]; !ok {
for _, segment := range stream[streamfile] {
b, _ := ParseBlockLocator(segment.Locator)
if _, ok := blocks[b.Digest]; !ok {
- if len(stream_tokens) == 1 {
- stream_tokens = append(stream_tokens, "d41d8cd98f00b204e9800998ecf8427e+0")
+ if len(streamTokens) == 1 {
+ streamTokens = append(streamTokens, "d41d8cd98f00b204e9800998ecf8427e+0")
fout := EscapeName(streamfile)
for _, segment := range stream[streamfile] {
// Collapse adjacent segments
b, _ := ParseBlockLocator(segment.Locator)
streamoffset = blocks[b.Digest] + int64(segment.Offset)
fout := EscapeName(streamfile)
for _, segment := range stream[streamfile] {
// Collapse adjacent segments
b, _ := ParseBlockLocator(segment.Locator)
streamoffset = blocks[b.Digest] + int64(segment.Offset)
- stream_tokens = append(stream_tokens, fmt.Sprintf("%d:%d:%s", span_start, span_end-span_start, fout))
- span_start = streamoffset
- span_end = streamoffset + int64(segment.Len)
+ streamTokens = append(streamTokens, fmt.Sprintf("%d:%d:%s", spanStart, spanEnd-spanStart, fout))
+ spanStart = streamoffset
+ spanEnd = streamoffset + int64(segment.Len)
- if span_start != -1 {
- stream_tokens = append(stream_tokens, fmt.Sprintf("%d:%d:%s", span_start, span_end-span_start, fout))
+ if spanStart != -1 {
+ streamTokens = append(streamTokens, fmt.Sprintf("%d:%d:%s", spanStart, spanEnd-spanStart, fout))
filesegs, okfile := stream[filename]
if okfile {
newstream := make(segmentedStream)
filesegs, okfile := stream[filename]
if okfile {
newstream := make(segmentedStream)
- relocate_stream, relocate_filename := splitPath(relocate)
- if relocate_filename == "" {
- relocate_filename = filename
+ relocateStream, relocateFilename := splitPath(relocate)
+ if relocateFilename == "" {
+ relocateFilename = filename
sortedstreams = append(sortedstreams, k)
}
sort.Strings(sortedstreams)
sortedstreams = append(sortedstreams, k)
}
sort.Strings(sortedstreams)
//
// If 'srcpath' points to a single file, it will return manifest text for just that file.
// The value of "relocate" is can be used to rename the file or set the file stream.
//
//
// If 'srcpath' points to a single file, it will return manifest text for just that file.
// The value of "relocate" is can be used to rename the file or set the file stream.
//
-// Extract("./foo", ".") // extract file "foo" and put it in stream "."
-// Extract("./foo", "./bar") // extract file "foo", rename it to "bar" in stream "."
-// Extract("./foo", "./bar/") // extract file "foo", rename it to "./bar/foo"
-// Extract("./foo", "./bar/baz") // extract file "foo", rename it to "./bar/baz")
+// Extract("./foo", ".") // extract file "foo" and put it in stream "."
+// Extract("./foo", "./bar") // extract file "foo", rename it to "bar" in stream "."
+// Extract("./foo", "./bar/") // extract file "foo", rename it to "./bar/foo"
+// Extract("./foo", "./bar/baz") // extract file "foo", rename it to "./bar/baz")
//
// Otherwise it will return the manifest text for all streams with the prefix in "srcpath" and place
// them under the path in "relocate".
//
//
// Otherwise it will return the manifest text for all streams with the prefix in "srcpath" and place
// them under the path in "relocate".
//
-// Extract("./stream", ".") // extract "./stream" to "." and "./stream/subdir" to "./subdir")
-// Extract("./stream", "./bar") // extract "./stream" to "./bar" and "./stream/subdir" to "./bar/subdir")
+// Extract("./stream", ".") // extract "./stream" to "." and "./stream/subdir" to "./subdir")
+// Extract("./stream", "./bar") // extract "./stream" to "./bar" and "./stream/subdir" to "./bar/subdir")
func (m Manifest) Extract(srcpath, relocate string) (ret Manifest) {
segmented, err := m.segment()
if err != nil {
func (m Manifest) Extract(srcpath, relocate string) (ret Manifest) {
segmented, err := m.segment()
if err != nil {
// Blocks may appear multiple times within the same manifest if they
// are used by multiple files. In that case this Iterator will output
// the same block multiple times.
// Blocks may appear multiple times within the same manifest if they
// are used by multiple files. In that case this Iterator will output
// the same block multiple times.