server

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: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RelatedLocationsPrefixMap = map[bool]map[bool]map[bool]string{
	// contains filtered or unexported fields
}

RelatedLocationsPrefixMap is a map from different scenarios to key prefix for RelatedLocations cache.

The three levels of keys are: - Whether related locaitons have the same ancestor. - Whether related locaitons have the same place type. - Whether closeness computaion is per capita.

Functions

func NewBtTable

func NewBtTable(
	ctx context.Context, projectID, instanceID, tableID string) (
	*bigtable.Table, error)

NewBtTable creates a new bigtable.Table instance.

func ReadBranchCacheFolder

func ReadBranchCacheFolder(
	ctx context.Context, bucket, versionFile string) (string, error)

ReadBranchCacheFolder reads branch cache folder from GCS.

Types

type InterestingPlaceAspect

type InterestingPlaceAspect struct {
	RankFromTop      int32                `json:"rankFromTop,omitempty"`
	RankFromBottom   int32                `json:"rankFromBottom,omitempty"`
	StatVar          *StatisticalVariable `json:"statVar,omitempty"`
	ContainedInPlace string               `json:"containedInPlace,omitempty"`
	PlaceType        string               `json:"placeType,omitempty"`
	PerCapita        bool                 `json:"perCapita,omitempty"`
}

InterestingPlaceAspect contains info about why a place is interesting.

type InterestingPlaceAspects

type InterestingPlaceAspects struct {
	Aspects []*InterestingPlaceAspect `json:"aspects,omitempty"`
}

InterestingPlaceAspects contains a list of InterestingPlaceAspect objects.

type LandingPageData added in v1.1.0

type LandingPageData struct {
	Data map[string]*ObsTimeSeries `json:"data,omitempty"`
}

LandingPageData represents the landing page cache data.

type Memcache

type Memcache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Memcache represents a Read Write locked object for in-memory key-value cache.

func NewMemcache

func NewMemcache(data map[string][]byte) *Memcache

NewMemcache initialize a new Memcache instance from a key value map.

func NewMemcacheFromGCS

func NewMemcacheFromGCS(
	ctx context.Context, bucket, folder string) (*Memcache, error)

NewMemcacheFromGCS initialize a Memcache instance from a Google Cloud Storage folder.

func (*Memcache) Read

func (m *Memcache) Read(key string) ([]byte, bool)

Read is used for key value look up for Cache.

func (*Memcache) ReadParallel

func (m *Memcache) ReadParallel(
	rowList bigtable.RowList,
	transform func(string, []byte) (interface{}, error),
	getToken func(string) (string, error),
) map[string]interface{}

ReadParallel read multiple entries from memecache concurrently. This takes a function which transforms raw data into an object.

func (*Memcache) Update

func (m *Memcache) Update(data map[string][]byte)

Update is used to update the data in Cache.

type Metadata

type Metadata struct {
	Mappings   []*base.Mapping
	OutArcInfo map[string]map[string][]translator.OutArcInfo
	InArcInfo  map[string][]translator.InArcInfo
	SubTypeMap map[string]string
	Bq         string
}

Metadata represents the metadata used by the server.

func NewMetadata

func NewMetadata(bqDataset string) (*Metadata, error)

NewMetadata initialize the metadata for translator.

type Node

type Node struct {
	Dcid   string   `json:"dcid,omitempty"`
	Name   string   `json:"name,omitempty"`
	ProvID string   `json:"provenanceId,omitempty"`
	Value  string   `json:"value,omitempty"`
	Types  []string `json:"types,omitempty"`
}

Node represents a information about a node.

type ObsTimeSeries added in v1.1.0

type ObsTimeSeries struct {
	Data             map[string]float64 `json:"data,omitempty"`
	PlaceName        string             `json:"placeName,omitempty"`
	PlaceDcid        string             `json:"placeDcid,omitempty"`
	SourceSeries     []*SourceSeries    `json:"sourceSeries,omitempty"`
	ProvenanceDomain string             `json:"provenanceDomain,omitempty"`
}

TODO(shifucun): deprecate the equivalant proto definition and use this throughout ObsTimeSeries repesents multiple time series data.

type PlacePopInfo

type PlacePopInfo struct {
	PlaceID      string `json:"dcid,omitempty"`
	PopulationID string `json:"population,omitempty"`
}

PlacePopInfo contains basic info for a place and a population.

type PlaceStatsVar

type PlaceStatsVar struct {
	StatVarIds []string `json:"statVarIds,omitempty"`
}

PlaceStatsVar contains the place stats var list.

type PopObs

type PopObs struct {
	PopulationID     string `json:"dcid,omitempty"`
	ObservationValue string `json:"observation,omitempty"`
}

PopObs represents a pair of population and observation node.

type PropLabelCache

type PropLabelCache struct {
	InLabels  []string `json:"inLabels"`
	OutLabels []string `json:"outLabels"`
}

PropLabelCache represents the json structure returned by the BT Prop cache

type PropValueCache

type PropValueCache struct {
	Nodes []*Node `json:"entities,omitempty"`
}

PropValueCache represents the json structure returned by the BT PropVal cache

type RelatedPlacesInfo

type RelatedPlacesInfo struct {
	RelatedPlaces    []string `json:"relatedPlaces,omitempty"`
	RankFromTop      int32    `json:"rankFromTop,omitempty"`
	RankFromBottom   int32    `json:"rankFromBottom,omitempty"`
	AllPlaces        []string `json:"allPlaces,omitempty"`
	Top1000Places    []string `json:"top1000Places,omitempty"`
	Bottom1000Places []string `json:"bottom1000Places,omitempty"`
}

RelatedPlacesInfo represents the json structure returned by the RelatedPlaces cache.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server holds resources for a mixer server

func NewServer

func NewServer(
	bqClient *bigquery.Client,
	btTable *bigtable.Table,
	memcache *Memcache,
	metadata *Metadata) *Server

NewServer creates a new server instance.

func (*Server) GetInterestingPlaceAspects

GetInterestingPlaceAspects implements API for Mixer.GetInterestingPlaceAspects.

func (*Server) GetLandingPage

func (s *Server) GetLandingPage(
	ctx context.Context, in *pb.GetLandingPageRequest) (
	*pb.GetLandingPageResponse, error)

GetLandingPage implements API for Mixer.GetLandingPage.

func (*Server) GetObservations

func (s *Server) GetObservations(
	ctx context.Context, in *pb.GetObservationsRequest) (
	*pb.GetObservationsResponse, error)

GetObservations implements API for Mixer.GetObservations.

func (*Server) GetPlaceObs

func (s *Server) GetPlaceObs(ctx context.Context, in *pb.GetPlaceObsRequest) (
	*pb.GetPlaceObsResponse, error)

GetPlaceObs implements API for Mixer.GetPlaceObs.

func (*Server) GetPlaceStatsVar

func (s *Server) GetPlaceStatsVar(
	ctx context.Context, in *pb.GetPlaceStatsVarRequest) (
	*pb.GetPlaceStatsVarResponse, error)

GetPlaceStatsVar implements API for Mixer.GetPlaceStatsVar.

func (*Server) GetPlacesIn

func (s *Server) GetPlacesIn(ctx context.Context, in *pb.GetPlacesInRequest) (
	*pb.GetPlacesInResponse, error)

GetPlacesIn implements API for Mixer.GetPlacesIn.

func (*Server) GetPlacesInPost

func (s *Server) GetPlacesInPost(ctx context.Context,
	in *pb.GetPlacesInRequest) (*pb.GetPlacesInResponse, error)

GetPlacesInPost implements API for Mixer.GetPlacesInPost.

func (*Server) GetPopObs

func (s *Server) GetPopObs(ctx context.Context, in *pb.GetPopObsRequest) (
	*pb.GetPopObsResponse, error)

GetPopObs implements API for Mixer.GetPopObs.

func (*Server) GetPopulations

func (s *Server) GetPopulations(
	ctx context.Context, in *pb.GetPopulationsRequest) (
	*pb.GetPopulationsResponse, error)

GetPopulations implements API for Mixer.GetPopulations.

func (*Server) GetPropertyLabels

GetPropertyLabels implements API for Mixer.GetPropertyLabels.

func (*Server) GetPropertyLabelsPost

func (s *Server) GetPropertyLabelsPost(ctx context.Context,
	in *pb.GetPropertyLabelsRequest) (*pb.GetPropertyLabelsResponse, error)

GetPropertyLabelsPost implements API for Mixer.GetPropertyLabelsPost.

func (*Server) GetPropertyValues

GetPropertyValues implements API for Mixer.GetPropertyValues.

func (*Server) GetPropertyValuesPost

func (s *Server) GetPropertyValuesPost(ctx context.Context,
	in *pb.GetPropertyValuesRequest) (*pb.GetPropertyValuesResponse, error)

GetPropertyValuesPost implements API for Mixer.GetPropertyValuesPost.

func (*Server) GetRelatedLocations

GetRelatedLocations implements API for Mixer.GetRelatedLocations.

func (*Server) GetStats

func (s *Server) GetStats(ctx context.Context, in *pb.GetStatsRequest) (
	*pb.GetStatsResponse, error)

GetStats implements API for Mixer.GetStats.

func (*Server) GetTriples

func (s *Server) GetTriples(ctx context.Context, in *pb.GetTriplesRequest) (
	*pb.GetTriplesResponse, error)

GetTriples implements API for Mixer.GetTriples.

func (*Server) GetTriplesPost

func (s *Server) GetTriplesPost(ctx context.Context,
	in *pb.GetTriplesRequest) (*pb.GetTriplesResponse, error)

GetTriplesPost implements API for Mixer.GetTriplesPost.

func (*Server) Query

func (s *Server) Query(
	ctx context.Context, in *pb.QueryRequest) (*pb.QueryResponse, error)

Query implements API for Mixer.Query.

func (*Server) QueryPost

func (s *Server) QueryPost(
	ctx context.Context, in *pb.QueryRequest) (*pb.QueryResponse, error)

QueryPost implements API for Mixer.QueryPost.

func (*Server) Search

func (s *Server) Search(
	ctx context.Context, in *pb.SearchRequest) (*pb.SearchResponse, error)

Search implements API for Mixer.Search.

func (*Server) SubscribeBranchCacheUpdate

func (s *Server) SubscribeBranchCacheUpdate(
	ctx context.Context, pubsubProjectID, branchCacheBucket, subscriberPrefix,
	pubsubTopic string) error

SubscribeBranchCacheUpdate subscribe server for branch cache update.

func (*Server) Translate

func (s *Server) Translate(ctx context.Context,
	in *pb.TranslateRequest) (*pb.TranslateResponse, error)

Translate implements API for Mixer.Translate.

type SourceSeries added in v1.1.0

type SourceSeries struct {
	ImportName        string             `json:"importName,omitempty"`
	ObservationPeriod string             `json:"observationPeriod,omitempty"`
	MeasurementMethod string             `json:"measurementMethod,omitempty"`
	ScalingFactor     string             `json:"scalingFactor,omitempty"`
	Unit              string             `json:"unit,omitempty"`
	ProvenanceDomain  string             `json:"provenanceDomain,omitempty"`
	Val               map[string]float64 `json:"val,omitempty"`
}

SourceSeries represents time series data for a particular source.

type StatisticalVariable

type StatisticalVariable struct {
	PopType                string            `json:"popType,omitempty"`
	PVs                    map[string]string `json:"pvs,omitempty"`
	MeasuredProp           string            `json:"measuredProp,omitempty"`
	MeasurementMethod      string            `json:"measurementMethod,omitempty"`
	MeasurementDenominator string            `json:"measurementDeonominator,omitempty"`
	MeasurementQualifier   string            `json:"measurementQualifier,omitempty"`
	ScalingFactor          string            `json:"scalingFactor,omitempty"`
	Unit                   string            `json:"unit,omitempty"`
	StatType               string            `json:"statType,omitempty"`
}

StatisticalVariable contains key info of population and observation.

type Triple

type Triple struct {
	SubjectID    string   `json:"subjectId,omitempty"`
	SubjectName  string   `json:"subjectName,omitempty"`
	SubjectTypes []string `json:"subjectTypes,omitempty"`
	Predicate    string   `json:"predicate,omitempty"`
	ObjectID     string   `json:"objectId,omitempty"`
	ObjectName   string   `json:"objectName,omitempty"`
	ObjectValue  string   `json:"objectValue,omitempty"`
	ObjectTypes  []string `json:"objectTypes,omitempty"`
	ProvenanceID string   `json:"provenanceId,omitempty"`
}

Triple represents a triples entry in the BT triples cache.

type TriplesCache

type TriplesCache struct {
	Triples []*Triple `json:"triples"`
}

TriplesCache represents the json structure returned by the BT triples cache

Jump to

Keyboard shortcuts

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