// Return the Well-Known Binary (WKB) representation of the geometry/geography
// without SRID meta data
963523
func AsBinary(c aspect.ColumnElem) aspect.ColumnElem {
	return c.SetInner(
		aspect.FuncClause{Inner: c.Inner(), F: "ST_AsBinary"},
	)
}
106950
func (s GeoDistanceSort) GeoDistance(geoDistance string) GeoDistanceSort {
	s.geoDistance = &geoDistance
	return s
}
779346
func UnmarshalMappingPB(data []byte, m *Mapping) error {
	return proto.Unmarshal(data, m)
}
1051194
func (sto *overlayStorage) StatBlobs(ctx context.Context, blobs []blob.Ref, f func(blob.SizedRef) error) error {
	exists := make([]blob.Ref, 0, len(blobs))
	for _, br := range blobs {
		if !sto.isDeleted(br) {
			exists = append(exists, br)
		}
	}

	seen := make(map[blob.Ref]struct{}, len(exists))

	err := sto.upper.StatBlobs(ctx, exists, func(sbr blob.SizedRef) error {
		seen[sbr.Ref] = struct{}{}
		return f(sbr)
	})

	if err != nil {
		return err
	}

	lowerBlobs := make([]blob.Ref, 0, len(exists))
	for _, br := range exists {
		if _, s := seen[br]; !s {
			lowerBlobs = append(lowerBlobs, br)
		}
	}

	return sto.lower.StatBlobs(ctx, lowerBlobs, f)
}
539223
func (*Binary) ReverseMap(_ VCursor, ksids [][]byte) ([]sqltypes.Value, error) {
	var reverseIds = make([]sqltypes.Value, len(ksids))
	for rownum, keyspaceID := range ksids {
		if keyspaceID == nil {
			return nil, fmt.Errorf("Binary.ReverseMap: keyspaceId is nil")
		}
		reverseIds[rownum] = sqltypes.MakeTrusted(sqltypes.VarBinary, keyspaceID)
	}
	return reverseIds, nil
}
570092
func Geometry(b orb.Bound, g orb.Geometry) orb.Geometry {
	if g == nil {
		return nil
	}

	if !b.Intersects(g.Bound()) {
		return nil
	}

	switch g := g.(type) {
	case orb.Point:
		return g // Intersect check above
	case orb.MultiPoint:
		mp := MultiPoint(b, g)
		if len(mp) == 1 {
			return mp[0]
		}

		if mp == nil {
			return nil
		}

		return mp
	case orb.LineString:
		mls := LineString(b, g)
		if len(mls) == 1 {
			return mls[0]
		}

		if len(mls) == 0 {
			return nil
		}
		return mls
	case orb.MultiLineString:
		mls := MultiLineString(b, g)
		if len(mls) == 1 {
			return mls[0]
		}

		if mls == nil {
			return nil
		}

		return mls
	case orb.Ring:
		r := Ring(b, g)
		if r == nil {
			return nil
		}

		return r
	case orb.Polygon:
		p := Polygon(b, g)
		if p == nil {
			return nil
		}

		return p
	case orb.MultiPolygon:
		mp := MultiPolygon(b, g)
		if len(mp) == 1 {
			return mp[0]
		}

		if mp == nil {
			return nil
		}

		return mp
	case orb.Collection:
		c := Collection(b, g)
		if len(c) == 1 {
			return c[0]
		}

		if c == nil {
			return nil
		}

		return c
	case orb.Bound:
		b = Bound(b, g)
		if b.IsEmpty() {
			return nil
		}

		return b
	}

	panic(fmt.Sprintf("geometry type not supported: %T", g))
}
809969
func Unmarshal(b []byte) (orb.Geometry, error) {
	g, err := NewDecoder(bytes.NewReader(b)).Decode()
	if err == io.EOF || err == io.ErrUnexpectedEOF {
		return nil, ErrNotWKB
	}

	return g, err
}
317254
func (KNN *KNNClassifier) GetMetadata() base.ClassifierMetadataV1 {

	classifierParams := make(map[string]interface{})
	classifierParams["distance_func"] = KNN.DistanceFunc
	classifierParams["algorithm"] = KNN.Algorithm
	classifierParams["neighbours"] = KNN.NearestNeighbours
	classifierParams["weighted"] = KNN.Weighted
	classifierParams["allow_optimizations"] = KNN.AllowOptimisations

	return base.ClassifierMetadataV1{
		FormatVersion:      1,
		ClassifierName:     "KNN",
		ClassifierVersion:  "1.0",
		ClassifierMetadata: classifierParams,
	}
}
1147794
func (g *Geometry) Covers(other *Geometry) (bool, error) {
	return g.binaryPred("Covers", cGEOSCovers, other)
}
609870
func NewBinaryInfo(goos, goarch string) *BinaryInfo {
	r := &BinaryInfo{GOOS: goos, nameOfRuntimeType: make(map[uintptr]nameOfRuntimeTypeEntry), typeCache: make(map[dwarf.Offset]godwarf.Type)}

	// TODO: find better way to determine proc arch (perhaps use executable file info).
	switch goarch {
	case "amd64":
		r.Arch = AMD64Arch(goos)
	}

	return r
}
1113794
func (p Polygon) MarshalJSON() ([]byte, error) {
	return json.Marshal(Geometry{Coordinates: orb.Polygon(p)})
}
212496
func (ebs *awsElasticBlockStore) GetGlobalMapPath(spec *volume.Spec) (string, error) {
	volumeSource, _, err := getVolumeSource(spec)
	if err != nil {
		return "", err
	}
	return filepath.Join(ebs.plugin.host.GetVolumeDevicePluginDir(awsElasticBlockStorePluginName), string(volumeSource.VolumeID)), nil
}
451056
func (d *wktDecoder) decode(wkt string) (*Geometry, error) {
	cstr := C.CString(wkt)
	defer C.free(unsafe.Pointer(cstr))
	g := cGEOSWKTReader_read(d.r, cstr)
	if g == nil {
		return nil, Error()
	}
	return geomFromPtr(g), nil
}
867162
func (fc *fcDisk) GetGlobalMapPath(spec *volume.Spec) (string, error) {
	return fc.fcGlobalMapPath(spec)
}
859996
func Geometry(g orb.Geometry, proj orb.Projection) orb.Geometry {
	if g == nil {
		return nil
	}

	switch g := g.(type) {
	case orb.Point:
		return Point(g, proj)
	case orb.MultiPoint:
		return MultiPoint(g, proj)
	case orb.LineString:
		return LineString(g, proj)
	case orb.MultiLineString:
		return MultiLineString(g, proj)
	case orb.Ring:
		return Ring(g, proj)
	case orb.Polygon:
		return Polygon(g, proj)
	case orb.MultiPolygon:
		return MultiPolygon(g, proj)
	case orb.Collection:
		return Collection(g, proj)
	case orb.Bound:
		return Bound(g, proj)
	}

	panic("geometry type not supported")
}
432689
func UnmarshalConfigUpdateEnvelope(data []byte) (*cb.ConfigUpdateEnvelope, error) {
	configUpdateEnvelope := &cb.ConfigUpdateEnvelope{}
	err := proto.Unmarshal(data, configUpdateEnvelope)
	if err != nil {
		return nil, err
	}
	return configUpdateEnvelope, nil
}
902429
func (r *ReplyGetattrV2) UnmarshalBinary(data []byte) error {
	return UnmarshalBinary(data, &r.Reply, &r.Attr, &r.SymlinkTarget)
}