func (tb *Table) AddItems(items [][]byte) error {
	var err error
	var blocksToMerge []*inmemoryBlock

	tb.rawItemsLock.Lock()
	if len(tb.rawItemsBlocks) == 0 {
		ib := getInmemoryBlock()
		tb.rawItemsBlocks = append(tb.rawItemsBlocks, ib)
	}
	ib := tb.rawItemsBlocks[len(tb.rawItemsBlocks)-1]
	for _, item := range items {
		if !ib.Add(item) {
			ib = getInmemoryBlock()
			if !ib.Add(item) {
				putInmemoryBlock(ib)
				err = fmt.Errorf("cannot insert an item %q into an empty inmemoryBlock on %q; it looks like the item is too large? len(item)=%d",
					item, tb.path, len(item))
				break
			}
			tb.rawItemsBlocks = append(tb.rawItemsBlocks, ib)
		}
	}
	if len(tb.rawItemsBlocks) >= 1024 {
		blocksToMerge = tb.rawItemsBlocks
		tb.rawItemsBlocks = nil
		tb.rawItemsLastFlushTime = time.Now()
	}
	tb.rawItemsLock.Unlock()

	if blocksToMerge == nil {
		// Fast path.
		return err
	}

	// Slow path: merge blocksToMerge.
	tb.mergeRawItemsBlocks(blocksToMerge)
	return err
}
// AddItems adds the given items to the tb.
AddItems adds the given items to the tb.
// AddItems adds the given items to the tb .
func (tb *Table) AddItems(items [][]byte) error {
	var err error
	var blocksToMerge []*inmemoryBlock
	tb.rawItemsLock.Lock()
	if len(tb.rawItemsBlocks) == 0 {
		ib := getInmemoryBlock()
		tb.rawItemsBlocks = append(tb.rawItemsBlocks, ib)
	}
	ib := tb.rawItemsBlocks[len(tb.rawItemsBlocks)-1]
	for _, item := range items {
		if !ib.Add(item) {
			ib = getInmemoryBlock()
			if !ib.Add(item) {
				putInmemoryBlock(ib)
				err = fmt.Errorf("cannot insert an item %q into an empty inmemoryBlock on %q; it looks like the item is too large? len(item)=%d",
					item, tb.path, len(item))
				break
			}
			tb.rawItemsBlocks = append(tb.rawItemsBlocks, ib)
		}
	}
	if len(tb.rawItemsBlocks) >= 1024 {
		blocksToMerge = tb.rawItemsBlocks
		tb.rawItemsBlocks = nil
		tb.rawItemsLastFlushTime = time.Now()
	}
	tb.rawItemsLock.Unlock()
	if blocksToMerge == nil {
		return err
	}
	tb.mergeRawItemsBlocks(blocksToMerge)
	return err
}
func ( tb * Table ) AddItems ( items [ ] [ ] byte ) error { var err error var blocksToMerge [ ] * inmemoryBlock tb . rawItemsLock . Lock ( ) if len ( tb . rawItemsBlocks ) == 0 { ib := getInmemoryBlock ( ) tb . rawItemsBlocks = append ( tb . rawItemsBlocks , ib ) } ib := tb . rawItemsBlocks [ len ( tb . rawItemsBlocks ) - 1 ] for _ , item := range items { if ! ib . Add ( item ) { ib = getInmemoryBlock ( ) if ! ib . Add ( item ) { putInmemoryBlock ( ib ) err = fmt . Errorf ( " " , item , tb . path , len ( item ) ) break } tb . rawItemsBlocks = append ( tb . rawItemsBlocks , ib ) } } if len ( tb . rawItemsBlocks ) >= 1024 { blocksToMerge = tb . rawItemsBlocks tb . rawItemsBlocks = nil tb . rawItemsLastFlushTime = time . Now ( ) } tb . rawItemsLock . Unlock ( ) if blocksToMerge == nil { return err } tb . mergeRawItemsBlocks ( blocksToMerge ) return err }
AddItems adds the given items to the tb.
AddItems adds the given items to the tb .
// Fast path. // Slow path: merge blocksToMerge.