// SPDX-License-Identifier: AGPL-3.0-only
// Provenance-includes-location: https://github.com/thanos-io/thanos/blob/main/pkg/store/storepb/types.proto
// Provenance-includes-license: Apache-2.0
// Provenance-includes-copyright: The Thanos Authors.

syntax = "proto3";
package thanos;

import "github.com/grafana/mimir/pkg/mimirpb/mimir.proto";
import "gogoproto/gogo.proto";

option go_package = "storepb";
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.goproto_sizecache_all) = false; // Do not generate XXX_sizecache fields to reduce memory footprint and allow zero-copy casts to/from Prometheus data types.
option (gogoproto.goproto_unkeyed_all) = false; // Do not generate XXX_sizecache fields to reduce memory footprint and allow zero-copy casts to/from Prometheus data types.
option (gogoproto.goproto_unrecognized_all) = false; // Do not generate XXX_sizecache fields to reduce memory footprint and allow zero-copy casts to/from Prometheus data types.
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.unmarshaler_all) = true;

message Chunk {
  enum Encoding {
    Chunk_XOR = 0;
    Chunk_Histogram = 1;
    Chunk_FloatHistogram = 2;
  }
  Encoding type = 1;
  bytes data = 2 [
    (gogoproto.nullable) = false,
    (gogoproto.customtype) = "github.com/grafana/mimir/pkg/mimirpb.UnsafeByteSlice"
  ];
}

message StreamingSeries {
  repeated cortexpb.LabelPair labels = 1 [
    (gogoproto.nullable) = false,
    (gogoproto.customtype) = "github.com/grafana/mimir/pkg/mimirpb.LabelAdapter"
  ];
}

message StreamingSeriesBatch {
  repeated StreamingSeries series = 1;
  bool is_end_of_series_stream = 2;
}

message StreamingChunks {
  uint64 series_index = 1; // Index into list of all series previously sent with SeriesResponse messages by this storegateway during this query response.
  repeated AggrChunk chunks = 2 [(gogoproto.nullable) = false];
}

message StreamingChunksBatch {
  repeated StreamingChunks series = 1;
}

message StreamingChunksEstimate {
  uint64 estimated_chunk_count = 1;
}

message AggrChunk {
  int64 min_time = 1;
  int64 max_time = 2;

  Chunk raw = 3 [(gogoproto.nullable) = false];

  // Thanos count.
  reserved 4;

  // Thanos sum.
  reserved 5;

  // Thanos min.
  reserved 6;

  // Thanos max.
  reserved 7;

  // Thanos counter.
  reserved 8;
}

// Matcher specifies a rule, which can match or set of labels or not.
message LabelMatcher {
  enum Type {
    LabelMatcher_EQ = 0; // =
    LabelMatcher_NEQ = 1; // !=
    LabelMatcher_RE = 2; // =~
    LabelMatcher_NRE = 3; // !~
  }
  Type type = 1;
  string name = 2;
  string value = 3;
}
