MCPcopy
hub / github.com/elastic/go-elasticsearch / computeLength

Method computeLength

esutil/bulk_indexer.go:230–247  ·  view source on GitHub ↗

computeLength calculate the size of the body and the metadata.

()

Source from the content-addressed store, hash-verified

228
229// computeLength calculate the size of the body and the metadata.
230func (item *BulkIndexerItem) computeLength() error {
231 if item.Body != nil {
232 n, err := item.Body.Seek(0, io.SeekEnd)
233 if err != nil {
234 return err
235 }
236 item.payloadLength += int(n)
237 _, err = item.Body.Seek(0, io.SeekStart)
238 if err != nil {
239 return err
240 }
241 }
242 item.payloadLength += len(item.meta.Bytes())
243 // Add one byte to account for newline at the end of payload.
244 item.payloadLength++
245
246 return nil
247}
248
249// BulkIndexerResponse represents the Elasticsearch response.
250type BulkIndexerResponse struct {

Callers 2

TestBulkIndexerItemFunction · 0.95
AddMethod · 0.80

Calls 2

SeekMethod · 0.80
BytesMethod · 0.45

Tested by 1

TestBulkIndexerItemFunction · 0.76