Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alignment in chunkedContentCoder #147

Merged
merged 1 commit into from
Nov 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions contentcoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,26 @@ func init() {
reflectStaticSizeMetaData = int(reflect.TypeOf(md).Size())
}

var termSeparator byte = 0xff
var termSeparatorSplitSlice = []byte{termSeparator}
var (
termSeparator byte = 0xff
termSeparatorSplitSlice = []byte{termSeparator}
)

type chunkedContentCoder struct {
final []byte
chunkSize uint64
currChunk uint64
chunkLens []uint64

compressed []byte // temp buf for snappy compression

w io.Writer
bytesWritten uint64 // atomic access to this variable
progressiveWrite bool

chunkMeta []MetaData
chunkMetaBuf bytes.Buffer
chunkBuf bytes.Buffer

chunkMeta []MetaData

compressed []byte // temp buf for snappy compression

// atomic access to this variable
bytesWritten uint64
}

// MetaData represents the data information inside a
Expand All @@ -64,7 +63,8 @@ type MetaData struct {
// newChunkedContentCoder returns a new chunk content coder which
// packs data into chunks based on the provided chunkSize
func newChunkedContentCoder(chunkSize uint64, maxDocNum uint64,
w io.Writer, progressiveWrite bool) *chunkedContentCoder {
w io.Writer, progressiveWrite bool,
) *chunkedContentCoder {
total := maxDocNum/chunkSize + 1
rv := &chunkedContentCoder{
chunkSize: chunkSize,
Expand Down Expand Up @@ -191,7 +191,6 @@ func (c *chunkedContentCoder) Add(docNum uint64, vals []byte) error {
//
// | ..... data ..... | chunk offsets (varints)
// | position of chunk offsets (uint64) | number of offsets (uint64) |
//
func (c *chunkedContentCoder) Write() (int, error) {
var tw int

Expand Down