Skip to content

Commit

Permalink
Improved documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-asplin-met-no committed Dec 19, 2023
1 parent 09553f6 commit 7f49fd9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
35 changes: 23 additions & 12 deletions datastore/protobuf/datastore.proto
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ message TSMetadata {
repeated Link links = 1;
// --- END non-string metadata -----------------

// --- BEGIN string metadata -----------------
// --- BEGIN string metadata (handleable with reflection) -----------------
string version = 2;
string type = 3;
string title = 4;
Expand Down Expand Up @@ -115,7 +115,7 @@ message ObsMetadata {
google.protobuf.Timestamp pubtime = 5;
// --- END non-string metadata -----------------

// --- BEGIN string metadata -----------------
// --- BEGIN string metadata (handleable with reflection) -----------------
string id = 6;
string data_id = 7 [json_name = "data_id"];
string history = 8;
Expand Down Expand Up @@ -152,14 +152,29 @@ message PutObsResponse {
//---------------------------------------------------------------------------

message GetObsRequest {
// --- BEGIN special handling of temporal and spatial search -----------------
// --- BEGIN non-string metadata -------------------------

// temporal search
TimeInterval interval = 1; // only return observations in this time range

// spatial search
Polygon inside = 2; // if specified, only return observations in this area
// --- END special handling of temporal and spatial search -----------------

// --- BEGIN general handling of strings; field names must correspond exactly with string field names in TSMetadata or ObsMetadata -----
// - if the field F is specified (where F is for example 'platform'), only observations matching at least one these values for F will be returned
// - if the field F is not specified, filtering on F is effectively disabled
// search wrt. TSMetadata.links
// TODO - needs special handling

// --- END non-string metadata -------------------------


// --- BEGIN string metadata (handleable with reflection) -------------------------
//
// - field names must correspond exactly with string field names in TSMetadata or ObsMetadata
//
// - if the field F is specified (where F is for example 'platform'), only observations
// matching at least one these values for F will be returned
//
// - if the field F is not specified, filtering on F is effectively disabled

repeated string version = 3;
repeated string type = 4;
repeated string title = 5;
Expand Down Expand Up @@ -187,11 +202,7 @@ message GetObsRequest {
repeated string history = 27;
repeated string metadata_id = 28 [json_name = "metadata_id"];
repeated string processing_level = 29 [json_name = "processing_level"];
// --- END general handling of strings -----

// --- BEGIN special handling of 'repeated Link' ------
// TODO
// --- END special handling of 'repeated Link' ------
// --- END string metadata -------------------------------------
}

message GetObsResponse {
Expand Down
10 changes: 5 additions & 5 deletions datastore/storagebackend/postgresql/getobservations.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func scanTSRow(rows *sql.Rows) (*datastore.TSMetadata, int64, error) {
&linkTitle,
}

// complete colValPtrs with string metadata
// complete colValPtrs with string metadata (handleable with reflection)
colVals0 := make([]interface{}, len(tsStringMdataGoNames))
for i := range tsStringMdataGoNames {
colValPtrs = append(colValPtrs, &colVals0[i])
Expand All @@ -151,7 +151,7 @@ func scanTSRow(rows *sql.Rows) (*datastore.TSMetadata, int64, error) {
Links: links,
}

// complete tsMdata with string metadata
// complete tsMdata with string metadata (handleable with reflection)
err := addStringMdata(reflect.ValueOf(&tsMdata), tsStringMdataGoNames, colVals0)
if err != nil {
return nil, -1, fmt.Errorf("addStringMdata() failed: %v", err)
Expand Down Expand Up @@ -220,7 +220,7 @@ type stringFilterInfo struct {
colName string
patterns []string
}
// TODO: add filter infos for non-string types
// TODO: add filter info for non-string types

// getMdataFilter derives from stringFilterInfos the expression used in a WHERE clause for
// "match any" filtering on a set of attributes.
Expand Down Expand Up @@ -403,7 +403,7 @@ func scanObsRow(rows *sql.Rows) (*datastore.ObsMetadata, int64, error) {
&point,
}

// complete colValPtrs with string metadata
// complete colValPtrs with string metadata (handleable with reflection)
colVals0 := make([]interface{}, len(obsStringMdataGoNames))
for i := range obsStringMdataGoNames {
colValPtrs = append(colValPtrs, &colVals0[i])
Expand All @@ -429,7 +429,7 @@ func scanObsRow(rows *sql.Rows) (*datastore.ObsMetadata, int64, error) {
Value: value,
}

// complete obsMdata with string metadata
// complete obsMdata with string metadata (handleable with reflection)
err := addStringMdata(reflect.ValueOf(&obsMdata), obsStringMdataGoNames, colVals0)
if err != nil {
return nil, -1, fmt.Errorf("addStringMdata() failed: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion datastore/storagebackend/postgresql/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func getTSMdataCols() []string {
"link_title",
}

// complete cols with string metadata
// complete cols with string metadata (handleable with reflection)
cols = append(cols, tsStringMdataPBNames...)

return cols
Expand Down
2 changes: 1 addition & 1 deletion datastore/storagebackend/postgresql/putobservations.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func getTSColVals(tsMdata *datastore.TSMetadata) ([]interface{}, error) {

// --- END non-string metadata ---------------------------

// --- BEGIN string metadata ---------------------------
// --- BEGIN string metadata (handleable with reflection) ---------------------------

rv := reflect.ValueOf(tsMdata)
for _, field := range reflect.VisibleFields(reflect.TypeOf(datastore.TSMetadata{})) {
Expand Down
2 changes: 1 addition & 1 deletion datastore/ts-init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CREATE TABLE time_series (
link_title TEXT[],
-- --- END non-string metadata -----------------

-- --- BEGIN string metadata -----------------
-- --- BEGIN string metadata (handleable with reflection) -----------------
version TEXT NOT NULL, -- required
type TEXT NOT NULL, -- required
title TEXT,
Expand Down

0 comments on commit 7f49fd9

Please sign in to comment.