// Copyright 2015 gRPC authors.
//
// 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";

//option java_multiple_files = true;
//option java_package = "io.grpc.examples.helloworld";
//option java_outer_classname = "HelloWorldProto";
//option objc_class_prefix = "HLW";

package SCAMPProto;

message SCAMPWork {
  SCAMPArgs args = 1;
  bool valid = 2;
}

// The greeting service definition.
service SCAMPService {
  rpc RequestSCAMPWork (SCAMPRequest) returns (SCAMPWork) {}
  rpc SCAMPCombiner (SCAMPArgs) returns (SCAMPResult) {}
  rpc ReportTileFailure (SCAMPArgs) returns (SCAMPResult) {}
  rpc IssueNewJob (SCAMPArgs) returns (SCAMPStatus) {}
  rpc CheckJobStatus (SCAMPJobID) returns (SCAMPStatus) {}
  rpc FetchJobResult (SCAMPJobID) returns (SCAMPWork) {}
}

message SCAMPStatus {
  int64 job_id = 1;
  JobStatus status = 2;
  float progress = 3;
  int64 time_elapsed = 4;
  int64 eta = 5;
}

message SCAMPJobID {
  uint64 job_id = 1;
}

message SCAMPRequest {
  int64 expected_throughput = 1;
}

message SCAMPResult {
}

enum JobStatus {
  JOB_STATUS_INVALID = 0;
  JOB_STATUS_READY = 1;
  JOB_STATUS_RUNNING = 2;
  JOB_STATUS_FINISHED = 3;
  JOB_STATUS_FAILED = 4;
}

message RepeatedUInt {
    repeated uint32 value = 1;
}
message RepeatedULong {
    repeated uint64 value = 1;
}
message RepeatedFloat {
    repeated float value = 1;
}
message RepeatedDouble {
    repeated double value = 1;
}

message ProfileData {
    oneof Data {
        RepeatedUInt uint32_value = 1;
        RepeatedULong uint64_value = 2;
        RepeatedFloat float_value = 3;
        RepeatedDouble double_value = 4;
    }
}

enum SCAMPProfileType {
    PROFILE_TYPE_INVALID = 0;
    PROFILE_TYPE_1NN_INDEX = 1;
    PROFILE_TYPE_SUM_THRESH = 2;
    PROFILE_TYPE_FREQUENCY_THRESH = 3;
    PROFILE_TYPE_KNN = 4;
    PROFILE_TYPE_1NN_MULTIDIM = 5;
    PROFILE_TYPE_1NN = 6;
}

message Profile {
    repeated ProfileData data = 1;
    SCAMPProfileType type = 2;
}

message SCAMPTileInfo {
}

enum SCAMPPrecisionType {
    PRECISION_INVALID = 0;
    PRECISION_SINGLE = 1;
    PRECISION_MIXED = 2;
    PRECISION_DOUBLE = 3;    
}

message SCAMPArgs {
    repeated double timeseries_a = 1;
    repeated double timeseries_b = 2;
    Profile profile_a = 3;
    Profile profile_b = 4;
    bool has_b = 5;
    uint64 window = 6;
    uint64 max_tile_size = 7;
    int64 distributed_start_row = 8;
    int64 distributed_start_col = 9;
    double distance_threshold = 10;
    SCAMPPrecisionType precision_type = 11;        
    SCAMPProfileType profile_type = 12;
    bool computing_rows = 13;
    bool computing_columns = 14;
    bool keep_rows_separate = 15;
    bool is_aligned = 16;
    int64 timeseries_size_a = 17;
    int64 timeseries_size_b = 18;
    int64 job_id = 19;
    int64 tile_id = 20;
    int64 distributed_tile_size = 21;
}
