From a61d735d54d077b24823f7ff70cc5736905733bc Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Fri, 9 Aug 2019 15:21:44 +1000 Subject: [PATCH] Re-order rac.ChunkWriter.AddChunk args --- lib/rac/chunk_writer.go | 4 ++-- lib/rac/example_test.go | 4 ++-- lib/rac/rac_test.go | 12 ++++++------ lib/rac/writer.go | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/rac/chunk_writer.go b/lib/rac/chunk_writer.go index 73eeee95..8e43c50f 100644 --- a/lib/rac/chunk_writer.go +++ b/lib/rac/chunk_writer.go @@ -343,8 +343,8 @@ func (w *ChunkWriter) AddResource(resource []byte) (OptResource, error) { // // The caller may modify primary's contents after this method returns. func (w *ChunkWriter) AddChunk( - dRangeSize uint64, primary []byte, - secondary OptResource, tertiary OptResource, codec Codec) error { + dRangeSize uint64, codec Codec, primary []byte, + secondary OptResource, tertiary OptResource) error { if dRangeSize == 0 { return nil diff --git a/lib/rac/example_test.go b/lib/rac/example_test.go index 53d4f8af..b46cc167 100644 --- a/lib/rac/example_test.go +++ b/lib/rac/example_test.go @@ -72,7 +72,7 @@ func Example_indexLocationAtEnd() { w := &rac.ChunkWriter{ Writer: buf, } - if err := w.AddChunk(uint64(len(src)), enc, 0, 0, rac.CodecZlib); err != nil { + if err := w.AddChunk(uint64(len(src)), rac.CodecZlib, enc, 0, 0); err != nil { log.Fatalf("AddChunk: %v", err) } if err := w.Close(); err != nil { @@ -141,7 +141,7 @@ func Example_indexLocationAtStart() { } encodedChunk := b.Bytes() - if err := w.AddChunk(uint64(len(chunk)), encodedChunk, dictResource, 0, rac.CodecZlib); err != nil { + if err := w.AddChunk(uint64(len(chunk)), rac.CodecZlib, encodedChunk, dictResource, 0); err != nil { log.Fatalf("AddChunk: %v", err) } diff --git a/lib/rac/rac_test.go b/lib/rac/rac_test.go index ec284b05..c065c4ec 100644 --- a/lib/rac/rac_test.go +++ b/lib/rac/rac_test.go @@ -207,9 +207,9 @@ func testWriter(iloc IndexLocation, tempFile io.ReadWriter, cPageSize uint64, em // These {Aa,Bb,Cc} chunks are also used in the reader test. res0, _ := w.AddResource([]byte("Rrr")) res1, _ := w.AddResource([]byte("Ss")) - _ = w.AddChunk(0x11, []byte("Aaa"), 0, 0, fakeCodec) - _ = w.AddChunk(0x22, []byte("Bbbb"), res0, 0, fakeCodec) - _ = w.AddChunk(0x44, []byte("Cccccccccc12"), res0, res1, fakeCodec) + _ = w.AddChunk(0x11, fakeCodec, []byte("Aaa"), 0, 0) + _ = w.AddChunk(0x22, fakeCodec, []byte("Bbbb"), res0, 0) + _ = w.AddChunk(0x44, fakeCodec, []byte("Cccccccccc12"), res0, res1) } if err := w.Close(); err != nil { @@ -283,7 +283,7 @@ func TestMultiLevelIndex(t *testing.T) { primary[0] = 'q' } primaries = append(primaries, primary...) - _ = w.AddChunk(0x10000, primary, secondary, tertiary, fakeCodec) + _ = w.AddChunk(0x10000, fakeCodec, primary, secondary, tertiary) } if err := w.Close(); err != nil { @@ -391,9 +391,9 @@ loop: res, _ := w.AddResource(data) for i := 0; i < 1000; i++ { if i == 2*255 { - _ = w.AddChunk(1, data, res, 0, fakeCodec) + _ = w.AddChunk(1, fakeCodec, data, res, 0) } else { - _ = w.AddChunk(1, data, 0, 0, fakeCodec) + _ = w.AddChunk(1, fakeCodec, data, 0, 0) } } if err := w.Close(); err != nil { diff --git a/lib/rac/writer.go b/lib/rac/writer.go index c222fc68..aed9cd2a 100644 --- a/lib/rac/writer.go +++ b/lib/rac/writer.go @@ -442,7 +442,7 @@ func (w *Writer) writeDChunks(eof bool) error { return err } - if err := w.chunkWriter.AddChunk(dSize, cBytes, res2, res3, codec); err != nil { + if err := w.chunkWriter.AddChunk(dSize, codec, cBytes, res2, res3); err != nil { w.err = err return err } @@ -521,7 +521,7 @@ func (w *Writer) tryCChunk(targetDChunkSize uint64, force bool) error { case uint64(len(cBytes)) == w.cChunkSize: w.uncompressed.advance(dSize) dSize += w.uncompressed.advancePastLeadingZeroes() - if err := w.chunkWriter.AddChunk(dSize, cBytes, res2, res3, codec); err != nil { + if err := w.chunkWriter.AddChunk(dSize, codec, cBytes, res2, res3); err != nil { w.err = err return err } @@ -540,7 +540,7 @@ func (w *Writer) tryCChunk(targetDChunkSize uint64, force bool) error { dSize, cBytes = uint64(dLen), cBytes[:eLen] w.uncompressed.advance(dSize) dSize += w.uncompressed.advancePastLeadingZeroes() - if err := w.chunkWriter.AddChunk(dSize, cBytes, res2, res3, codec); err != nil { + if err := w.chunkWriter.AddChunk(dSize, codec, cBytes, res2, res3); err != nil { w.err = err return err }