Documentation
¶
Index ¶
- Constants
- Variables
- func NewBtTable(ctx context.Context, projectID, instanceID, tableID string) (*bigtable.Table, error)
- func ReadBranchCacheFolder(ctx context.Context, bucket, versionFile string) (string, error)
- type LandingPageData
- type LandingPageResponse
- type Memcache
- type Metadata
- type Node
- type ObsProp
- type ObsTimeSeries
- type PlacePopInfo
- type PlaceStatsVar
- type PopObs
- type PropLabelCache
- type PropValueCache
- type RankKey
- type RelatedPlacesInfo
- type SeriesByRank
- type Server
- func (s *Server) GetLandingPageData(ctx context.Context, in *pb.GetLandingPageDataRequest) (*pb.GetLandingPageDataResponse, error)
- func (s *Server) GetLocationsRankings(ctx context.Context, in *pb.GetLocationsRankingsRequest) (*pb.GetLocationsRankingsResponse, error)
- func (s *Server) GetObservations(ctx context.Context, in *pb.GetObservationsRequest) (*pb.GetObservationsResponse, error)
- func (s *Server) GetPlaceObs(ctx context.Context, in *pb.GetPlaceObsRequest) (*pb.GetPlaceObsResponse, error)
- func (s *Server) GetPlaceStatVars(ctx context.Context, in *pb.GetPlaceStatVarsRequest) (*pb.GetPlaceStatVarsResponse, error)
- func (s *Server) GetPlaceStatVarsUnion(ctx context.Context, in *pb.GetPlaceStatVarsUnionRequest) (*pb.GetPlaceStatVarsUnionResponse, error)
- func (s *Server) GetPlaceStatsVar(ctx context.Context, in *pb.GetPlaceStatsVarRequest) (*pb.GetPlaceStatsVarResponse, error)
- func (s *Server) GetPlacesIn(ctx context.Context, in *pb.GetPlacesInRequest) (*pb.GetPlacesInResponse, error)
- func (s *Server) GetPopObs(ctx context.Context, in *pb.GetPopObsRequest) (*pb.GetPopObsResponse, error)
- func (s *Server) GetPopulations(ctx context.Context, in *pb.GetPopulationsRequest) (*pb.GetPopulationsResponse, error)
- func (s *Server) GetPropertyLabels(ctx context.Context, in *pb.GetPropertyLabelsRequest) (*pb.GetPropertyLabelsResponse, error)
- func (s *Server) GetPropertyValues(ctx context.Context, in *pb.GetPropertyValuesRequest) (*pb.GetPropertyValuesResponse, error)
- func (s *Server) GetRelatedLocations(ctx context.Context, in *pb.GetRelatedLocationsRequest) (*pb.GetRelatedLocationsResponse, error)
- func (s *Server) GetStat(ctx context.Context, in *pb.GetStatRequest) (*pb.GetStatResponse, error)
- func (s *Server) GetStatAll(ctx context.Context, in *pb.GetStatAllRequest) (*pb.GetStatAllResponse, error)
- func (s *Server) GetStatCollection(ctx context.Context, in *pb.GetStatCollectionRequest) (*pb.GetStatCollectionResponse, error)
- func (s *Server) GetStatSeries(ctx context.Context, in *pb.GetStatSeriesRequest) (*pb.GetStatSeriesResponse, error)
- func (s *Server) GetStatSet(ctx context.Context, in *pb.GetStatSetRequest) (*pb.GetStatSetResponse, error)
- func (s *Server) GetStatValue(ctx context.Context, in *pb.GetStatValueRequest) (*pb.GetStatValueResponse, error)
- func (s *Server) GetStats(ctx context.Context, in *pb.GetStatsRequest) (*pb.GetStatsResponse, error)
- func (s *Server) GetTriples(ctx context.Context, in *pb.GetTriplesRequest) (*pb.GetTriplesResponse, error)
- func (s *Server) Query(ctx context.Context, in *pb.QueryRequest) (*pb.QueryResponse, error)
- func (s *Server) Search(ctx context.Context, in *pb.SearchRequest) (*pb.SearchResponse, error)
- func (s *Server) SubscribeBranchCacheUpdate(ctx context.Context, ...) error
- func (s *Server) Translate(ctx context.Context, in *pb.TranslateRequest) (*pb.TranslateResponse, error)
- type SourceSeries
- type StatisticalVariable
- type Triple
- type TriplesCache
Constants ¶
const LowestRank = 100
LowestRank is the lowest ranking score.
Variables ¶
var RelatedLocationsPrefixMap = 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 locations have the same ancestor. - Whether related locations have the same place type. - Whether closeness computaion is per capita.
var StatsRanking = map[RankKey]int{
{"CensusPEP", "CensusPEPSurvey"}: 0,
{"CensusACS5YearSurvey", "CensusACS5yrSurvey"}: 1,
{"CensusACS5YearSurvey_AggCountry", "dcAggregate/CensusACS5yrSurvey"}: 1,
{"CensusUSAMedianAgeIncome", "CensusACS5yrSurvey"}: 1,
{"EurostatData", "EurostatRegionalPopulationData"}: 2,
{"WorldDevelopmentIndicators", ""}: 3,
{"BLS_LAUS", "BLSSeasonallyUnadjusted"}: 0,
{"EurostatData", ""}: 1,
{"NYT_COVID19", "NYT_COVID19_GitHub"}: 0,
{"CDC500", "AgeAdjustedPrevalence"}: 0,
}
StatsRanking is used to rank multiple source series for the same StatisticalVariable, where lower value means higher ranking. The ranking score ranges from 0 to 100.
Functions ¶
Types ¶
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 LandingPageResponse ¶ added in v1.6.0
type LandingPageResponse struct {
Data map[string]map[string]*ObsTimeSeries `json:"data,omitempty"`
AllChildPlaces map[string][]*place `json:"allChildPlaces,omitempty"`
ChildPlacesType string `json:"childPlacesType,omitempty"`
ChildPlaces []string `json:"childPlaces,omitempty"`
ParentPlaces []string `json:"parentPlaces,omitempty"`
SimilarPlaces []string `json:"similarPlaces,omitempty"`
NearbyPlaces []string `json:"nearbyPlaces,omitempty"`
}
LandingPageResponse represents all the data needed for rendering landing page.
type Memcache ¶
Memcache represents a Read Write locked object for in-memory key-value cache.
func NewMemcache ¶
NewMemcache initialize a new Memcache instance from a key value map.
func NewMemcacheFromGCS ¶
NewMemcacheFromGCS initialize a Memcache instance from a Google Cloud Storage folder.
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.
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 ¶
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"`
ProvenanceURL string `json:"provenanceUrl,omitempty"`
}
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"`
}
RelatedPlacesInfo represents the json structure returned by the RelatedPlaces cache.
type SeriesByRank ¶ added in v1.7.0
type SeriesByRank []*pb.SourceSeries
SeriesByRank implements sort.Interface for []*SourceSeries based on the rank score. protobuf version of byRank. TODO(shifucun): add observationPeriod, unit, scalingFactor to ranking decision, so the ranking is deterministic.
func (SeriesByRank) Len ¶ added in v1.7.0
func (a SeriesByRank) Len() int
func (SeriesByRank) Less ¶ added in v1.7.0
func (a SeriesByRank) Less(i, j int) bool
func (SeriesByRank) Swap ¶ added in v1.7.0
func (a SeriesByRank) Swap(i, j int)
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) GetLandingPageData ¶ added in v1.6.0
func (s *Server) GetLandingPageData( ctx context.Context, in *pb.GetLandingPageDataRequest) ( *pb.GetLandingPageDataResponse, error)
GetLandingPageData implements API for Mixer.GetLandingPageData.
TODO(shifucun):For each related place, it is supposed to have dcid, name and population but it's not complete now as the client in most cases only requires the dcid. Should consider have the full name, even with parent place abbreviations like "CA" filled in here so the client won't bother to fetch those again.
func (*Server) GetLocationsRankings ¶ added in v1.4.0
func (s *Server) GetLocationsRankings(ctx context.Context, in *pb.GetLocationsRankingsRequest) (*pb.GetLocationsRankingsResponse, error)
GetLocationsRankings implements API for Mixer.GetLocationsRankings.
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) GetPlaceStatVars ¶ added in v1.11.0
func (s *Server) GetPlaceStatVars( ctx context.Context, in *pb.GetPlaceStatVarsRequest) ( *pb.GetPlaceStatVarsResponse, error)
GetPlaceStatVars implements API for Mixer.GetPlaceStatVars.
func (*Server) GetPlaceStatVarsUnion ¶ added in v1.11.0
func (s *Server) GetPlaceStatVarsUnion( ctx context.Context, in *pb.GetPlaceStatVarsUnionRequest) ( *pb.GetPlaceStatVarsUnionResponse, error)
GetPlaceStatVarsUnion implements API for Mixer.GetPlaceStatVarsUnion.
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) 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 ¶
func (s *Server) GetPropertyLabels(ctx context.Context, in *pb.GetPropertyLabelsRequest) (*pb.GetPropertyLabelsResponse, error)
GetPropertyLabels implements API for Mixer.GetPropertyLabels.
func (*Server) GetPropertyValues ¶
func (s *Server) GetPropertyValues(ctx context.Context, in *pb.GetPropertyValuesRequest) (*pb.GetPropertyValuesResponse, error)
GetPropertyValues implements API for Mixer.GetPropertyValues.
func (*Server) GetRelatedLocations ¶
func (s *Server) GetRelatedLocations(ctx context.Context, in *pb.GetRelatedLocationsRequest) (*pb.GetRelatedLocationsResponse, error)
GetRelatedLocations implements API for Mixer.GetRelatedLocations.
func (*Server) GetStat ¶ added in v1.7.0
func (s *Server) GetStat(ctx context.Context, in *pb.GetStatRequest) ( *pb.GetStatResponse, error)
GetStat implements API for Mixer.GetStat. Endpoint: /stat/series/rich
func (*Server) GetStatAll ¶ added in v1.2.0
func (s *Server) GetStatAll(ctx context.Context, in *pb.GetStatAllRequest) ( *pb.GetStatAllResponse, error)
GetStatAll implements API for Mixer.GetStatAll. Endpoint: /stat/set/series/all Endpoint: /stat/all
func (*Server) GetStatCollection ¶ added in v1.7.0
func (s *Server) GetStatCollection( ctx context.Context, in *pb.GetStatCollectionRequest) ( *pb.GetStatCollectionResponse, error)
GetStatCollection implements API for Mixer.GetStatCollection. Endpoint: /stat/set/within-place Endpoint: /stat/collection
func (*Server) GetStatSeries ¶ added in v1.2.0
func (s *Server) GetStatSeries( ctx context.Context, in *pb.GetStatSeriesRequest) ( *pb.GetStatSeriesResponse, error)
GetStatSeries implements API for Mixer.GetStatSeries. Endpoint: /stat/series TODO(shifucun): consilidate and dedup the logic among these similar APIs.
func (*Server) GetStatSet ¶ added in v1.11.0
func (s *Server) GetStatSet(ctx context.Context, in *pb.GetStatSetRequest) ( *pb.GetStatSetResponse, error)
GetStatSet implements API for Mixer.GetStatSet. Endpoint: /stat/set
func (*Server) GetStatValue ¶ added in v1.2.0
func (s *Server) GetStatValue(ctx context.Context, in *pb.GetStatValueRequest) ( *pb.GetStatValueResponse, error)
GetStatValue implements API for Mixer.GetStatValue. Endpoint: /stat (/stat/value)
func (*Server) GetStats ¶
func (s *Server) GetStats(ctx context.Context, in *pb.GetStatsRequest) ( *pb.GetStatsResponse, error)
GetStats implements API for Mixer.GetStats. Endpoint: /stat/set/series Endpoint: /bulk/stats
func (*Server) GetTriples ¶
func (s *Server) GetTriples(ctx context.Context, in *pb.GetTriplesRequest) ( *pb.GetTriplesResponse, error)
GetTriples implements API for Mixer.GetTriples.
func (*Server) Query ¶
func (s *Server) Query( ctx context.Context, in *pb.QueryRequest) (*pb.QueryResponse, error)
Query implements API for Mixer.Query.
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"`
ProvenanceURL string `json:"provenanceUrl,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