Skip to content

Commit

Permalink
GOCBC-571: Rename *ResultMetadata to *Metadata
Browse files Browse the repository at this point in the history
Motivation
----------
For http services the RFC states that metadata on results should
be *Metadata rather than *ResultMetadata.

Changes
-------
Change *ResultMetadata to *Metadata and clean up search facet names
too.

Change-Id: Ic74a4fe6647e3ad978bd1f520332d7cb3050a3e0
Reviewed-on: http://review.couchbase.org/114955
Reviewed-by: Mike Goldsmith <goldsmith.mike@gmail.com>
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Charles Dixon <chvckd@gmail.com>
  • Loading branch information
chvck committed Sep 19, 2019
1 parent 5438ab6 commit b7b1b35
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 65 deletions.
10 changes: 5 additions & 5 deletions bucket_viewquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ type ViewRow struct {
value json.RawMessage
}

// ViewResultsMetadata provides access to the metadata properties of a view query result.
type ViewResultsMetadata struct {
// ViewMetadata provides access to the metadata properties of a view query result.
type ViewMetadata struct {
totalRows int
}

// ViewResult implements an iterator interface which can be used to iterate over the rows of the query results.
type ViewResult struct {
metadata ViewResultsMetadata
metadata ViewMetadata
errReason string
errMessage string

Expand Down Expand Up @@ -242,7 +242,7 @@ func (r *ViewResult) One(rowPtr *ViewRow) error {
}

// Metadata returns metadata for this result.
func (r *ViewResult) Metadata() (*ViewResultsMetadata, error) {
func (r *ViewResult) Metadata() (*ViewMetadata, error) {
if r.streamResult != nil && !r.streamResult.Closed() {
return nil, errors.New("result must be closed before accessing meta-data")
}
Expand All @@ -251,7 +251,7 @@ func (r *ViewResult) Metadata() (*ViewResultsMetadata, error) {
}

// TotalRows returns the total number of rows in the view, can be greater than the number of rows returned.
func (r *ViewResultsMetadata) TotalRows() int {
func (r *ViewMetadata) TotalRows() int {
return r.totalRows
}

Expand Down
30 changes: 15 additions & 15 deletions cluster_analyticsquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ type analyticsResponseMetrics struct {
ProcessedObjects uint `json:"processedObjects,omitempty"`
}

// AnalyticsResultMetrics encapsulates various metrics gathered during a queries execution.
type AnalyticsResultMetrics struct {
// AnalyticsMetrics encapsulates various metrics gathered during a queries execution.
type AnalyticsMetrics struct {
ElapsedTime time.Duration
ExecutionTime time.Duration
ResultCount uint
Expand All @@ -53,20 +53,20 @@ type AnalyticsResultMetrics struct {
ProcessedObjects uint
}

// AnalyticsResultsMetadata provides access to the metadata properties of an Analytics query result.
type AnalyticsResultsMetadata struct {
// AnalyticsMetadata provides access to the metadata properties of an Analytics query result.
type AnalyticsMetadata struct {
requestID string
clientContextID string
status string
warnings []AnalyticsWarning
signature interface{}
metrics AnalyticsResultMetrics
metrics AnalyticsMetrics
sourceAddr string
}

// AnalyticsResult allows access to the results of an Analytics query.
type AnalyticsResult struct {
metadata AnalyticsResultsMetadata
metadata AnalyticsMetadata
err error
httpStatus int

Expand Down Expand Up @@ -159,7 +159,7 @@ func (r *AnalyticsResult) One(valuePtr interface{}) error {
}

// Metadata returns metadata for this result.
func (r *AnalyticsResult) Metadata() (*AnalyticsResultsMetadata, error) {
func (r *AnalyticsResult) Metadata() (*AnalyticsMetadata, error) {
if !r.streamResult.Closed() {
return nil, errors.New("result must be closed before accessing meta-data")
}
Expand All @@ -168,32 +168,32 @@ func (r *AnalyticsResult) Metadata() (*AnalyticsResultsMetadata, error) {
}

// Warnings returns any warnings that occurred during query execution.
func (r *AnalyticsResultsMetadata) Warnings() []AnalyticsWarning {
func (r *AnalyticsMetadata) Warnings() []AnalyticsWarning {
return r.warnings
}

// Status returns the status for the results.
func (r *AnalyticsResultsMetadata) Status() string {
func (r *AnalyticsMetadata) Status() string {
return r.status
}

// Signature returns TODO
func (r *AnalyticsResultsMetadata) Signature() interface{} {
func (r *AnalyticsMetadata) Signature() interface{} {
return r.signature
}

// Metrics returns metrics about execution of this result.
func (r *AnalyticsResultsMetadata) Metrics() AnalyticsResultMetrics {
func (r *AnalyticsMetadata) Metrics() AnalyticsMetrics {
return r.metrics
}

// RequestID returns the request ID used for this query.
func (r *AnalyticsResultsMetadata) RequestID() string {
func (r *AnalyticsMetadata) RequestID() string {
return r.requestID
}

// ClientContextID returns the context ID used for this query.
func (r *AnalyticsResultsMetadata) ClientContextID() string {
func (r *AnalyticsMetadata) ClientContextID() string {
return r.clientContextID
}

Expand Down Expand Up @@ -225,7 +225,7 @@ func (r *AnalyticsResult) readAttribute(decoder *json.Decoder, t json.Token) (bo
logDebugf("Failed to parse execution time duration (%s)", err)
}

r.metadata.metrics = AnalyticsResultMetrics{
r.metadata.metrics = AnalyticsMetrics{
ElapsedTime: elapsedTime,
ExecutionTime: executionTime,
ResultCount: metrics.ResultCount,
Expand Down Expand Up @@ -424,7 +424,7 @@ func (c *Cluster) executeAnalyticsQuery(ctx context.Context, opts map[string]int
}

queryResults := &AnalyticsResult{
metadata: AnalyticsResultsMetadata{
metadata: AnalyticsMetadata{
sourceAddr: epInfo.Host,
},
httpStatus: resp.StatusCode,
Expand Down
30 changes: 15 additions & 15 deletions cluster_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ type QueryWarning struct {
Message string `json:"msg"`
}

// QueryResultMetrics encapsulates various metrics gathered during a queries execution.
type QueryResultMetrics struct {
// QueryMetrics encapsulates various metrics gathered during a queries execution.
type QueryMetrics struct {
ElapsedTime time.Duration
ExecutionTime time.Duration
ResultCount uint
Expand All @@ -55,11 +55,11 @@ type QueryResultMetrics struct {
WarningCount uint
}

// QueryResultsMetadata provides access to the metadata properties of a N1QL query result.
type QueryResultsMetadata struct {
// QueryMetadata provides access to the metadata properties of a N1QL query result.
type QueryMetadata struct {
requestID string
clientContextID string
metrics QueryResultMetrics
metrics QueryMetrics
signature interface{}
warnings []QueryWarning
sourceAddr string
Expand All @@ -68,7 +68,7 @@ type QueryResultsMetadata struct {

// QueryResult allows access to the results of a N1QL query.
type QueryResult struct {
metadata QueryResultsMetadata
metadata QueryMetadata
preparedName string
err error
httpStatus int
Expand Down Expand Up @@ -162,7 +162,7 @@ func (r *QueryResult) One(valuePtr interface{}) error {
}

// Metadata returns metadata for this result.
func (r *QueryResult) Metadata() (*QueryResultsMetadata, error) {
func (r *QueryResult) Metadata() (*QueryMetadata, error) {
if !r.streamResult.Closed() {
return nil, errors.New("result must be closed before accessing meta-data")
}
Expand All @@ -171,32 +171,32 @@ func (r *QueryResult) Metadata() (*QueryResultsMetadata, error) {
}

// RequestID returns the request ID used for this query.
func (r *QueryResultsMetadata) RequestID() string {
func (r *QueryMetadata) RequestID() string {
return r.requestID
}

// Profile returns the profile generated for this query.
func (r *QueryResultsMetadata) Profile() interface{} {
func (r *QueryMetadata) Profile() interface{} {
return r.profile
}

// ClientContextID returns the context ID used for this query.
func (r *QueryResultsMetadata) ClientContextID() string {
func (r *QueryMetadata) ClientContextID() string {
return r.clientContextID
}

// Metrics returns metrics about execution of this result.
func (r *QueryResultsMetadata) Metrics() QueryResultMetrics {
func (r *QueryMetadata) Metrics() QueryMetrics {
return r.metrics
}

// Warnings returns any warnings that were generated during execution of the query.
func (r *QueryResultsMetadata) Warnings() []QueryWarning {
func (r *QueryMetadata) Warnings() []QueryWarning {
return r.warnings
}

// Signature returns the schema of the results.
func (r *QueryResultsMetadata) Signature() interface{} {
func (r *QueryMetadata) Signature() interface{} {
return r.signature
}

Expand Down Expand Up @@ -233,7 +233,7 @@ func (r *QueryResult) readAttribute(decoder *json.Decoder, t json.Token) (bool,
logDebugf("Failed to parse execution time duration (%s)", err)
}

r.metadata.metrics = QueryResultMetrics{
r.metadata.metrics = QueryMetrics{
ElapsedTime: elapsedTime,
ExecutionTime: executionTime,
ResultCount: metrics.ResultCount,
Expand Down Expand Up @@ -583,7 +583,7 @@ func (c *Cluster) executeN1qlQuery(ctx context.Context, opts map[string]interfac
}

queryResults := &QueryResult{
metadata: QueryResultsMetadata{
metadata: QueryMetadata{
sourceAddr: epInfo.Host,
},
httpStatus: resp.StatusCode,
Expand Down
60 changes: 30 additions & 30 deletions cluster_searchquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,41 +32,41 @@ type SearchResultRow struct {
Fields map[string]interface{} `json:"fields,omitempty"`
}

// SearchResultTermFacet holds the results of a term facet in search results.
type SearchResultTermFacet struct {
// TermFacetResult holds the results of a term facet in search results.
type TermFacetResult struct {
Term string `json:"term,omitempty"`
Count int `json:"count,omitempty"`
}

// SearchResultNumericFacet holds the results of a numeric facet in search results.
type SearchResultNumericFacet struct {
// NumericFacetResult holds the results of a numeric facet in search results.
type NumericFacetResult struct {
Name string `json:"name,omitempty"`
Min float64 `json:"min,omitempty"`
Max float64 `json:"max,omitempty"`
Count int `json:"count,omitempty"`
}

// SearchResultDateFacet holds the results of a date facet in search results.
type SearchResultDateFacet struct {
// DateFacetResult holds the results of a date facet in search results.
type DateFacetResult struct {
Name string `json:"name,omitempty"`
Min string `json:"min,omitempty"`
Max string `json:"max,omitempty"`
Count int `json:"count,omitempty"`
}

// SearchResultFacet holds the results of a specified facet in search results.
type SearchResultFacet struct {
Field string `json:"field,omitempty"`
Total int `json:"total,omitempty"`
Missing int `json:"missing,omitempty"`
Other int `json:"other,omitempty"`
Terms []SearchResultTermFacet `json:"terms,omitempty"`
NumericRanges []SearchResultNumericFacet `json:"numeric_ranges,omitempty"`
DateRanges []SearchResultDateFacet `json:"date_ranges,omitempty"`
// FacetResult holds the results of a specified facet in search results.
type FacetResult struct {
Field string `json:"field,omitempty"`
Total int `json:"total,omitempty"`
Missing int `json:"missing,omitempty"`
Other int `json:"other,omitempty"`
Terms []TermFacetResult `json:"terms,omitempty"`
NumericRanges []NumericFacetResult `json:"numeric_ranges,omitempty"`
DateRanges []DateFacetResult `json:"date_ranges,omitempty"`
}

// SearchResultStatus holds the status information for an executed search query.
type SearchResultStatus struct {
// SearchStatus holds the status information for an executed search query.
type SearchStatus struct {
Total int `json:"total,omitempty"`
Failed int `json:"failed,omitempty"`
Successful int `json:"successful,omitempty"`
Expand All @@ -88,9 +88,9 @@ type searchResponseStatus struct {
Errors interface{} `json:"errors,omitempty"`
}

// SearchResultsMetadata provides access to the metadata properties of a search query result.
type SearchResultsMetadata struct {
status SearchResultStatus
// SearchMetadata provides access to the metadata properties of a search query result.
type SearchMetadata struct {
status SearchStatus
totalHits int
took uint
maxScore float64
Expand All @@ -99,9 +99,9 @@ type SearchResultsMetadata struct {

// SearchResult allows access to the results of a search query.
type SearchResult struct {
metadata SearchResultsMetadata
metadata SearchMetadata
err error
facets map[string]SearchResultFacet
facets map[string]FacetResult

httpStatus int
streamResult *streamingResult
Expand Down Expand Up @@ -241,7 +241,7 @@ func (r *SearchResult) One(rowPtr *SearchResultRow) error {
}

// Metadata returns metadata for this result.
func (r *SearchResult) Metadata() (*SearchResultsMetadata, error) {
func (r *SearchResult) Metadata() (*SearchMetadata, error) {
if !r.streamResult.Closed() {
return nil, errors.New("result must be closed before accessing meta-data")
}
Expand All @@ -250,22 +250,22 @@ func (r *SearchResult) Metadata() (*SearchResultsMetadata, error) {
}

// SuccessCount is the number of successes for the results.
func (r SearchResultsMetadata) SuccessCount() int {
func (r SearchMetadata) SuccessCount() int {
return r.status.Successful
}

// ErrorCount is the number of errors for the results.
func (r SearchResultsMetadata) ErrorCount() int {
func (r SearchMetadata) ErrorCount() int {
return r.status.Failed
}

// TotalRows is the actual number of rows before the limit was applied.
func (r SearchResultsMetadata) TotalRows() int {
func (r SearchMetadata) TotalRows() int {
return r.totalHits
}

// Facets contains the information relative to the facets requested in the search query.
func (r SearchResult) Facets() (map[string]SearchResultFacet, error) {
func (r SearchResult) Facets() (map[string]FacetResult, error) {
if !r.streamResult.Closed() {
return nil, errors.New("result must be closed before accessing meta-data")
}
Expand All @@ -274,12 +274,12 @@ func (r SearchResult) Facets() (map[string]SearchResultFacet, error) {
}

// Took returns the time taken to execute the search.
func (r SearchResultsMetadata) Took() time.Duration {
func (r SearchMetadata) Took() time.Duration {
return time.Duration(r.took) / time.Nanosecond
}

// MaxScore returns the highest score of all documents for this query.
func (r SearchResultsMetadata) MaxScore() float64 {
func (r SearchMetadata) MaxScore() float64 {
return r.maxScore
}

Expand Down Expand Up @@ -585,7 +585,7 @@ func (c *Cluster) executeSearchQuery(ctx context.Context, query jsonx.DelayedObj
}

queryResults := &SearchResult{
metadata: SearchResultsMetadata{
metadata: SearchMetadata{
sourceAddr: epInfo.Host,
},
httpStatus: resp.StatusCode,
Expand Down

0 comments on commit b7b1b35

Please sign in to comment.