// NewCompactData parses a CompactData from a start element.
// If delim is explicitly passed, it will override the DELIMITER element value, which defaults to \t. Pass
// empty string to automatically parse DELIMITER value or fallback to default of \t.
517763
func NewCompactData(start xml.StartElement, decoder *xml.Decoder, delim string) (CompactData, error) {
	cd := CompactData{}
	cd.Element = start.Name.Local
	cd.Attr = map[string]string{}
	for _, a := range start.Attr {
		cd.Attr[a.Name.Local] = a.Value
	}
	err := decoder.DecodeElement(&cd, &start)
	if err != nil {
		return cd, err
	}
	if delim != "" {
		cd.Delimiter = delim
	} else if cd.CompactDelimiter.Value != "" {
		// explicitly specified delimiter, eg:  <DELIMITER value="2C"/>
		delimOrdinal, err := strconv.ParseInt(cd.CompactDelimiter.Value, 16, 8)
		if err != nil {
			return cd, fmt.Errorf("unable to parse DELIMITER value=%s", cd.CompactDelimiter.Value)
		}
		cd.Delimiter = string(rune(delimOrdinal))
	} else {
		cd.Delimiter = CompactDefaultDelim
	}
	return cd, nil
}
1104005
func fullViaCompactIncremental(ctx context.Context, requester rets.Requester, url string) (*metadata.MSystem, error) {
	compact := &util.IncrementalCompact{}
	err := compact.Load(ctx, requester, url)
	if err != nil {
		return nil, err
	}
	return util.AsStandard(*compact).Convert()
}
422425
func (p *SourceObjectParams) AppendTo(body *form.Values, keyParts []string) {
	if len(p.TypeData) > 0 && p.Type == nil {
		panic("You can not fill TypeData if you don't explicitly set Type")
	}

	for k, vs := range p.TypeData {
		body.Add(form.FormatKey(append(keyParts, StringValue(p.Type), k)), vs)
	}
}
77672
func NewDelStr(ctx context.Context, table, key string,
	values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) {
	return NewDel(ctx, []byte(table), []byte(key), values, options...)
}
907871
func (db *Database) Compact() (resp string, e error) {
	url, err := buildUrl(db.dbName, "_compact")
	fmt.Println(url)
	if err != nil {
		return "", err
	}

	var headers = make(map[string]string)
	headers["Accept"] = "application/json"
	headers["Content-Type"] = "application/json"

	emtpyBody := ""

	dbResponse, err := db.connection.request("POST", url, strings.NewReader(emtpyBody), headers, db.auth)
	defer dbResponse.Body.Close()

	buf := new(bytes.Buffer)
	buf.ReadFrom(dbResponse.Body)
	strResp := buf.String()

	return strResp, err
}
1173041
func (fs *FileStore) compactClientFile(orgFileName string) error {
	// Open a temporary file
	tmpFile, err := getTempFile(fs.fm.rootDir, clientsFileName)
	if err != nil {
		return err
	}
	defer func() {
		if tmpFile != nil {
			tmpFile.Close()
			os.Remove(tmpFile.Name())
		}
	}()
	bw := bufio.NewWriterSize(tmpFile, defaultBufSize)
	fileSize := int64(0)
	size := 0
	_buf := [256]byte{}
	buf := _buf[:]
	// Dump the content of active clients into the temporary file.
	for _, c := range fs.clients {
		buf, size, err = writeRecord(bw, buf, addClient, &c.ClientInfo, c.ClientInfo.Size(), fs.crcTable)
		if err != nil {
			return err
		}
		fileSize += int64(size)
	}
	// Flush the buffer on disk
	if err := bw.Flush(); err != nil {
		return err
	}
	// Start by closing the temporary file.
	if err := tmpFile.Close(); err != nil {
		return err
	}
	// Rename the tmp file to original file name
	if err := os.Rename(tmpFile.Name(), orgFileName); err != nil {
		return err
	}
	// Avoid unnecessary attempt to cleanup
	tmpFile = nil

	fs.cliDeleteRecs = 0
	fs.cliFileSize = fileSize
	fs.cliCompactTS = time.Now()
	return nil
}
138701
func putData(v interface{}, pn *C.pn_data_t) {
	if v != nil {
		C.pn_data_clear(pn)
		marshal(v, pn)
	}
}
320799
func fullViaCompact(ctx context.Context, requester rets.Requester, url string) (*metadata.MSystem, error) {
	reader, err := rets.MetadataStream(rets.MetadataResponse(ctx, requester, rets.MetadataRequest{
		URL: url,
		MetadataParams: rets.MetadataParams{
			Format: "COMPACT",
			MType:  "METADATA-SYSTEM",
			ID:     "*",
		},
	}))
	defer reader.Close()
	if err != nil {
		return nil, err
	}
	compact, err := rets.ParseMetadataCompactResult(reader)
	if err != nil {
		return nil, err
	}
	return util.AsStandard(*compact).Convert()
}
177508
func (mc *xlsxMergeCells) getExtent(cellRef string) (int, int, error) {
	if mc == nil {
		return 0, 0, nil
	}
	for _, cell := range mc.Cells {
		if strings.HasPrefix(cell.Ref, cellRef+cellRangeChar) {
			parts := strings.Split(cell.Ref, cellRangeChar)
			startx, starty, err := GetCoordsFromCellIDString(parts[0])
			if err != nil {
				return -1, -1, err
			}
			endx, endy, err := GetCoordsFromCellIDString(parts[1])
			if err != nil {
				return -2, -2, err
			}
			return endx - startx, endy - starty, nil
		}
	}
	return 0, 0, nil
}
585200
func parseStructuredData(buff []byte, cursor *int, l int) (string, error) {
	var sdData string
	var found bool

	if *cursor >= l {
		return "-", nil
	}

	if buff[*cursor] == NILVALUE {
		*cursor++
		return "-", nil
	}

	if buff[*cursor] != '[' {
		return sdData, ErrNoStructuredData
	}

	from := *cursor
	to := from

	for to = from; to < l; to++ {
		if found {
			break
		}

		b := buff[to]

		if b == ']' {
			switch t := to + 1; {
			case t == l:
				found = true
			case t <= l && buff[t] == ' ':
				found = true
			}
		}
	}

	if found {
		*cursor = to
		return string(buff[from:to]), nil
	}

	return sdData, ErrNoStructuredData
}
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
}
1097630
func (Encoder) AppendObjectData(dst []byte, o []byte) []byte {
        // BeginMarker is present in the dst, which
        // should not be copied when appending to existing data.
        return append(dst, o[1:]...)
}
833205
func formatCompact(x uint64) []byte {
	var b [20]byte
	return strconv.AppendUint(b[0:0], uint64(x), 10)
}
1247807
func selectionData(selection *goquery.Selection) string {
	var results []string
	selection.Each(func(i int, element *goquery.Selection) {
		if len(element.Nodes) > 0 {
			results = append(results, element.Nodes[0].Data)
		}
	})
	return strings.Join(results, " ")
}
987557
func (c *SeriesPartitionCompactor) Compact(p *SeriesPartition) (time.Duration, error) {
	// Snapshot the partitions and index so we can check tombstones and replay at the end under lock.
	p.mu.RLock()
	segments := CloneSeriesSegments(p.segments)
	index := p.index.Clone()
	seriesN := p.index.Count()
	p.mu.RUnlock()

	now := time.Now()

	// Compact index to a temporary location.
	indexPath := index.path + ".compacting"
	if err := c.compactIndexTo(index, seriesN, segments, indexPath); err != nil {
		return 0, err
	}
	duration := time.Since(now)

	// Swap compacted index under lock & replay since compaction.
	if err := func() error {
		p.mu.Lock()
		defer p.mu.Unlock()

		// Reopen index with new file.
		if err := p.index.Close(); err != nil {
			return err
		} else if err := os.Rename(indexPath, index.path); err != nil {
			return err
		} else if err := p.index.Open(); err != nil {
			return err
		}

		// Replay new entries.
		if err := p.index.Recover(p.segments); err != nil {
			return err
		}
		return nil
	}(); err != nil {
		return 0, err
	}

	return duration, nil
}
745486
func newCompactCommand(m *Main) *CompactCommand {
	return &CompactCommand{
		Stdin:  m.Stdin,
		Stdout: m.Stdout,
		Stderr: m.Stderr,
	}
}
1363247
func NewBinDataAsset(assetName, targetDir, targetName, permissions string, isTemplate bool) *BinDataAsset {
	m := &BinDataAsset{
		BaseAsset: BaseAsset{
			AssetName:   assetName,
			TargetDir:   targetDir,
			TargetName:  targetName,
			Permissions: permissions,
		},
		template: nil,
	}
	m.loadData(isTemplate)
	return m
}