util

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BtPlaceStatsVarPrefix for place to statsvar list cache.
	BtPlaceStatsVarPrefix = "d/0/"
	// BtPopObsPrefix for internal pop obs cache.
	BtPopObsPrefix = "d/2/"
	// BtPlaceObsPrefix for internal place obs cache.
	BtPlaceObsPrefix = "d/3/"
	// BtLandingPagePrefix for place landing page cache.
	BtLandingPagePrefix = "d/4/"
	// BtObsAncestorPrefix for the ancestor node of Bigtable.
	BtObsAncestorPrefix = "d/6/"
	// BtTriplesPrefix for internal GetTriples cache.
	BtTriplesPrefix = "d/7/"
	// BtArcsPrefix for internal arcs cache.
	BtArcsPrefix = "d/9/"
	// BtPopPrefix for population cache.
	BtPopPrefix = "d/a/"
	// BtObsPrefix for observation cache.
	BtObsPrefix = "d/b/"
	// BtPlacesInPrefix for GetPlacesIn cache.
	BtPlacesInPrefix = "d/c/"
	// BtPopPVPrefix for population PVs.
	BtPopPVPrefix = "d/d/"
	// BtChartDataPrefix for chart data.
	BtChartDataPrefix = "d/f/"
	// BtInterestingPlaceAspectPrefix for interesting place aspect.
	BtInterestingPlaceAspectPrefix = "d/k/"
	// BtInPropValPrefix for in-arc prop value.
	BtInPropValPrefix = "d/l/"
	// BtOutPropValPrefix for out-arc prop value.
	BtOutPropValPrefix = "d/m/"
	// BtRelatedLocationsPrefix for related places.
	BtRelatedLocationsPrefix = "d/n/"
	// BtRelatedLocationsSameTypePrefix for related places with same type.
	BtRelatedLocationsSameTypePrefix = "d/o/"
	// BtRelatedLocationsSameAncestorPrefix for related places with same ancestor.
	BtRelatedLocationsSameAncestorPrefix = "d/p/"
	// BtRelatedLocationsSameTypeAndAncestorPrefix for related places with same type and ancestor.
	BtRelatedLocationsSameTypeAndAncestorPrefix = "d/q/"
	// BtRelatedLocationsPCPrefix for related places, per capita.
	BtRelatedLocationsPCPrefix = "d/n0/"
	// BtRelatedLocationsSameTypePCPrefix for related places with same type, per capita.
	BtRelatedLocationsSameTypePCPrefix = "d/o0/"
	// BtRelatedLocationsSameAncestorPCPrefix for related places with same ancestor, per capita.
	BtRelatedLocationsSameAncestorPCPrefix = "d/p0/"
	// BtRelatedLocationsSameTypeAndAncestorPCPrefix for related places with same type and ancestor,
	// per capita.
	BtRelatedLocationsSameTypeAndAncestorPCPrefix = "d/q0/"

	// BtFamily is the key for the row.
	BtFamily = "csv"
	// BtCacheLimit is the cache limit. The limit is per predicate and neighbor type.
	BtCacheLimit = 500
	// BtBatchQuerySize is the size of BigTable batch query.
	BtBatchQuerySize = 1000
	// LimitFactor is the amount to multiply the limit by to make sure certain
	// triples are returned by the BQ query.
	LimitFactor = 1
	// TextType represents text type.
	TextType = "Text"
)

Variables

This section is empty.

Functions

func CamelToSnake

func CamelToSnake(str string) string

CamelToSnake converts a camel case string to snake case string.

func CheckValidDCIDs added in v1.0.0

func CheckValidDCIDs(dcids []string) bool

CheckValidDCIDs checks if DCIDs are valid. More criteria will be added as being discovered.

func GetContainedIn

func GetContainedIn(typeRelationJSONFilePath string) (map[TypePair][]string, error)

GetContainedIn returns the contained in relation change given two types.

func KeyToDcid added in v1.0.0

func KeyToDcid(key string) (string, error)

KeyToDcid ... The Bigtable key is in the form of "x/y/dcid^prop1^prop2^..."

func RandomString added in v1.0.0

func RandomString() string

RandomString creates a random string with 16 runes.

func RemoveKeyPrefix added in v1.0.0

func RemoveKeyPrefix(key string) (string, error)

RemoveKeyPrefix removes the prefix of a big query key

func SnakeToCamel

func SnakeToCamel(s string) string

SnakeToCamel converts a snake case string to camel case string.

func StringContainedIn

func StringContainedIn(target string, strs []string) bool

StringContainedIn returns true if TARGET is contained in STRS

func StringList

func StringList(strs []string) string

StringList formats a list of strings into a comma-separated list with each surrounded with quotes.

func UnzipAndDecode

func UnzipAndDecode(contents string) ([]byte, error)

UnzipAndDecode decompresses the given contents using gzip and decodes it from base64

func ZipAndEncode

func ZipAndEncode(contents []byte) (string, error)

ZipAndEncode Compresses the given contents using gzip and encodes it in base64

Types

type TypePair

type TypePair struct {
	Child  string
	Parent string
}

TypePair represents two types that are related.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL