// Copyright 2023 Greptime Team
//
// 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 greptime.v1.index;

option go_package = "github.com/GreptimeTeam/greptime-proto/go/greptime/v1/index";

// Vector index engine types.
enum VectorIndexEngine {
  VECTOR_INDEX_ENGINE_USEARCH = 0;
}

// Vector distance metrics.
enum VectorDistanceMetric {
  VECTOR_DISTANCE_METRIC_L2SQ = 0;
  VECTOR_DISTANCE_METRIC_COSINE = 1;
  VECTOR_DISTANCE_METRIC_INNER_PRODUCT = 2;
}

// Metadata for a vector index blob (stored as footer).
message VectorIndexMeta {
  // Index engine type.
  VectorIndexEngine engine = 1;

  // Vector dimension.
  uint32 dim = 2;

  // Distance metric.
  VectorDistanceMetric metric = 3;

  // HNSW connectivity parameter.
  uint32 connectivity = 4;

  // HNSW expansion factor during index construction.
  uint32 expansion_add = 5;

  // HNSW expansion factor during search.
  uint32 expansion_search = 6;

  // Byte length of the null bitmap (RoaringBitmap serialized).
  uint32 null_bitmap_size = 7;

  // Byte length of the vector index data (engine-specific serialized format).
  uint64 index_size = 8;

  // Statistics about the vector index.
  VectorIndexStats stats = 9;
}

// Statistics for a vector index.
message VectorIndexStats {
  // Total number of rows in the SST.
  uint64 total_row_count = 1;

  // Number of rows with valid vectors (indexed).
  uint64 indexed_row_count = 2;

  // Number of null vectors.
  uint64 null_count = 3;
}
