//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you 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.
//

// usage:
// protoc  --java_out=./storage-hbase/src/main/java  ./storage-hbase/src/main/java/org/apache/kylin/storage/hbase/cube/v2/coprocessor/endpoint/protobuf/CubeVisit.proto

option java_package = "org.apache.kylin.storage.hbase.cube.v2.coprocessor.endpoint.generated";

option java_outer_classname = "CubeVisitProtos";

option java_generic_services = true;

option java_generate_equals_and_hash = true;

option optimize_for = SPEED;

message CubeVisitRequest {
    required bytes gtScanRequest = 1;
    required bytes hbaseRawScan = 2;
    required int32 rowkeyPreambleSize = 3;
    repeated IntList hbaseColumnsToGT = 4;
    required string kylinProperties = 5; // kylin properties
    optional string queryId = 6;
    optional bool spillEnabled = 7 [default = true];
    optional int64 maxScanBytes = 8; // must be positive
    optional bool isExactAggregate = 9 [default = false];
    message IntList {
        repeated int32 ints = 1;
    }
}

message CubeVisitResponse {
    message Stats {
        optional int64 serviceStartTime = 1;
        optional int64 serviceEndTime = 2;
        optional int64 scannedRowCount = 3;
        optional int64 aggregatedRowCount = 4;
        optional double systemCpuLoad = 5;
        optional double freePhysicalMemorySize = 6;
        optional double freeSwapSpaceSize = 7;
        optional string hostname = 8;
        optional string etcMsg = 9;
        optional int32 normalComplete =10;
        optional int64 scannedBytes = 11;
        optional int64 filteredRowCount = 12;
    }
    enum ErrorType {
        UNKNOWN_TYPE = 0;
        TIMEOUT = 1;
        RESOURCE_LIMIT_EXCEEDED = 2;
    }
    message ErrorInfo {
        required ErrorType type = 1;
        required string message = 2;
    }
    required bytes compressedRows = 1;
    required Stats stats = 2;
    optional ErrorInfo errorInfo = 3; // should be set when stats.normalComplete == false
}

service CubeVisitService {
    rpc visitCube (CubeVisitRequest) returns (CubeVisitResponse);
}
