// WriteFull writes len(data) bytes to the object with key oid.
// The object is filled with the provided data. If the object exists,
// it is atomically truncated and then written. It returns an error, if any.
500026
func (ioctx *IOContext) WriteFull(oid string, data []byte) error {
	c_oid := C.CString(oid)
	defer C.free(unsafe.Pointer(c_oid))

	ret := C.rados_write_full(ioctx.ioctx, c_oid,
		(*C.char)(unsafe.Pointer(&data[0])),
		(C.size_t)(len(data)))
	return GetRadosError(int(ret))
}
927164
func (w *ResponseWriter) Write(data []byte) (int, error) {
	size, err := w.ResponseWriter.Write(data)
	w.size += size
	return size, err
}
860905
func (w *Writer) Write(data []byte) (n int, err error) {
	return w.d.write(data)
}
678740
func (f *Formatter) Write(str string, a ...interface{}) error {
	// Don't indent empty lines
	if str == "" {
		_, err := io.WriteString(f.Writer, "\n")
		return err
	}

	indent := ""
	for i := 0; i < f.IndentLevel; i++ {
		indent = indent + " "
	}

	if len(a) > 0 {
		str = fmt.Sprintf(str, a...)
	}
	_, err := io.WriteString(f.Writer, indent+str+"\n")
	return err
}
797462
func (w *BackupStreamWriter) Write(b []byte) (int, error) {
	if w.bytesLeft < int64(len(b)) {
		return 0, fmt.Errorf("too many bytes by %d", int64(len(b))-w.bytesLeft)
	}
	n, err := w.w.Write(b)
	w.bytesLeft -= int64(n)
	return n, err
}
953135
func (c *Compactor) CompactFull(tsmFiles []string) ([]string, error) {
	c.mu.RLock()
	enabled := c.compactionsEnabled
	c.mu.RUnlock()

	if !enabled {
		return nil, errCompactionsDisabled
	}

	if !c.add(tsmFiles) {
		return nil, errCompactionInProgress{}
	}
	defer c.remove(tsmFiles)

	files, err := c.compact(false, tsmFiles)

	// See if we were disabled while writing a snapshot
	c.mu.RLock()
	enabled = c.compactionsEnabled
	c.mu.RUnlock()

	if !enabled {
		if err := c.removeTmpFiles(files); err != nil {
			return nil, err
		}
		return nil, errCompactionsDisabled
	}

	return files, err
}
245147
func (c PublicClient) ListFull(patterns ...string) ([]payload.FullPayloadInfo, error) {
	var result params.PayloadListResults

	args := params.PayloadListArgs{
		Patterns: patterns,
	}
	if err := c.FacadeCall("List", &args, &result); err != nil {
		return nil, errors.Trace(err)
	}

	payloads := make([]payload.FullPayloadInfo, len(result.Results))
	for i, apiInfo := range result.Results {
		payload, err := api.API2Payload(apiInfo)
		if err != nil {
			// We should never see this happen; we control the input safely.
			return nil, errors.Trace(err)
		}
		payloads[i] = payload
	}
	return payloads, nil
}
1088459
func (spec MutateInSpec) UpsertFull(val interface{}, opts *MutateInSpecUpsertFullOptions) MutateInOp {
	if opts == nil {
		opts = &MutateInSpecUpsertFullOptions{}
	}

	encoder := opts.Encoder
	if opts.Encoder == nil {
		encoder = JSONEncode
	}

	marshaled, _, err := encoder(val)
	if err != nil {
		return MutateInOp{err: err}
	}

	op := gocbcore.SubDocOp{
		Op:    gocbcore.SubDocOpSetDoc,
		Flags: gocbcore.SubdocFlag(SubdocFlagNone),
		Value: marshaled,
	}

	return MutateInOp{op: op}
}
391071
func (w *BackupFileWriter) Write(b []byte) (int, error) {
	var bytesWritten uint32
	err := backupWrite(syscall.Handle(w.f.Fd()), b, &bytesWritten, false, w.includeSecurity, &w.ctx)
	if err != nil {
		return 0, &os.PathError{"BackupWrite", w.f.Name(), err}
	}
	runtime.KeepAlive(w.f)
	if int(bytesWritten) != len(b) {
		return int(bytesWritten), errors.New("not all bytes could be written")
	}
	return len(b), nil
}
1091396
func (oc *OutputChannel) Write(fields map[string]interface{}) (err error) {
	select {
	case oc.input <- fields:
		// Sent with success
	default:
		// Channel is full, message dropped
		err = ErrBufferFull
	}
	return err
}
625313
func (b *Bucket) write() []byte {
	// Allocate the appropriate size.
	var n = b.rootNode
	var value = make([]byte, bucketHeaderSize+n.size())

	// Write a bucket header.
	var bucket = (*bucket)(unsafe.Pointer(&value[0]))
	*bucket = *b.bucket

	// Convert byte slice to a fake page and write the root node.
	var p = (*page)(unsafe.Pointer(&value[bucketHeaderSize]))
	n.write(p)

	return value
}
1014011
func (w *asyncUdsWriter) Write(data []byte) (int, error) {
	select {
	case w.datagramQueue <- data:
		return len(data), nil
	default:
		return 0, fmt.Errorf("uds datagram queue is full (the agent might not be able to keep up)")
	}
}
1360698
func (w *Writer) Write(data []byte) (n int, err error) {
	src := data
	if w.n > 0 {
		// Append bytes from data to the last remainder.
		// TODO: limit the amount copied on first try.
		n = copy(w.src[w.n:], data)
		w.n += n
		src = w.src[:w.n]
	}
	for {
		nDst, nSrc, err := w.t.Transform(w.dst, src, false)
		if _, werr := w.w.Write(w.dst[:nDst]); werr != nil {
			return n, werr
		}
		src = src[nSrc:]
		if w.n > 0 && len(src) <= n {
			// Enough bytes from w.src have been consumed. We make src point
			// to data instead to reduce the copying.
			w.n = 0
			n -= len(src)
			src = data[n:]
			if n < len(data) && (err == nil || err == ErrShortSrc) {
				continue
			}
		} else {
			n += nSrc
		}
		switch {
		case err == ErrShortDst && (nDst > 0 || nSrc > 0):
		case err == ErrShortSrc && len(src) < len(w.src):
			m := copy(w.src, src)
			// If w.n > 0, bytes from data were already copied to w.src and n
			// was already set to the number of bytes consumed.
			if w.n == 0 {
				n += m
			}
			w.n = m
			return n, nil
		case err == nil && w.n > 0:
			return n, errInconsistentByteCount
		default:
			return n, err
		}
	}
}
1194355
func (s *stdlogAdapter) Write(data []byte) (int, error) {
	str := string(bytes.TrimRight(data, " \t\n"))

	if s.forceLevel != NoLevel {
		// Use pickLevel to strip log levels included in the line since we are
		// forcing the level
		_, str := s.pickLevel(str)

		// Log at the forced level
		switch s.forceLevel {
		case Trace:
			s.log.Trace(str)
		case Debug:
			s.log.Debug(str)
		case Info:
			s.log.Info(str)
		case Warn:
			s.log.Warn(str)
		case Error:
			s.log.Error(str)
		default:
			s.log.Info(str)
		}
	} else if s.inferLevels {
		level, str := s.pickLevel(str)
		switch level {
		case Trace:
			s.log.Trace(str)
		case Debug:
			s.log.Debug(str)
		case Info:
			s.log.Info(str)
		case Warn:
			s.log.Warn(str)
		case Error:
			s.log.Error(str)
		default:
			s.log.Info(str)
		}
	} else {
		s.log.Info(str)
	}

	return len(data), nil
}
350746
func (w *Writer) Write(i interface{}) {
	var s string
	switch i.(type) {
	case string:
		s = i.(string)
	case []byte:
		for _, b := range i.([]byte) {
			s += fmt.Sprintf("%.8b", b)
		}
	case bool:
		if i.(bool) {
			s = "1"
		} else {
			s = "0"
		}
	case uint8:
		s = fmt.Sprintf("%.8b", i)
	case uint16:
		s = fmt.Sprintf("%.16b", i)
	case uint32:
		s = fmt.Sprintf("%.32b", i)
	case uint64:
		s = fmt.Sprintf("%.64b", i)
	default:
		return
	}

	for _, c := range s {
		w.remainingBits = w.remainingBits + string(c)
		if len(w.remainingBits) == 8 {
			var nb byte
			var power float64
			for idx := len(w.remainingBits) - 1; idx >= 0; idx-- {
				if w.remainingBits[idx] == '1' {
					nb = nb + uint8(math.Pow(2, power))
				}
				power++
			}
			w.b = append(w.b, nb)
			w.remainingBits = ""
		}
	}
}
309332
func (sbself *splitBufferedWriter) Write(data []byte) (int, error) {
	toCopy := len(sbself.userBuffer) - sbself.userBufferCount
	if toCopy > len(data) {
		toCopy = len(data)
	}
	copy(sbself.userBuffer[sbself.userBufferCount:sbself.userBufferCount+toCopy], data[:toCopy])
	sbself.userBufferCount += toCopy
	if toCopy < len(data) { // we need to overflow to remainder
		count, err := sbself.remainder.Write(data[toCopy:])
		return count + toCopy, err
	}
	return toCopy, nil
}
1060600
func (w *commandWriter) Write(data []byte) (int, error) {

	var (
		written int
		err     error
	)

	for len(data) > 0 {
		if w.eof {
			return written, io.EOF
		}
		// never send more data than our EnvelopeSize.
		n := min(w.client.Parameters.EnvelopeSize-1000, len(data))
		if err := w.sendInput(data[:n]); err != nil {
			break
		}
		data = data[n:]
		written += n
	}

	return written, err
}