// NewCMSketchWithTopN returns a new CM sketch with TopN elements, the estimate NDV and the scale ratio.
171123
func NewCMSketchWithTopN(d, w int32, sample [][]byte, numTop uint32, rowCount uint64) (*CMSketch, uint64, uint64) {
	helper := newTopNHelper(sample, numTop)
	// rowCount is not a accurate value when fast analyzing
	// In some cases, if user triggers fast analyze when rowCount is close to sampleSize, unexpected bahavior might happen.
	rowCount = mathutil.MaxUint64(rowCount, uint64(len(sample)))
	estimateNDV, scaleRatio := calculateEstimateNDV(helper, rowCount)
	c := buildCMSWithTopN(helper, d, w, scaleRatio)
	c.calculateDefaultVal(helper, estimateNDV, scaleRatio, rowCount)
	return c, estimateNDV, scaleRatio
}
1080184
func NewGraphiteWithMetricPrefix(host string, port int, prefix string) (*Graphite, error) {
	return GraphiteFactory("tcp", host, port, prefix)
}
69071
func NewPointFlat(l Layout, flatCoords []float64) *Point {
	g := new(Point)
	g.layout = l
	g.stride = l.Stride()
	g.flatCoords = flatCoords
	return g
}
793542
func WithImageStopSignal(image Image, defaultSignal string) NewContainerOpts {
	return func(ctx context.Context, _ *Client, c *containers.Container) error {
		if c.Labels == nil {
			c.Labels = make(map[string]string)
		}
		stopSignal, err := GetOCIStopSignal(ctx, image, defaultSignal)
		if err != nil {
			return err
		}
		c.Labels[StopSignalLabel] = stopSignal
		return nil
	}
}
871174
func New(params *stripe.TopupParams) (*stripe.Topup, error) {
	return getC().New(params)
}
750567
func NewPCPInstanceMetric(vals Instances, name string, indom *PCPInstanceDomain, t MetricType, s MetricSemantics, u MetricUnit, desc ...string) (*PCPInstanceMetric, error) {
	d, err := newpcpMetricDesc(name, t, s, u, desc...)
	if err != nil {
		return nil, err
	}

	im, err := newpcpInstanceMetric(vals, indom, d)
	if err != nil {
		return nil, err
	}

	return &PCPInstanceMetric{im, sync.RWMutex{}}, nil
}
1083823
func NewTopK(epsilon, delta float64, k uint) *TopK {
	elements := make(elementHeap, 0, k)
	heap.Init(&elements)
	return &TopK{
		cms:      NewCountMinSketch(epsilon, delta),
		k:        k,
		elements: &elements,
	}
}
808864
func (gp *GoPdf) SetMarginTop(margin float64) {
	gp.margins.Top = gp.UnitsToPoints(margin)
}
152597
func NewRollPitchYawThrustSetpoint(TIME_BOOT_MS uint32, ROLL float32, PITCH float32, YAW float32, THRUST float32) *RollPitchYawThrustSetpoint {
	m := RollPitchYawThrustSetpoint{}
	m.TIME_BOOT_MS = TIME_BOOT_MS
	m.ROLL = ROLL
	m.PITCH = PITCH
	m.YAW = YAW
	m.THRUST = THRUST
	return &m
}
1044732
func newCPartsFromTopicPartitions(partitions []TopicPartition) (cparts *C.rd_kafka_topic_partition_list_t) {
	cparts = C.rd_kafka_topic_partition_list_new(C.int(len(partitions)))
	for _, part := range partitions {
		ctopic := C.CString(*part.Topic)
		defer C.free(unsafe.Pointer(ctopic))
		rktpar := C.rd_kafka_topic_partition_list_add(cparts, ctopic, C.int32_t(part.Partition))
		rktpar.offset = C.int64_t(part.Offset)
	}

	return cparts
}
553906
func NewMultiPointFlat(layout Layout, flatCoords []float64) *MultiPoint {
	g := new(MultiPoint)
	g.layout = layout
	g.stride = layout.Stride()
	g.flatCoords = flatCoords
	return g
}
1354842
func CmpTotalAbs(x, y *decimal.Big) int {
	xs := ord(x, true)
	ys := ord(y, true)
	if xs != ys {
		if xs > ys {
			return +1
		}
		return -1
	}
	if xs != 0 {
		return 0
	}
	return x.CmpAbs(y)
}
808733
func (charts *ChartData) NewAtomsTip() int32 {
	charts.mtx.RLock()
	defer charts.mtx.RUnlock()
	return int32(len(charts.Blocks.NewAtoms)) - 1
}
1015136
func newCloserChan(kvc KeyValueChan, size int) closerChan {
	signals := make(closerChan)
	go func() {
		ctr := 0
		for {
			<-signals
			ctr++
			if ctr == size {
				kvc.Close()
				close(signals)
				return
			}
		}
	}()
	return signals
}
653864
func (p *Pages) AddAndSwitchToPage(name string, item Primitive, resize bool) *Pages {
	p.AddPage(name, item, resize, true)
	p.SwitchToPage(name)
	return p
}
180124
func (twe *TxWeightEstimator) AddNestedP2WKHInput() *TxWeightEstimator {
	twe.inputSize += InputSize + P2WPKHSize
	twe.inputWitnessSize += P2WKHWitnessSize
	twe.inputSize++
	twe.hasWitness = true

	return twe
}
785816
func stateEndTop(s *scanner, c byte) int {
	if c != ' ' && c != '\t' && c != '\r' && c != '\n' {
		// Complain about non-space byte on next call.
		s.error(c, "after top-level value")
	}
	return scanEnd
}