// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package fcp.client;

import "fcp/client/event_time_range.proto";

option java_package = "com.google.intelligence.fcp.client";
option java_multiple_files = true;
option objc_class_prefix = "FCPC";

// Describes the result of an example query, as a series of vectors. Example
// iterators invoked using `ExampleQuerySpec` are expected to return a single
// result that is a serialized proto of this type.
message ExampleQueryResult {
  message VectorData {
    message Int32Values {
      repeated int32 value = 1;
    }

    message Int64Values {
      repeated int64 value = 1;
    }

    message BoolValues {
      repeated bool value = 1;
    }

    message FloatValues {
      repeated float value = 1;
    }

    message DoubleValues {
      repeated double value = 1;
    }

    message StringValues {
      repeated string value = 1;
    }

    message BytesValues {
      repeated bytes value = 1;
    }

    message Values {
      oneof values {
        Int32Values int32_values = 1;
        Int64Values int64_values = 2;
        BoolValues bool_values = 3;
        FloatValues float_values = 4;
        DoubleValues double_values = 5;
        StringValues string_values = 6;
        BytesValues bytes_values = 7;
      }
    }

    // Maps a name of the result vector to its values.
    map<string, Values> vectors = 1;
  }

  // Vector data fetched from the example store.
  VectorData vector_data = 1;

  message ExampleQueryStats {
    // The total number of "logical" output rows produced by the query, which
    // cannot otherwise be deduced from the produced vector data itself. This
    // can be used both for logging purposes and to compare against a minimum
    // number of outputs rows that must be produced by the query in order for
    // the device to be eligible.
    int32 output_rows_count = 1;

    // Deprecated. Maps the query name to the event time range of the query
    // results.
    map<string, EventTimeRange> event_time_range = 2 [deprecated = true];

    // The event time range of all query results.
    EventTimeRange cross_query_event_time_range = 3;
  }

  // Statistic data and properties of an example query.
  ExampleQueryStats stats = 2;

  enum ResultSource {
    // The result source is unknown. Treated as EXAMPLE_STORE for backwards
    // compatibility.
    UNKNOWN = 0;
    // The result was fetched from the example store.
    EXAMPLE_STORE = 1;
    // The result was fetched from the private logger.
    PRIVATE_LOGGER = 2;
  }
  ResultSource result_source = 3;
}
