From: Peter Amstutz Date: Thu, 9 Feb 2017 19:11:35 +0000 (-0500) Subject: 9397: Remove conflicting code for easier merge X-Git-Tag: 1.1.0~427^2~6 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/310f7b0266f012355e38f3296bc6defe14a3d25f?hp=ef934e66fee76dcf760dd5fc835f27127e4cc791 9397: Remove conflicting code for easier merge --- diff --git a/sdk/go/manifest/manifest.go b/sdk/go/manifest/manifest.go index a9745ae7cd..ff104aacd7 100644 --- a/sdk/go/manifest/manifest.go +++ b/sdk/go/manifest/manifest.go @@ -230,103 +230,6 @@ func parseManifestStream(s string) (m ManifestStream) { return } -func (m *Manifest) NormalizeManifest() map[string]ManifestStream { - streams := make(map[string]ManifestStream) - - for stream := range m.StreamIter() { - ms := streams[stream.StreamName] - - if ms.StreamName == "" { // new stream - streams[stream.StreamName] = stream - } else { - ms.Blocks = append(ms.Blocks, stream.Blocks...) - ms.FileStreamSegments = append(ms.FileStreamSegments, stream.FileStreamSegments...) - } - } - - return streams -} - -func (m *Manifest) NormalizedManifestForPath(path string) string { - normalized := m.NormalizeManifest() - - var streams []string - for _, stream := range normalized { - streams = append(streams, stream.StreamName) - } - sort.Strings(streams) - - path = strings.Trim(path, "/") - var subdir, filename string - - if path != "" { - if strings.Index(path, "/") == -1 { - isStream := false - for _, v := range streams { - if v == "./"+path { - isStream = true - } - } - if isStream { - subdir = path - } else { - filename = path - } - } else { - pathIdx := strings.LastIndex(path, "/") - if pathIdx >= 0 { - subdir = path[0:pathIdx] - filename = path[pathIdx+1:] - } - } - } - - manifestForPath := "" - - for _, streamName := range streams { - stream := normalized[streamName] - - if subdir != "" && stream.StreamName != "./"+subdir { - continue - } - - manifestForPath += stream.StreamName + " " + strings.Join(stream.Blocks, " ") + " " - - currentName := "" - currentSpan := []uint64{0, 0} - for _, fss := range stream.FileStreamSegments { - if filename != "" && fss.Name != filename { - continue - } - - if fss.Name != currentName && currentName != "" { - manifestForPath += fmt.Sprintf("%v", currentSpan[0]) + ":" + fmt.Sprintf("%v", currentSpan[1]) + ":" + currentName + " " - } - - if fss.Name != currentName { - currentName = fss.Name - currentSpan = []uint64{0, 0} - } - - if currentSpan[1] == 0 { - currentSpan = []uint64{fss.SegPos, fss.SegLen} - } else { - if currentSpan[1] == fss.SegPos { - currentSpan[1] += fss.SegLen - } else if currentSpan[0]+currentSpan[1] == fss.SegPos { - currentSpan[1] = fss.SegPos + fss.SegLen - } else { - manifestForPath += fmt.Sprintf("%v", currentSpan[0]) + ":" + fmt.Sprintf("%v", currentSpan[1]+fss.SegLen) + ":" + fss.Name + " " - currentSpan = []uint64{fss.SegPos, fss.SegPos + fss.SegLen} - } - } - } - manifestForPath += fmt.Sprintf("%v", currentSpan[0]) + ":" + fmt.Sprintf("%v", currentSpan[1]) + ":" + currentName + "\n" - } - - return manifestForPath -} - func (m *Manifest) StreamIter() <-chan ManifestStream { ch := make(chan ManifestStream) go func(input string) { diff --git a/sdk/go/manifest/manifest_test.go b/sdk/go/manifest/manifest_test.go index 0d58a9ec11..2fe427224e 100644 --- a/sdk/go/manifest/manifest_test.go +++ b/sdk/go/manifest/manifest_test.go @@ -251,9 +251,3 @@ func TestBlockIterWithBadManifest(t *testing.T) { } } } - -func TestNormalizeManifest(t *testing.T) { - m := Manifest{Text: ". acbd18db4cc2f85cedef654fccc4a4d8+40 0:10:one 10:10:one 20:10:two 30:10:two\n"} - normalized := m.NormalizedManifestForPath("") - expectEqual(t, normalized, ". acbd18db4cc2f85cedef654fccc4a4d8+40 0:20:one 20:40:two\n") -}