// DumpTxn returns all the tombstones.
965299
func (g *Graveyard) DumpTxn(tx *memdb.Txn) (memdb.ResultIterator, error) {
	iter, err := tx.Get("tombstones", "id")
	if err != nil {
		return nil, err
	}

	return iter, nil
}
350699
func (r *renderedStack) dumpTo(w io.Writer, excludePkgs ...string) (n int, err error) {
	excludeSet := stringset.NewFromSlice(excludePkgs...)

	return iotools.WriteTracker(w, func(w io.Writer) error {
		fmt.Fprintf(w, "goroutine %d:\n", r.goID)

		lastIdx := 0
		needNL := false
		skipCount := 0
		skipPkg := ""
		flushSkips := func(extra string) {
			if skipCount != 0 {
				if needNL {
					w.Write(nlSlice)
					needNL = false
				}
				fmt.Fprintf(w, "... skipped %d frames in pkg %q...\n%s", skipCount, skipPkg, extra)
				skipCount = 0
				skipPkg = ""
			}
		}
		for i, f := range r.frames {
			if needNL {
				w.Write(nlSlice)
				needNL = false
			}
			if excludeSet.Has(f.pkg) {
				if skipPkg == f.pkg {
					skipCount++
				} else {
					flushSkips("")
					skipCount++
					skipPkg = f.pkg
				}
				continue
			}
			flushSkips("\n")
			if len(f.wrappers) > 0 {
				f.dumpWrappersTo(w, lastIdx, i)
				w.Write(nlSlice)
			}
			if len(f.annotations) > 0 {
				lastIdx = i
				needNL = true
			}
			f.dumpTo(w, i)
		}
		flushSkips("")

		return nil
	})
}
840020
func (b *Buffer) DumpTo(w io.Writer) (written int, err error) {
	var n int
	for _, buf := range b.bufs {
		if err == nil {
			n, err = w.Write(buf)
			written += n
		}
		putBuf(buf)
	}

	if err == nil {
		n, err = w.Write(b.Buf)
		written += n
	}
	putBuf(b.toPool)

	b.bufs = nil
	b.Buf = nil
	b.toPool = nil

	return
}
1132219
func (m *Map) DumpIfExists(hash map[string][]string) error {
	found, err := m.exist()
	if err != nil {
		return err
	}

	if found {
		return m.Dump(hash)
	}

	return nil
}
582758
func (m *Message) Dump() (resp string) {
	var keys []string

	for k := range m.Headers {
		keys = append(keys, k)
	}

	sort.Strings(keys)

	for _, k := range keys {
		resp += fmt.Sprintf("%s: %s\r\n", k, m.Headers[k])
	}

	resp += fmt.Sprintf("BODY: %v\r\n", string(m.Body))

	return
}
620402
func (node *Node) Dump() string {
	str := ""
	str += node.Value

	if len(node.Flags) > 0 {
		str += fmt.Sprintf(" %q", node.Flags)
	}

	for _, n := range node.Children {
		str += "(" + n.Dump() + ")\n"
	}

	for n := node.Next; n != nil; n = n.Next {
		if len(n.Children) > 0 {
			str += " " + n.Dump()
		} else {
			str += " " + strconv.Quote(n.Value)
		}
	}

	return strings.TrimSpace(str)
}
1268105
func (e *env) writeTxn() (*mdb.Txn, error) {
	e.l.Lock()
	defer e.l.Unlock()
	if e.shouldClose {
		// should never happen
		return nil, fmt.Errorf("Environment is marked as closing, no new txns allowed!")
	}
	t, err := e.e.BeginTxn(nil, 0)
	if err != nil {
		return nil, err
	}
	return t, nil
}
874889
func (s *AtomicSequence) Dump() ([]byte, error) {
	if !s.IsStarted() {
		return nil, errors.New("cannot dump an uninitialized or unstarted sequence")
	}

	data := make(map[string]uint64)
	data["current"] = atomic.LoadUint64(&s.current)
	data["increment"] = atomic.LoadUint64(&s.increment)
	data["minvalue"] = atomic.LoadUint64(&s.minvalue)
	data["maxvalue"] = atomic.LoadUint64(&s.maxvalue)

	return json.Marshal(data)
}
724012
func runIsolatedTxn(c context.Context, cb func(context.Context) error) error {
	return runTxn(datastore.WithoutTransaction(c), cb)
}
423921
func FormatLSN(lsn uint64) string {
	return fmt.Sprintf("%X/%X", uint32(lsn>>32), uint32(lsn))
}
433273
func Dump(w io.Writer) func(r *Rego) {
	return func(r *Rego) {
		r.dump = w
	}
}
1142691
func (w *Writer) DumpTo(out io.Writer) (written int, err error) {
	return w.Buffer.DumpTo(out)
}
1108363
func (t *Trie) DumpToFile(fname string) (err error) {
	t.Root.Lock()
	entries := t.Members()
	t.Root.Unlock()

	buf := new(bytes.Buffer)
	enc := gob.NewEncoder(buf)
	if err = enc.Encode(entries); err != nil {
		err = errors.New(fmt.Sprintf("Could encode Trie entries for dump file: %v", err))
		return
	}

	f, err := os.Create(fname)
	if err != nil {
		err = errors.New(fmt.Sprintf("Could not save dump file: %v", err))
		return
	}
	defer f.Close()

	w := bufio.NewWriter(f)
	_, err = w.Write(buf.Bytes())
	if err != nil {
		err = errors.New(fmt.Sprintf("Error writing to dump file: %v", err))
		return
	}
	// log.Printf("wrote %d bytes to dumpfile %s\n", bl, fname)
	w.Flush()
	return
}
500950
func (c *Client) NewTxn() keyval.BytesTxn {
	return &txn{
		kv: c.client.KV(),
	}
}
744862
func (pdb *BytesBrokerWatcherRedis) NewTxn() keyval.BytesTxn {
	if pdb.delegate.closed {
		pdb.Error("NewTxn() called on a closed connection")
		return nil
	}
	pdb.Debug("NewTxn()")

	return &Txn{db: pdb.delegate, ops: []op{}, addPrefix: pdb.addPrefix}
}
1271955
func (r *Env) BeginTxn(parent *lmdb.Txn, flags uint) (*lmdb.Txn, error) {
	return nil, fmt.Errorf("lmdbsync: unmanaged transactions are not supported")
}
1172555
func (e *env) readTxn() (*mdb.Txn, error) {
	e.l.Lock()
	defer e.l.Unlock()
	if e.shouldClose {
		// should never happen
		return nil, fmt.Errorf("Environment is marked as closing, no new txns allowed!")
	}
	t, err := e.e.BeginTxn(nil, mdb.RDONLY)
	if err != nil {
		return nil, err
	}
	e.numOpen++
	return t, nil
}