adding checks for robustness
This commit is contained in:
parent
76f827f469
commit
0272451093
|
@ -46,7 +46,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) *chunkedContentCoder {
|
||||
func newChunkedContentCoder(chunkSize uint64,
|
||||
maxDocNum uint64) *chunkedContentCoder {
|
||||
total := maxDocNum/chunkSize + 1
|
||||
rv := &chunkedContentCoder{
|
||||
chunkSize: chunkSize,
|
||||
|
@ -113,7 +114,7 @@ func (c *chunkedContentCoder) flushContents() error {
|
|||
// write the compressed data to the final data
|
||||
compressedData := snappy.Encode(nil, c.chunkBuf.Bytes())
|
||||
c.final = append(c.final, compressedData...)
|
||||
//c.chunkLens = append(c.chunkLens, uint64(len(compressedData)+len(metaData)))
|
||||
|
||||
c.chunkLens[c.currChunk] = uint64(len(compressedData) + len(metaData))
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ func (s *Segment) loadFieldDocValueIterator(field string,
|
|||
}
|
||||
|
||||
// read the number of chunks, chunk lengths
|
||||
var offset uint64
|
||||
var offset, clen uint64
|
||||
numChunks, read := binary.Uvarint(s.mm[fieldDvLoc : fieldDvLoc+binary.MaxVarintLen64])
|
||||
if read <= 0 {
|
||||
return nil, fmt.Errorf("failed to read the field "+
|
||||
|
@ -66,7 +66,11 @@ func (s *Segment) loadFieldDocValueIterator(field string,
|
|||
chunkLens: make([]uint64, int(numChunks)),
|
||||
}
|
||||
for i := 0; i < int(numChunks); i++ {
|
||||
fdvIter.chunkLens[i], read = binary.Uvarint(s.mm[fieldDvLoc+offset : fieldDvLoc+offset+binary.MaxVarintLen64])
|
||||
clen, read = binary.Uvarint(s.mm[fieldDvLoc+offset : fieldDvLoc+offset+binary.MaxVarintLen64])
|
||||
if read <= 0 {
|
||||
return nil, fmt.Errorf("corrupted chunk length during segment load")
|
||||
}
|
||||
fdvIter.chunkLens[i] = clen
|
||||
offset += uint64(read)
|
||||
}
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@ func (s *Segment) DictAddr(field string) (uint64, error) {
|
|||
}
|
||||
|
||||
func (s *Segment) loadDvIterators() error {
|
||||
if s.docValueOffset == math.MaxUint64 {
|
||||
if s.docValueOffset == math.MaxUint64 || s.docValueOffset == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue