├── .clang-format ├── .clang-tidy ├── .cmake-format.json ├── .github └── workflows │ ├── ci_rocky8.yml │ ├── ci_rocky9.yml │ ├── ci_ubuntu.yml │ ├── java_build.yml │ ├── java_package.yml │ └── release-dockerhub.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── cmake ├── bdb.cmake ├── diskann.cmake ├── faiss-mkl.cmake ├── faiss-openblas.cmake ├── ftxui.cmake ├── hnswlib.cmake ├── modules │ ├── Findbacktrace.cmake │ ├── Findbraft.cmake │ ├── Findbrpc.cmake │ ├── Findgperftools.cmake │ ├── Findleveldb.cmake │ ├── Findunwind.cmake │ └── Finduring.cmake ├── openblas.cmake ├── tantivy-search.cmake └── yaml-cpp.cmake ├── conf ├── coordinator-gflags.conf ├── coordinator.template.yaml ├── diskann-gflags.conf ├── diskann.template.yaml ├── document-gflags.conf ├── document.template.yaml ├── index-gflags.conf ├── index.template.yaml ├── store-gflags.conf └── store.template.yaml ├── contrib └── .clang-tidy ├── docker ├── Dockerfile ├── centos7 │ └── Dockerfile ├── centos8 │ └── Dockerfile ├── dev_build_from_docker.md ├── docker-compose.yml ├── rocky8 │ └── Dockerfile ├── rocky9 │ └── Dockerfile ├── ubuntu18 │ └── Dockerfile ├── ubuntu22 │ └── Dockerfile └── ubuntu24 │ └── Dockerfile ├── docs ├── contributing.md └── images │ ├── dingo-store-architecture.jpg │ └── dingo_contact.jpg ├── java ├── dingo-grpc-tools │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── io │ │ │ └── dingodb │ │ │ └── grpc │ │ │ ├── Constant.java │ │ │ ├── MessageGenerateProcessor.java │ │ │ ├── OneOfNestMethod.java │ │ │ ├── RpcMethodAnnotationProcessor.java │ │ │ └── SerializeGenerateProcessor.java │ │ └── resources │ │ └── META-INF │ │ └── services │ │ └── javax.annotation.processing.Processor ├── dingo-sdk │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── dingodb │ │ │ └── sdk │ │ │ ├── common │ │ │ ├── AutoIncrement.java │ │ │ ├── Context.java │ │ │ ├── DingoClientException.java │ │ │ ├── DingoCommonId.java │ │ │ ├── KeyValue.java │ │ │ ├── KeyValueWithExpect.java │ │ │ ├── Location.java │ │ │ ├── Range.java │ │ │ ├── RangeWithOptions.java │ │ │ ├── Row.java │ │ │ ├── SDKCommonId.java │ │ │ ├── cluster │ │ │ │ ├── Coordinator.java │ │ │ │ ├── Executor.java │ │ │ │ ├── ExecutorMap.java │ │ │ │ ├── ExecutorUser.java │ │ │ │ ├── InternalCoordinator.java │ │ │ │ ├── InternalExecutor.java │ │ │ │ ├── InternalExecutorMap.java │ │ │ │ ├── InternalExecutorUser.java │ │ │ │ ├── InternalRegion.java │ │ │ │ ├── InternalStore.java │ │ │ │ ├── Region.java │ │ │ │ └── Store.java │ │ │ ├── codec │ │ │ │ ├── CodecUtils.java │ │ │ │ ├── DingoKeyValueCodec.java │ │ │ │ └── KeyValueCodec.java │ │ │ ├── index │ │ │ │ ├── BruteForceParam.java │ │ │ │ ├── DiskAnnParam.java │ │ │ │ ├── FlatParam.java │ │ │ │ ├── HnswParam.java │ │ │ │ ├── Index.java │ │ │ │ ├── IndexDefinition.java │ │ │ │ ├── IndexMetrics.java │ │ │ │ ├── IndexParameter.java │ │ │ │ ├── IvfFlatParam.java │ │ │ │ ├── IvfPqParam.java │ │ │ │ ├── ScalarIndexParameter.java │ │ │ │ └── VectorIndexParameter.java │ │ │ ├── partition │ │ │ │ ├── Partition.java │ │ │ │ ├── PartitionDetail.java │ │ │ │ ├── PartitionDetailDefinition.java │ │ │ │ └── PartitionRule.java │ │ │ ├── region │ │ │ │ ├── RegionEpoch.java │ │ │ │ ├── RegionHeartbeatState.java │ │ │ │ ├── RegionState.java │ │ │ │ └── RegionStatus.java │ │ │ ├── serial │ │ │ │ ├── Buf.java │ │ │ │ ├── BufImpl.java │ │ │ │ ├── Config.java │ │ │ │ ├── MyDecimal.java │ │ │ │ ├── RecordDecoder.java │ │ │ │ ├── RecordEncoder.java │ │ │ │ ├── Utils.java │ │ │ │ └── schema │ │ │ │ │ ├── ArraySchema.java │ │ │ │ │ ├── BitSchema.java │ │ │ │ │ ├── BooleanListSchema.java │ │ │ │ │ ├── BooleanSchema.java │ │ │ │ │ ├── BytesSchema.java │ │ │ │ │ ├── DecimalSchema.java │ │ │ │ │ ├── DingoSchema.java │ │ │ │ │ ├── DoubleListSchema.java │ │ │ │ │ ├── DoubleSchema.java │ │ │ │ │ ├── FloatListSchema.java │ │ │ │ │ ├── FloatSchema.java │ │ │ │ │ ├── IntegerListSchema.java │ │ │ │ │ ├── IntegerSchema.java │ │ │ │ │ ├── LongListSchema.java │ │ │ │ │ ├── LongSchema.java │ │ │ │ │ ├── StringListSchema.java │ │ │ │ │ ├── StringSchema.java │ │ │ │ │ ├── Type.java │ │ │ │ │ └── VectorSchema.java │ │ │ ├── table │ │ │ │ ├── Column.java │ │ │ │ ├── ColumnDefinition.java │ │ │ │ ├── RangeDistribution.java │ │ │ │ ├── Table.java │ │ │ │ ├── TableDefinition.java │ │ │ │ └── metric │ │ │ │ │ └── TableMetrics.java │ │ │ ├── utils │ │ │ │ ├── Any.java │ │ │ │ ├── ByteArrayUtils.java │ │ │ │ ├── EntityConversion.java │ │ │ │ ├── ErrorCodeUtils.java │ │ │ │ ├── Future.java │ │ │ │ ├── LinkedIterator.java │ │ │ │ ├── NoBreakFunctions.java │ │ │ │ ├── Optional.java │ │ │ │ ├── Parameters.java │ │ │ │ ├── ReflectionUtils.java │ │ │ │ ├── StackTraces.java │ │ │ │ └── TypeSchemaMapper.java │ │ │ └── vector │ │ │ │ ├── ScalarField.java │ │ │ │ ├── ScalarValue.java │ │ │ │ ├── Search.java │ │ │ │ ├── SearchDiskAnnParam.java │ │ │ │ ├── SearchFlatParam.java │ │ │ │ ├── SearchHnswParam.java │ │ │ │ ├── SearchIvfFlatParam.java │ │ │ │ ├── SearchIvfPqParam.java │ │ │ │ ├── Vector.java │ │ │ │ ├── VectorCalcDistance.java │ │ │ │ ├── VectorDistance.java │ │ │ │ ├── VectorDistanceRes.java │ │ │ │ ├── VectorIndexMetrics.java │ │ │ │ ├── VectorScanQuery.java │ │ │ │ ├── VectorSearchParameter.java │ │ │ │ ├── VectorTableData.java │ │ │ │ ├── VectorWithDistance.java │ │ │ │ ├── VectorWithDistanceResult.java │ │ │ │ └── VectorWithId.java │ │ │ ├── grpc │ │ │ └── serializer │ │ │ │ ├── Marshaller.java │ │ │ │ ├── Reader.java │ │ │ │ ├── SizeUtils.java │ │ │ │ └── Writer.java │ │ │ └── service │ │ │ ├── AutoIncrementService.java │ │ │ ├── Caller.java │ │ │ ├── ChannelManager.java │ │ │ ├── ChannelProvider.java │ │ │ ├── CoordinatorChannelProvider.java │ │ │ ├── JsonMessageUtils.java │ │ │ ├── LockService.java │ │ │ ├── RegionChannelProvider.java │ │ │ ├── Service.java │ │ │ ├── ServiceCallCycle.java │ │ │ ├── ServiceCallCycles.java │ │ │ ├── ServiceMethodBuilder.java │ │ │ ├── Services.java │ │ │ ├── TableRegionsFailOver.java │ │ │ ├── WatchService.java │ │ │ ├── caller │ │ │ ├── RpcCaller.java │ │ │ ├── RpcFuture.java │ │ │ └── ServiceCaller.java │ │ │ ├── cluster │ │ │ └── ClusterServiceClient.java │ │ │ ├── connector │ │ │ ├── AutoIncrementServiceConnector.java │ │ │ ├── CoordinatorServiceConnector.java │ │ │ ├── IndexServiceConnector.java │ │ │ ├── MetaServiceConnector.java │ │ │ ├── ServiceConnector.java │ │ │ ├── StoreServiceConnector.java │ │ │ ├── UtilServiceConnector.java │ │ │ └── VersionServiceConnector.java │ │ │ ├── entity │ │ │ ├── Message.java │ │ │ ├── Numeric.java │ │ │ └── ServiceCallCycleEntity.java │ │ │ ├── index │ │ │ └── IndexServiceClient.java │ │ │ ├── lock │ │ │ └── LockInfo.java │ │ │ ├── meta │ │ │ ├── AutoIncrementService.java │ │ │ └── MetaServiceClient.java │ │ │ ├── store │ │ │ ├── AggregationOperator.java │ │ │ ├── Coprocessor.java │ │ │ ├── ScanIterator.java │ │ │ └── StoreServiceClient.java │ │ │ └── util │ │ │ ├── OnlineDdlLogUtils.java │ │ │ └── UtilServiceClient.java │ │ └── test │ │ ├── java │ │ └── sdk │ │ │ └── common │ │ │ ├── AutoIncrementTest.java │ │ │ └── serial │ │ │ ├── CodecTest.java │ │ │ ├── Test.java │ │ │ ├── TestAllType.java │ │ │ └── TestListType.java │ │ └── resources │ │ └── simplelogger.properties └── pom.xml ├── scripts ├── check_store.sh ├── clean_start_cluster.sh ├── deploy_func.sh ├── deploy_parameters ├── deploy_server.sh ├── docker-dingo-store.sh ├── format_code.sh ├── gen_coverage.sh ├── prepare_xdprocks.sh ├── shflags ├── start_server.sh ├── stop.sh └── sysctl.sh ├── src ├── br │ ├── backup.cc │ ├── backup.h │ ├── backup_data.cc │ ├── backup_data.h │ ├── backup_data_base.cc │ ├── backup_data_base.h │ ├── backup_meta.cc │ ├── backup_meta.h │ ├── backup_meta_base.cc │ ├── backup_meta_base.h │ ├── backup_sdk_data.cc │ ├── backup_sdk_data.h │ ├── backup_sdk_meta.cc │ ├── backup_sdk_meta.h │ ├── backup_sql_data.cc │ ├── backup_sql_data.h │ ├── backup_sql_meta.cc │ ├── backup_sql_meta.h │ ├── helper.cc │ ├── helper.h │ ├── interaction_manager.cc │ ├── interaction_manager.h │ ├── interation.cc │ ├── interation.h │ ├── main.cc │ ├── parameter.cc │ ├── parameter.h │ ├── restore.cc │ ├── restore.h │ ├── restore_data.cc │ ├── restore_data.h │ ├── restore_data_base.cc │ ├── restore_data_base.h │ ├── restore_meta.cc │ ├── restore_meta.h │ ├── restore_region_data.cc │ ├── restore_region_data.h │ ├── restore_region_data_manager.cc │ ├── restore_region_data_manager.h │ ├── restore_region_meta.cc │ ├── restore_region_meta.h │ ├── restore_region_meta_manager.cc │ ├── restore_region_meta_manager.h │ ├── restore_sdk_data.cc │ ├── restore_sdk_data.h │ ├── restore_sdk_meta.cc │ ├── restore_sdk_meta.h │ ├── restore_sql_data.cc │ ├── restore_sql_data.h │ ├── restore_sql_meta.cc │ ├── restore_sql_meta.h │ ├── router.cc │ ├── router.h │ ├── sst_file_reader.cc │ ├── sst_file_reader.h │ ├── sst_file_writer.cc │ ├── sst_file_writer.h │ ├── tool.cc │ ├── tool.h │ ├── tool_client.cc │ ├── tool_client.h │ ├── tool_diff.cc │ ├── tool_diff.h │ ├── tool_dump.cc │ ├── tool_dump.h │ ├── tool_utils.cc │ ├── tool_utils.h │ ├── utils.cc │ └── utils.h ├── client │ ├── client_helper.h │ ├── client_interation.cc │ ├── client_interation.h │ ├── client_router.cc │ ├── client_router.h │ ├── coordinator_client_function.h │ ├── coordinator_client_function_coor.cc │ ├── coordinator_client_function_incr.cc │ ├── coordinator_client_function_kv.cc │ ├── coordinator_client_function_lease.cc │ ├── coordinator_client_function_meta.cc │ ├── coordinator_client_function_meta_watch.cc │ ├── coordinator_client_function_watch.cc │ ├── dingodb_client.cc │ ├── store_client_function.cc │ ├── store_client_function.h │ └── store_client_function_txn.cc ├── client_v2 │ ├── coordinator.cc │ ├── coordinator.h │ ├── document_index.cc │ ├── document_index.h │ ├── dump.cc │ ├── dump.h │ ├── helper.h │ ├── interation.cc │ ├── interation.h │ ├── kv.cc │ ├── kv.h │ ├── main.cc │ ├── meta.cc │ ├── meta.h │ ├── pretty.cc │ ├── pretty.h │ ├── restore.cc │ ├── restore.h │ ├── router.cc │ ├── router.h │ ├── store.cc │ ├── store.h │ ├── tools.cc │ ├── tools.h │ ├── vector_index.cc │ └── vector_index.h ├── common │ ├── constant.h │ ├── context.h │ ├── failpoint.cc │ ├── failpoint.h │ ├── file_reader.cc │ ├── file_reader.h │ ├── helper.cc │ ├── helper.h │ ├── latch.cc │ ├── latch.h │ ├── logging.cc │ ├── logging.h │ ├── meta_control.h │ ├── role.cc │ ├── role.h │ ├── runnable.cc │ ├── runnable.h │ ├── safe_map.h │ ├── serial_helper.cc │ ├── serial_helper.h │ ├── service_access.cc │ ├── service_access.h │ ├── slice.cc │ ├── slice.h │ ├── stream.cc │ ├── stream.h │ ├── synchronization.cc │ ├── synchronization.h │ ├── syscheck.cc │ ├── syscheck.h │ ├── threadpool.cc │ ├── threadpool.h │ ├── tracker.cc │ ├── tracker.h │ ├── uuid.cc │ ├── uuid.h │ ├── version.cc │ └── version.h ├── config │ ├── config.h │ ├── config_helper.cc │ ├── config_helper.h │ ├── config_manager.cc │ ├── config_manager.h │ ├── yaml_config.cc │ └── yaml_config.h ├── coordinator │ ├── auto_increment_control.cc │ ├── auto_increment_control.h │ ├── balance_leader.cc │ ├── balance_leader.h │ ├── balance_region.cc │ ├── balance_region.h │ ├── coordinator_control.cc │ ├── coordinator_control.h │ ├── coordinator_control_coor.cc │ ├── coordinator_control_fsm.cc │ ├── coordinator_control_meta.cc │ ├── coordinator_control_watch.cc │ ├── coordinator_interaction.cc │ ├── coordinator_interaction.h │ ├── coordinator_meta_storage.h │ ├── coordinator_prefix.h │ ├── kv_control.cc │ ├── kv_control.h │ ├── kv_control_fsm.cc │ ├── kv_control_kv.cc │ ├── kv_control_lease.cc │ ├── kv_control_watch.cc │ ├── tso_control.cc │ └── tso_control.h ├── coprocessor │ ├── aggregation.cc │ ├── aggregation.h │ ├── aggregation_manager.cc │ ├── aggregation_manager.h │ ├── coprocessor.cc │ ├── coprocessor.h │ ├── coprocessor_scalar.cc │ ├── coprocessor_scalar.h │ ├── coprocessor_v2.cc │ ├── coprocessor_v2.h │ ├── raw_coprocessor.cc │ ├── raw_coprocessor.h │ ├── rel_expr_helper.cc │ ├── rel_expr_helper.h │ ├── utils.cc │ └── utils.h ├── crontab │ ├── crontab.cc │ └── crontab.h ├── diskann │ ├── diskann_core.cc │ ├── diskann_core.h │ ├── diskann_item.cc │ ├── diskann_item.h │ ├── diskann_item_manager.cc │ ├── diskann_item_manager.h │ ├── diskann_item_parameter.cc │ ├── diskann_item_parameter.h │ ├── diskann_item_runtime.cc │ ├── diskann_item_runtime.h │ ├── diskann_service_handle.cc │ ├── diskann_service_handle.h │ ├── diskann_utils.cc │ └── diskann_utils.h ├── document │ ├── codec.cc │ ├── codec.h │ ├── document_index.cc │ ├── document_index.h │ ├── document_index_factory.cc │ ├── document_index_factory.h │ ├── document_index_manager.cc │ ├── document_index_manager.h │ ├── document_reader.cc │ └── document_reader.h ├── engine │ ├── bdb_raw_engine.cc │ ├── bdb_raw_engine.h │ ├── engine.h │ ├── gc_safe_point.cc │ ├── gc_safe_point.h │ ├── iterator.h │ ├── mem_engine.cc │ ├── mem_engine.h │ ├── mono_store_engine.cc │ ├── mono_store_engine.h │ ├── raft_store_engine.cc │ ├── raft_store_engine.h │ ├── raw_engine.h │ ├── rocks_raw_engine.cc │ ├── rocks_raw_engine.h │ ├── snapshot.h │ ├── storage.cc │ ├── storage.h │ ├── txn_engine_helper.cc │ ├── txn_engine_helper.h │ ├── write_data.h │ ├── xdprocks_raw_engine.cc │ └── xdprocks_raw_engine.h ├── event │ ├── event.cc │ ├── event.h │ ├── store_state_machine_event.cc │ └── store_state_machine_event.h ├── handler │ ├── handler.cc │ ├── handler.h │ ├── raft_apply_handler.cc │ ├── raft_apply_handler.h │ ├── raft_apply_handler_txn.cc │ ├── raft_snapshot_handler.cc │ ├── raft_snapshot_handler.h │ ├── raft_vote_handler.cc │ └── raft_vote_handler.h ├── log │ ├── log_storage_manager.cc │ ├── log_storage_manager.h │ ├── rocks_log_storage.cc │ ├── rocks_log_storage.h │ ├── segment_log_storage.cc │ └── segment_log_storage.h ├── merge │ ├── merge_checker.cc │ └── merge_checker.h ├── meta │ ├── meta_reader.cc │ ├── meta_reader.h │ ├── meta_writer.cc │ ├── meta_writer.h │ ├── store_meta_manager.cc │ ├── store_meta_manager.h │ └── transform_kv_able.h ├── metrics │ ├── coordinator_bvar_metrics.h │ ├── dingo_bvar.h │ ├── store_bvar_metrics.cc │ ├── store_bvar_metrics.h │ ├── store_metrics_manager.cc │ └── store_metrics_manager.h ├── mvcc │ ├── codec.cc │ ├── codec.h │ ├── iterator.cc │ ├── iterator.h │ ├── reader.cc │ ├── reader.h │ ├── ts_provider.cc │ └── ts_provider.h ├── raft │ ├── dingo_filesystem_adaptor.cc │ ├── dingo_filesystem_adaptor.h │ ├── meta_state_machine.cc │ ├── meta_state_machine.h │ ├── raft_node.cc │ ├── raft_node.h │ ├── raft_node_manager.cc │ ├── raft_node_manager.h │ ├── state_machine.cc │ ├── state_machine.h │ ├── store_state_machine.cc │ └── store_state_machine.h ├── report │ ├── allure.cc │ ├── allure.h │ ├── web.cc │ └── web.h ├── scan │ ├── scan.cc │ ├── scan.h │ ├── scan_filter.cc │ ├── scan_filter.h │ ├── scan_manager.cc │ └── scan_manager.h ├── server │ ├── cluster_service.cc │ ├── cluster_service.h │ ├── coordinator_service.cc │ ├── coordinator_service.h │ ├── debug_service.cc │ ├── debug_service.h │ ├── diskann_service.cc │ ├── diskann_service.h │ ├── document_service.cc │ ├── document_service.h │ ├── file_service.cc │ ├── file_service.h │ ├── index_service.cc │ ├── index_service.h │ ├── job_service.cc │ ├── job_service.h │ ├── main.cc │ ├── meta_service.cc │ ├── meta_service.h │ ├── node_service.cc │ ├── node_service.h │ ├── push_service.cc │ ├── push_service.h │ ├── region_service.cc │ ├── region_service.h │ ├── server.cc │ ├── server.h │ ├── service_helper.cc │ ├── service_helper.h │ ├── store_metrics_service.cc │ ├── store_metrics_service.h │ ├── store_operation_service.cc │ ├── store_operation_service.h │ ├── store_service.cc │ ├── store_service.h │ ├── table_service.cc │ ├── table_service.h │ ├── util_service.cc │ ├── util_service.h │ ├── version_service.cc │ └── version_service.h ├── simd │ ├── distances_avx.cc │ ├── distances_avx.h │ ├── distances_avx512.cc │ ├── distances_avx512.h │ ├── distances_ref.cc │ ├── distances_ref.h │ ├── distances_sse.cc │ ├── distances_sse.h │ ├── hook.cc │ ├── hook.h │ └── instruction_set.h ├── split │ ├── split_checker.cc │ └── split_checker.h ├── store │ ├── heartbeat.cc │ ├── heartbeat.h │ ├── region_controller.cc │ ├── region_controller.h │ ├── store_controller.cc │ └── store_controller.h └── vector │ ├── codec.cc │ ├── codec.h │ ├── vector_index.cc │ ├── vector_index.h │ ├── vector_index_bruteforce.cc │ ├── vector_index_bruteforce.h │ ├── vector_index_diskann.cc │ ├── vector_index_diskann.h │ ├── vector_index_factory.cc │ ├── vector_index_factory.h │ ├── vector_index_flat.cc │ ├── vector_index_flat.h │ ├── vector_index_hnsw.cc │ ├── vector_index_hnsw.h │ ├── vector_index_ivf_flat.cc │ ├── vector_index_ivf_flat.h │ ├── vector_index_ivf_pq.cc │ ├── vector_index_ivf_pq.h │ ├── vector_index_manager.cc │ ├── vector_index_manager.h │ ├── vector_index_raw_ivf_pq.cc │ ├── vector_index_raw_ivf_pq.h │ ├── vector_index_snapshot.cc │ ├── vector_index_snapshot.h │ ├── vector_index_snapshot_manager.cc │ ├── vector_index_snapshot_manager.h │ ├── vector_index_utils.cc │ ├── vector_index_utils.h │ ├── vector_reader.cc │ └── vector_reader.h └── test └── unit_test ├── CMakeLists.txt ├── br ├── CMakeLists.txt ├── test_backup.cc ├── test_backup_data.cc ├── test_backup_meta.cc ├── test_backup_misc.cc ├── test_backup_sdk_data.cc ├── test_backup_sdk_meta.cc ├── test_backup_sql_data.cc ├── test_backup_sql_meta.cc ├── test_helper.cc ├── test_interaction_manager.cc ├── test_interation.cc ├── test_restore_.cc ├── test_restore_data.cc ├── test_restore_data_base.cc ├── test_restore_meta.cc ├── test_restore_region_data.cc ├── test_restore_region_data_manager.cc ├── test_restore_region_meta.cc ├── test_restore_region_meta_manager.cc ├── test_restore_sdk_data.cc ├── test_restore_sdk_meta.cc ├── test_restore_sql_data.cc ├── test_restore_sql_meta.cc ├── test_sst_file_reader.cc ├── test_sst_file_writer.cc └── test_utils.cc ├── common ├── CMakeLists.txt ├── test_crontab.cc ├── test_failpoint.cc ├── test_google_sanitize.cc ├── test_helper.cc ├── test_latch.cc ├── test_log.cc ├── test_pb.cc ├── test_rel_expr_helper.cc ├── test_runnable.cc ├── test_safe_map.cc ├── test_serial_helper.cc ├── test_service_helper.cc ├── test_synchronization.cc ├── test_threadpool.cc ├── test_tracker.cc ├── test_uuid.cc ├── test_worker_set.cc ├── test_write_data.cc └── test_yaml_config.cc ├── coprocessor ├── CMakeLists.txt ├── test_coprocessor.cc ├── test_coprocessor_aggregation_manager.cc ├── test_coprocessor_utils.cc └── test_coprocessor_v2.cc ├── document ├── CMakeLists.txt ├── test_document_index.cc └── test_tantivy_search.cc ├── engine ├── CMakeLists.txt ├── test_bdb_engine.cc ├── test_raft_node.cc ├── test_raft_snapshot_handler.cc ├── test_rocks_engine.cc ├── test_rocks_engine_destroy.cc ├── test_rocks_log_storage.cc └── test_segment_log_storage.cc ├── main.cc ├── misc ├── CMakeLists.txt ├── test_balance_leader.cc ├── test_balance_region.cc ├── test_coordinator.cc ├── test_coordinator_meta_storage.cc ├── test_region_controller.cc ├── test_scan.cc ├── test_scan_v2.cc ├── test_scan_with_coprocessor.cc ├── test_scan_with_coprocessor_v2.cc ├── test_split_checker.cc ├── test_store_meta_manager.cc └── test_store_metrics_manager.cc ├── mvcc ├── CMakeLists.txt ├── test_codec.cc ├── test_iterator.cc └── test_ts_provider.cc ├── txn ├── CMakeLists.txt ├── test_gc_safe_point.cc ├── test_mvcc_gc.cc ├── test_mvcc_gc_store.cc ├── test_txn_gc.cc ├── test_txn_pessimistic_lock.cc ├── test_txn_prewrite.cc └── test_txn_scan.cc └── vector ├── CMakeLists.txt ├── test_codec.cc ├── test_diskann_brpc_client.cc ├── test_diskann_core.cc ├── test_diskann_core_stress.cc ├── test_diskann_flat_compare.cc ├── test_diskann_item.cc ├── test_diskann_item_ann.cc ├── test_diskann_item_concurrent.cc ├── test_diskann_item_manager.cc ├── test_diskann_item_runtime.cc ├── test_diskann_utils.cc ├── test_vector_index.cc ├── test_vector_index_binary_flat.cc ├── test_vector_index_binary_ivf_flat.cc ├── test_vector_index_diskann.cc ├── test_vector_index_flat.cc ├── test_vector_index_flat_search_limit.cc ├── test_vector_index_flat_search_param.cc ├── test_vector_index_flat_simd.cc ├── test_vector_index_hnsw.cc ├── test_vector_index_hnsw_search_param.cc ├── test_vector_index_hnsw_simd.cc ├── test_vector_index_ivf_flat.cc ├── test_vector_index_ivf_pq.cc ├── test_vector_index_memory.cc ├── test_vector_index_memory_flat.cc ├── test_vector_index_memory_hnsw.cc ├── test_vector_index_raw_ivf_pq.cc ├── test_vector_index_raw_ivf_pq_boundary.cc ├── test_vector_index_recall_flat.cc ├── test_vector_index_snapshot.cc ├── test_vector_index_utils.cc └── test_vector_reader.cc /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | ColumnLimit: 120 5 | --- 6 | Language: Proto 7 | BasedOnStyle: Google 8 | ColumnLimit: 120 9 | ... 10 | -------------------------------------------------------------------------------- /.github/workflows/java_build.yml: -------------------------------------------------------------------------------- 1 | name: Java_Maven_Build 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: Set up JDK 17 17 | uses: actions/setup-java@v4 18 | with: 19 | java-version: '17' 20 | distribution: 'temurin' 21 | cache: maven 22 | 23 | - name: Clone Submodule 24 | # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. 25 | # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type 26 | run: git submodule update --init --recursive 27 | 28 | - name: Build with Maven 29 | run: cd java && mvn clean package -Dmaven.test.skip=true #-DiskipTests 30 | # run: cd java && mvn -B package --file pom.xml 31 | 32 | 33 | # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive 34 | # - name: Update dependency graph 35 | # uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 36 | -------------------------------------------------------------------------------- /.github/workflows/java_package.yml: -------------------------------------------------------------------------------- 1 | name: Maven_Publish_package 2 | 3 | on: 4 | # Triggers the workflow on push or pull request events but only for the main branch 5 | workflow_run: 6 | workflows: ["Java_Maven_Build"] 7 | types: 8 | - completed 9 | on: 10 | branches: 11 | - main 12 | pull_requests: 13 | - merged 14 | 15 | jobs: 16 | publish: 17 | runs-on: ubuntu-latest 18 | permissions: 19 | contents: read 20 | packages: write 21 | steps: 22 | - uses: actions/checkout@v4 23 | - uses: actions/setup-java@v4 24 | with: 25 | java-version: '17' 26 | distribution: 'adopt' 27 | server-id: ossrh 28 | server-username: MAVEN_USERNAME 29 | server-password: MAVEN_PASSWORD 30 | 31 | - name: Clone Submodule 32 | # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. 33 | # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type 34 | run: git submodule update --init --recursive 35 | 36 | - name: Publish package 37 | run: cd java && mvn clean deploy -Dmaven.test.skip=true 38 | env: 39 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 40 | MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} 41 | MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Swap 35 | [._]*.s[a-v][a-z] 36 | [._]*.sw[a-p] 37 | [._]s[a-rt-v][a-z] 38 | [._]ss[a-gi-z] 39 | [._]sw[a-p] 40 | 41 | .idea 42 | cmake-build-debug 43 | cmake-build-release 44 | .DS_Store 45 | tags 46 | .cache 47 | .run 48 | .fleet 49 | 50 | # eclipse 51 | .cproject 52 | .project 53 | .settings/language.settings.xml 54 | third-party 55 | .iml 56 | 57 | # bazel 58 | 59 | build/ 60 | dist/ 61 | .vscode/ 62 | *.bak 63 | 64 | # Maven Files 65 | target/ 66 | 67 | # Ignore Gradle project-specific cache directory 68 | .gradle 69 | 70 | *.iml 71 | scripts/local_start_server.sh 72 | coor_list 73 | create_table.sh 74 | .devcontainer/ 75 | local_scripts/ 76 | contrib/xdprocks/ 77 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "contrib/yaml-cpp"] 2 | path = contrib/yaml-cpp 3 | url = https://github.com/jbeder/yaml-cpp 4 | [submodule "contrib/hnswlib"] 5 | path = contrib/hnswlib 6 | url = https://github.com/dingodb/hnswlib 7 | [submodule "contrib/openblas"] 8 | path = contrib/openblas 9 | url = https://github.com/xianyi/OpenBLAS 10 | [submodule "contrib/faiss"] 11 | path = contrib/faiss 12 | url = https://github.com/dingodb/faiss 13 | [submodule "contrib/diskann"] 14 | path = contrib/diskann 15 | url = https://github.com/dingodb/DiskANN 16 | [submodule "contrib/bdb"] 17 | path = contrib/bdb 18 | url = https://github.com/dingodb/bdb 19 | [submodule "src/libexpr"] 20 | path = src/libexpr 21 | url = https://github.com/dingodb/dingo-libexpr.git 22 | [submodule "contrib/tantivy-search"] 23 | path = contrib/tantivy-search 24 | url = https://github.com/dingodb/tantivy-search 25 | [submodule "src/serial"] 26 | path = src/serial 27 | url = https://github.com/dingodb/dingo-serial 28 | [submodule "dingo-store-proto"] 29 | path = dingo-store-proto 30 | url = https://github.com/dingodb/dingo-store-proto 31 | [submodule "contrib/cli11"] 32 | path = contrib/cli11 33 | url = https://github.com/CLIUtils/CLI11.git 34 | [submodule "contrib/FTXUI"] 35 | path = contrib/FTXUI 36 | url = https://github.com/ArthurSonzogni/FTXUI.git 37 | -------------------------------------------------------------------------------- /cmake/hnswlib.cmake: -------------------------------------------------------------------------------- 1 | message(STATUS "Include hnswlib...") 2 | include_directories(contrib/hnswlib) 3 | -------------------------------------------------------------------------------- /cmake/modules/Findbacktrace.cmake: -------------------------------------------------------------------------------- 1 | # Find the backtrace library 2 | # BACKTRACE_FOUND - True if backtrace found. 3 | # backtrace::backtrace - cmake target for libbacktrace 4 | 5 | find_path(BACKTRACE_INCLUDE_DIRS 6 | NAMES backtrace.h 7 | HINTS ${backtrace_ROOT_DIR}/include) 8 | 9 | find_library(BACKTRACE_LIBRARIES 10 | NAMES backtrace 11 | HINTS ${backtrace_ROOT_DIR}/lib) 12 | 13 | include(FindPackageHandleStandardArgs) 14 | find_package_handle_standard_args(backtrace DEFAULT_MSG BACKTRACE_LIBRARIES BACKTRACE_INCLUDE_DIRS) 15 | 16 | mark_as_advanced( 17 | BACKTRACE_LIBRARIES 18 | BACKTRACE_INCLUDE_DIRS) 19 | 20 | if(BACKTRACE_FOUND AND NOT (TARGET backtrace::backtrace)) 21 | add_library (backtrace::backtrace UNKNOWN IMPORTED) 22 | set_target_properties(backtrace::backtrace 23 | PROPERTIES 24 | IMPORTED_LOCATION ${BACKTRACE_LIBRARIES} 25 | INTERFACE_INCLUDE_DIRECTORIES ${BACKTRACE_INCLUDE_DIRS} 26 | INTERFACE_LINK_LIBRARIES dl) 27 | endif() 28 | 29 | -------------------------------------------------------------------------------- /cmake/modules/Findbraft.cmake: -------------------------------------------------------------------------------- 1 | # Find braft 2 | # Find the braft library and includes 3 | # BRAFT_FOUND - True if braft found. 4 | # braft::braft - cmake target for libbraft 5 | 6 | find_path(BRAFT_INCLUDE_DIRS 7 | NAMES braft/raft.h 8 | HINTS ${braft_ROOT_DIR}/include) 9 | 10 | find_library(BRAFT_LIBRARIES 11 | NAMES braft 12 | HINTS ${braft_ROOT_DIR}/lib) 13 | 14 | include(FindPackageHandleStandardArgs) 15 | find_package_handle_standard_args(braft DEFAULT_MSG BRAFT_LIBRARIES BRAFT_INCLUDE_DIRS) 16 | 17 | mark_as_advanced( 18 | BRAFT_LIBRARIES 19 | BRAFT_INCLUDE_DIRS) 20 | 21 | if(BRAFT_FOUND AND NOT (TARGET braft::braft)) 22 | find_package(brpc REQUIRED) 23 | add_library (braft::braft UNKNOWN IMPORTED) 24 | set_target_properties(braft::braft 25 | PROPERTIES 26 | IMPORTED_LOCATION ${BRAFT_LIBRARIES} 27 | INTERFACE_INCLUDE_DIRECTORIES ${BRAFT_INCLUDE_DIRS} 28 | INTERFACE_LINK_LIBRARIES brpc::brpc) 29 | endif() 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /cmake/modules/Findbrpc.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find brpc 2 | # This module will also define the following variables: 3 | # 4 | # BRPC_INCLUDE_DIRS - where to find brpc headers 5 | # BRPC_LIBRARIES - List of libraries when using brpc. 6 | # BRPC_FOUND - True if zstd found. 7 | 8 | 9 | find_path(BRPC_INCLUDE_DIRS 10 | NAMES brpc/server.h 11 | HINTS ${brpc_ROOT_DIR}/include) 12 | 13 | find_library(BRPC_LIBRARIES 14 | NAMES brpc 15 | HINTS ${brpc_ROOT_DIR}/lib) 16 | 17 | include(FindPackageHandleStandardArgs) 18 | find_package_handle_standard_args(brpc DEFAULT_MSG BRPC_LIBRARIES BRPC_INCLUDE_DIRS) 19 | 20 | mark_as_advanced( 21 | BRPC_LIBRARIES 22 | BRPC_INCLUDE_DIRS) 23 | 24 | if(BRPC_FOUND AND NOT (TARGET brpc::brpc)) 25 | set(BRPC_DEPS_LIBS 26 | gflags 27 | OpenSSL::SSL 28 | leveldb::leveldb 29 | Snappy::snappy 30 | ZLIB::ZLIB 31 | fmt::fmt 32 | glog::glog 33 | protobuf::libprotobuf) 34 | message("BRPC_DEPS_LIBS: ${BRPC_DEPS_LIBS}") 35 | add_library(brpc::brpc UNKNOWN IMPORTED) 36 | set_target_properties(brpc::brpc 37 | PROPERTIES 38 | IMPORTED_LOCATION ${BRPC_LIBRARIES} 39 | INTERFACE_INCLUDE_DIRECTORIES ${BRPC_INCLUDE_DIRS} 40 | INTERFACE_LINK_LIBRARIES "${BRPC_DEPS_LIBS}") 41 | endif() 42 | 43 | -------------------------------------------------------------------------------- /cmake/modules/Findgperftools.cmake: -------------------------------------------------------------------------------- 1 | # Find gperftools 2 | # This module defines 3 | # GPERFTOOLS_FOUND, if false, do not try to link to gperftools 4 | # GPERFTOOLS_LIBRARIES, the libraries needed to use gperftools 5 | # GPERFTOOLS_MINIMAL_LIBRARIES, the minimal libraries needed to use gperftools 6 | # GPERFTOOLS_INCLUDE_DIRS, where to find gperftools.h 7 | 8 | find_path(GPERFTOOLS_INCLUDE_DIRS 9 | NAMES gperftools/profiler.h 10 | HINTS ${GPERFTOOLS_ROOT_DIR}/include) 11 | 12 | find_library(GPERFTOOLS_LIBRARIES 13 | NAMES tcmalloc_and_profiler 14 | HINTS ${GPERFTOOLS_ROOT_DIR}/lib) 15 | 16 | find_library(GPERFTOOLS_MINIMAL_LIBRARIES 17 | NAMES tcmalloc_minimal 18 | HINTS ${GPERFTOOLS_ROOT_DIR}/lib) 19 | 20 | 21 | include(FindPackageHandleStandardArgs) 22 | 23 | find_package_handle_standard_args(gperftools DEFAULT_MSG GPERFTOOLS_LIBRARIES GPERFTOOLS_MINIMAL_LIBRARIES GPERFTOOLS_INCLUDE_DIRS) 24 | 25 | mark_as_advanced( 26 | GPERFTOOLS_LIBRARIES 27 | GPERFTOOLS_MINIMAL_LIBRARIES 28 | GPERFTOOLS_INCLUDE_DIRS 29 | ) 30 | 31 | if(GPERFTOOLS_FOUND AND NOT (TARGET gperftools::gperftools)) 32 | add_library (gperftools::gperftools UNKNOWN IMPORTED) 33 | set_target_properties(gperftools::gperftools 34 | PROPERTIES 35 | IMPORTED_LOCATION ${GPERFTOOLS_LIBRARIES} 36 | INTERFACE_INCLUDE_DIRECTORIES ${GPERFTOOLS_INCLUDE_DIRS}) 37 | 38 | add_library (gperftools::gperftools_minimal UNKNOWN IMPORTED) 39 | set_target_properties(gperftools::gperftools_minimal 40 | PROPERTIES 41 | IMPORTED_LOCATION ${GPERFTOOLS_MINIMAL_LIBRARIES} 42 | INTERFACE_INCLUDE_DIRECTORIES ${GPERFTOOLS_INCLUDE_DIRS}) 43 | endif() 44 | 45 | -------------------------------------------------------------------------------- /cmake/modules/Findleveldb.cmake: -------------------------------------------------------------------------------- 1 | # Find the LevelDB library 2 | # LEVELDB_INCLUDE_DIRS - where to find leveldb/db.h, etc. 3 | # LEVELDB_LIBRARIES - List of libraries when using LevelDB. 4 | # LEVELDB_FOUND - True if LevelDB found. 5 | 6 | find_path(LEVELDB_INCLUDE_DIRS 7 | NAMES leveldb/db.h 8 | HINTS ${leveldb_ROOT_DIR}/include) 9 | 10 | find_library(LEVELDB_LIBRARIES 11 | NAMES leveldb 12 | HINTS ${leveldb_ROOT_DIR}/lib) 13 | 14 | include(FindPackageHandleStandardArgs) 15 | find_package_handle_standard_args(leveldb DEFAULT_MSG LEVELDB_LIBRARIES LEVELDB_INCLUDE_DIRS) 16 | 17 | mark_as_advanced( 18 | LEVELDB_LIBRARIES 19 | LEVELDB_INCLUDE_DIRS) 20 | 21 | if(LEVELDB_FOUND AND NOT (TARGET leveldb::leveldb)) 22 | add_library (leveldb::leveldb UNKNOWN IMPORTED) 23 | set_target_properties(leveldb::leveldb 24 | PROPERTIES 25 | IMPORTED_LOCATION ${LEVELDB_LIBRARIES} 26 | INTERFACE_INCLUDE_DIRECTORIES ${LEVELDB_INCLUDE_DIRS}) 27 | endif() 28 | -------------------------------------------------------------------------------- /cmake/modules/Findunwind.cmake: -------------------------------------------------------------------------------- 1 | # Find unwind 2 | # This module defines 3 | # UNWIND_FOUND, if false, do not try to link to unwind 4 | # UNWIND_LIBRARIES, the libraries needed to use unwind 5 | # UNWIND_INCLUDE_DIRS, where to find unwind.h 6 | 7 | find_path(UNWIND_INCLUDE_DIRS 8 | NAMES unwind.h 9 | HINTS ${UNWIND_ROOT_DIR}/include) 10 | 11 | find_library(UNWIND_LIBRARIES 12 | NAMES unwind 13 | HINTS ${UNWIND_ROOT_DIR}/lib) 14 | 15 | find_library(UNWIND_GENERIC_LIBRARIES 16 | NAMES unwind-generic 17 | HINTS ${unwind_ROOT_DIR}/lib) 18 | 19 | include(FindPackageHandleStandardArgs) 20 | find_package_handle_standard_args(unwind DEFAULT_MSG UNWIND_LIBRARIES UNWIND_GENERIC_LIBRARIES UNWIND_INCLUDE_DIRS) 21 | 22 | mark_as_advanced( 23 | UNWIND_LIBRARIES 24 | UNWIND_GENERIC_LIBRARIES 25 | UNWIND_INCLUDE_DIRS 26 | ) 27 | 28 | if(UNWIND_FOUND AND NOT (TARGET unwind::unwind)) 29 | add_library(unwind::unwind UNKNOWN IMPORTED) 30 | set_target_properties(unwind::unwind 31 | PROPERTIES 32 | IMPORTED_LOCATION ${UNWIND_LIBRARIES} 33 | INTERFACE_INCLUDE_DIRECTORIES ${UNWIND_INCLUDE_DIRS}) 34 | 35 | add_library(unwind::unwind-generic UNKNOWN IMPORTED) 36 | set_target_properties(unwind::unwind-generic 37 | PROPERTIES 38 | IMPORTED_LOCATION ${UNWIND_GENERIC_LIBRARIES} 39 | INTERFACE_INCLUDE_DIRECTORIES ${UNWIND_INCLUDE_DIRS}) 40 | endif() 41 | -------------------------------------------------------------------------------- /cmake/modules/Finduring.cmake: -------------------------------------------------------------------------------- 1 | # - Find liburing 2 | # 3 | # uring_INCLUDE_DIR - Where to find liburing.h 4 | # uring_LIBRARIES - List of libraries when using uring. 5 | # uring_FOUND - True if uring found. 6 | 7 | find_path(uring_INCLUDE_DIR 8 | NAMES liburing.h) 9 | find_library(uring_LIBRARIES 10 | NAMES liburing.a liburing) 11 | 12 | include(FindPackageHandleStandardArgs) 13 | find_package_handle_standard_args(uring 14 | DEFAULT_MSG uring_LIBRARIES uring_INCLUDE_DIR) 15 | 16 | mark_as_advanced( 17 | uring_INCLUDE_DIR 18 | uring_LIBRARIES) 19 | 20 | if(uring_FOUND AND NOT TARGET uring::uring) 21 | add_library(uring::uring UNKNOWN IMPORTED) 22 | set_target_properties(uring::uring PROPERTIES 23 | INTERFACE_INCLUDE_DIRECTORIES "${uring_INCLUDE_DIR}" 24 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" 25 | IMPORTED_LOCATION "${uring_LIBRARIES}") 26 | endif() 27 | -------------------------------------------------------------------------------- /conf/coordinator-gflags.conf: -------------------------------------------------------------------------------- 1 | -role=coordinator 2 | -conf=./conf/coordinator.yaml 3 | -coor_url=file://./conf/coor_list 4 | -max_hnsw_memory_size_of_region=2147483648 5 | -async_create_table=true 6 | -raft_sync=true 7 | -braft_use_align_hearbeat=true 8 | -bdb_stat_time_s=1048576 9 | -bdb_dead_lock_detect_time_s=1048576 10 | -bdb_checkpoint_time_s=1048576 11 | -free_memory_to_system_interval=60 12 | -enable_dir_service=false 13 | -enable_threads_service=false 14 | -dingo_log_switch_coor_kv=false 15 | -dingo_log_switch_coor_watch=false 16 | -dingo_log_switch_coor_lease=false 17 | -default_replica_num=$DEFAULT_REPLICA_NUM$ 18 | -dingo_log_switch_scalar_speed_up_detail=true 19 | -service_log_threshold_time_ns=100000000 20 | -coordinator_service_worker_num=32 21 | -coordinator_service_worker_max_pending_num=1024 22 | -meta_service_worker_num=32 23 | -meta_service_worker_max_pending_num=1024 24 | -version_service_worker_num=32 25 | -version_service_worker_max_pending_num=1024 -------------------------------------------------------------------------------- /conf/coordinator.template.yaml: -------------------------------------------------------------------------------- 1 | cluster: 2 | name: dingodb 3 | instance_id: $INSTANCE_ID$ 4 | keyring: TO_BE_CONTINUED 5 | server: 6 | listen_host: $SERVER_LISTEN_HOST$ 7 | host: $SERVER_HOST$ 8 | port: $SERVER_PORT$ 9 | # worker_thread_num: 128 # must >4, worker_thread_num priority worker_thread_ratio 10 | worker_thread_ratio: 4 # cpu core * ratio 11 | coordinator: 12 | peers: $COORDINATOR_RAFT_PEERS$ 13 | push_interval_s: 1 14 | update_state_interval_s: 10 15 | job_interval_s: 1 16 | calc_metrics_interval_s: 60 17 | recycle_orphan_interval_s: 60 18 | remove_watch_interval_s: 10 19 | meta_watch_clean_interval_s: 60 20 | lease_interval_s: 1 21 | auto_compaction: true 22 | compaction_interval_s: 300 23 | compaction_retention_rev_count: 1000 24 | recycle_job_interval_s: 600 25 | reserve_job_recent_day: 7 26 | balance_leader_inspection_time_period: 0,23 # format: start_hour,end_hour;start_hour,end_hour e.g. 2,4;5,6;8,9 27 | balance_region_inspection_time_period: 0,23 # format: start_hour,end_hour;start_hour,end_hour e.g. 2,4;5,6;8,9 28 | balance_region_default_region_count_ratio: 0.8 29 | raft: 30 | listen_host: $RAFT_LISTEN_HOST$ 31 | host: $RAFT_HOST$ 32 | port: $RAFT_PORT$ 33 | path: $BASE_PATH$/data/raft 34 | election_timeout_s: 30 35 | snapshot_interval_s: 300 36 | segmentlog_max_segment_size: 33554432 # 32MB 37 | log: 38 | level: INFO 39 | path: $BASE_PATH$/log 40 | store: 41 | path: $BASE_PATH$/data/db 42 | background_thread_num: 16 # background_thread_num priority background_thread_ratio 43 | # background_thread_ratio: 0.5 # cpu core * ratio 44 | stats_dump_period_s: 120 45 | -------------------------------------------------------------------------------- /conf/diskann-gflags.conf: -------------------------------------------------------------------------------- 1 | -role=diskann 2 | --conf=./conf/diskann.yaml 3 | -coor_url=file://./conf/coor_list 4 | -use_pthread_diskann_import_worker_set=false 5 | -use_pthread_diskann_build_worker_set=true 6 | -use_pthread_diskann_load_worker_set=true 7 | -use_pthread_diskann_search_worker_set=true 8 | -use_pthread_diskann_misc_worker_set=false 9 | -use_prior_diskann_worker_set=false -------------------------------------------------------------------------------- /conf/diskann.template.yaml: -------------------------------------------------------------------------------- 1 | cluster: 2 | name: dingodb 3 | instance_id: $INSTANCE_ID$ 4 | keyring: TO_BE_CONTINUED 5 | server: 6 | listen_host: $SERVER_LISTEN_HOST$ 7 | host: $SERVER_HOST$ 8 | port: $SERVER_PORT$ 9 | # worker_thread_num: 128 # must >4, worker_thread_num priority worker_thread_ratio 10 | worker_thread_ratio: 4 # cpu core * ratio 11 | log: 12 | level: INFO 13 | path: $BASE_PATH$/log 14 | store: 15 | path: $BASE_PATH$/data/diskann 16 | num_threads: 64 17 | search_dram_budget_gb: 1.0 18 | build_dram_budget_gb: 10.0 19 | import_timeout_s: 30 20 | -------------------------------------------------------------------------------- /conf/document-gflags.conf: -------------------------------------------------------------------------------- 1 | -role=document 2 | -conf=./conf/document.yaml 3 | -coor_url=file://./conf/coor_list 4 | -document_max_batch_count=4096 5 | -braft_use_align_hearbeat=true 6 | -dingo_trace_append_entry_latency=true 7 | -raft_sync=true 8 | -free_memory_to_system_interval=60 9 | -enable_dir_service=false 10 | -enable_threads_service=false 11 | -dingo_log_switch_txn_detail=false 12 | -dingo_log_switch_txn_gc_detail=false 13 | -service_log_threshold_time_ns=10000000000 14 | -document_operation_parallel_thread_num=16 15 | -read_worker_num=128 16 | -read_worker_max_pending_num=1024 17 | -write_worker_num=128 18 | -write_worker_max_pending_num=1024 19 | -apply_worker_num=64 20 | -apply_worker_max_pending_num=1024 21 | -enable_coprocessor_v2_statistics_time_consumption=false -------------------------------------------------------------------------------- /conf/document.template.yaml: -------------------------------------------------------------------------------- 1 | cluster: 2 | name: dingodb 3 | instance_id: $INSTANCE_ID$ 4 | keyring: TO_BE_CONTINUED 5 | server: 6 | listen_host: $SERVER_LISTEN_HOST$ 7 | host: $SERVER_HOST$ 8 | port: $SERVER_PORT$ 9 | heartbeat_interval_s: 6 10 | metrics_collect_interval_s: 300 11 | approximate_size_metrics_collect_interval_s: 300 12 | scrub_document_index_interval_s: 60 13 | get_tso_interval_ms: 1000 14 | # worker_thread_num: 36 # must >4, worker_thread_num priority worker_thread_ratio 15 | worker_thread_ratio: 4 # cpu core * ratio 16 | region: 17 | region_max_size: 536870912 # 512MB 18 | enable_auto_split: true 19 | split_check_interval_s: 120 20 | enable_auto_merge: true 21 | merge_check_interval_s: 120 22 | region_merge_min_size: 1048576 # 1MB 23 | region_merge_min_keys_count: 10000 24 | merge_size_ratio: 0.2 25 | merge_keys_ratio: 0.2 26 | merge_check_concurrency: 3 27 | raft: 28 | listen_host: $RAFT_LISTEN_HOST$ 29 | host: $RAFT_HOST$ 30 | port: $RAFT_PORT$ 31 | path: $BASE_PATH$/data/raft 32 | election_timeout_s: 20 33 | snapshot_interval_s: 120 34 | segmentlog_max_segment_size: 33554432 # 32MB 35 | log: 36 | level: INFO 37 | path: $BASE_PATH$/log 38 | document: 39 | index_path: $BASE_PATH$/data/document_index 40 | enable_follower_hold_index: false 41 | store: 42 | path: $BASE_PATH$/data/db 43 | background_thread_num: 16 # background_thread_num priority background_thread_ratio 44 | fast_background_thread_num: 8 # background_thread_num priority background_thread_ratio 45 | # background_thread_ratio: 0.5 # cpu core * ratio 46 | stats_dump_period_s: 120 47 | gc: 48 | update_safe_point_interval_s: 60 49 | do_gc_interval_s: 60 50 | -------------------------------------------------------------------------------- /conf/index-gflags.conf: -------------------------------------------------------------------------------- 1 | -role=index 2 | -conf=./conf/index.yaml 3 | -coor_url=file://./conf/coor_list 4 | -omp_num_threads=1 5 | -vector_operation_parallel_thread_num=16 6 | -max_hnsw_memory_size_of_region=2147483648 7 | -vector_max_batch_count=4096 8 | -hnsw_max_init_max_elements=40000 9 | -braft_use_align_hearbeat=true 10 | -dingo_trace_append_entry_latency=true 11 | -raft_sync=true 12 | -free_memory_to_system_interval=60 13 | -enable_dir_service=false 14 | -enable_threads_service=false 15 | -dingo_log_switch_txn_detail=false 16 | -dingo_log_switch_txn_gc_detail=false 17 | -dingo_log_switch_scalar_speed_up_detail=false 18 | -service_log_threshold_time_ns=10000000000 19 | -enable_vector_index_diskann=true 20 | -dingo_log_switch_diskann_detail=false 21 | -read_worker_num=128 22 | -read_worker_max_pending_num=1024 23 | -write_worker_num=128 24 | -write_worker_max_pending_num=1024 25 | -apply_worker_num=64 26 | -apply_worker_max_pending_num=1024 27 | -enable_coprocessor_v2_statistics_time_consumption=false -------------------------------------------------------------------------------- /conf/store-gflags.conf: -------------------------------------------------------------------------------- 1 | -role=store 2 | -conf=./conf/store.yaml 3 | -coor_url=file://./conf/coor_list 4 | -braft_use_align_hearbeat=true 5 | -dingo_trace_append_entry_latency=true 6 | -raft_sync=true 7 | -free_memory_to_system_interval=60 8 | -enable_dir_service=false 9 | -enable_threads_service=false 10 | -dingo_log_switch_txn_detail=false 11 | -dingo_log_switch_txn_gc_detail=false 12 | -service_log_threshold_time_ns=1000000000 13 | -enable_async_store_operation=true 14 | -read_worker_num=128 15 | -read_worker_max_pending_num=1024 16 | -write_worker_num=128 17 | -write_worker_max_pending_num=1024 18 | -apply_worker_num=96 19 | -apply_worker_max_pending_num=1024 20 | -enable_coprocessor_v2_statistics_time_consumption=false -------------------------------------------------------------------------------- /conf/store.template.yaml: -------------------------------------------------------------------------------- 1 | cluster: 2 | name: dingodb 3 | instance_id: $INSTANCE_ID$ 4 | keyring: TO_BE_CONTINUED 5 | server: 6 | listen_host: $SERVER_LISTEN_HOST$ 7 | host: $SERVER_HOST$ 8 | port: $SERVER_PORT$ 9 | heartbeat_interval_s: 6 10 | metrics_collect_interval_s: 300 11 | approximate_size_metrics_collect_interval_s: 300 12 | get_tso_interval_ms: 1000 13 | # worker_thread_num: 36 # must >4, worker_thread_num priority worker_thread_ratio 14 | worker_thread_ratio: 4 # cpu core * ratio 15 | region: 16 | region_max_size: 268435456 # 256MB 17 | enable_auto_split: true 18 | split_check_interval_s: 120 19 | enable_auto_merge: true 20 | merge_check_interval_s: 120 21 | max_merge_region_size: 1048576 # 1MB 22 | max_merge_region_keys: 10000 23 | split_merge_interval: 3600 #1h 24 | merge_size_ratio: 0.2 25 | merge_keys_ratio: 0.2 26 | merge_check_concurrency: 3 27 | raft: 28 | listen_host: $RAFT_LISTEN_HOST$ 29 | host: $RAFT_HOST$ 30 | port: $RAFT_PORT$ 31 | path: $BASE_PATH$/data/raft 32 | election_timeout_s: 6 33 | snapshot_interval_s: 120 34 | segmentlog_max_segment_size: 33554432 # 32MB 35 | leader_num_weight: 1 36 | log: 37 | level: INFO 38 | path: $BASE_PATH$/log 39 | store: 40 | path: $BASE_PATH$/data/db 41 | background_thread_num: 16 # background_thread_num priority background_thread_ratio 42 | # background_thread_ratio: 0.5 # cpu core * ratio 43 | stats_dump_period_s: 120 44 | scan: 45 | scan_interval_s: 30 46 | timeout_s: 300 47 | max_bytes_rpc: 4194304 48 | max_fetch_cnt_by_server: 1000 49 | scan_v2: 50 | scan_interval_s: 30 51 | timeout_s: 300 52 | max_bytes_rpc: 4194304 53 | max_fetch_cnt_by_server: 1000 54 | gc: 55 | update_safe_point_interval_s: 60 56 | do_gc_interval_s: 60 57 | -------------------------------------------------------------------------------- /contrib/.clang-tidy: -------------------------------------------------------------------------------- 1 | # Disable all checks in this folder. 2 | Checks: '-*' 3 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM dingodatabase/dingo-eureka:rocky8 2 | 3 | ENV TZ=Asia/Shanghai 4 | SHELL ["/bin/bash", "-c"] 5 | 6 | RUN dnf update -y \ 7 | && dnf install -y vim unzip net-tools tzdata wget git gcc gcc-c++ make automake openssl openssl-devel gcc-toolset-13* libtool patch libaio-devel boost-devel \ 8 | && dnf clean all \ 9 | && ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime \ 10 | && echo ${TZ} > /etc/timezone \ 11 | && unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY 12 | 13 | COPY ./dingo-store.tar.gz /opt 14 | 15 | RUN cd /opt && mkdir dingo-store && tar -zxvf dingo-store.tar.gz -C dingo-store && chmod +x -R /opt/dingo-store/* && sed -i 's/electionTimeout: [0-9]\+/electionTimeout: 30000/g' /opt/dingo-store/conf/store.template.yaml && sed -i 's/electionTimeout: [0-9]\+/electionTimeout: 30000/g' /opt/dingo-store/conf/coordinator.template.yaml 16 | 17 | ENV PATH=/opt/rh/gcc-toolset-13/root/usr/bin:$PATH 18 | WORKDIR /opt/dingo-store 19 | 20 | ENTRYPOINT [ "/opt/dingo-store/scripts/docker-dingo-store.sh" ] 21 | CMD ["cleanstart"] 22 | -------------------------------------------------------------------------------- /docker/centos8/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos8 2 | 3 | ENV TZ=Asia/Shanghai 4 | SHELL ["/bin/bash", "-c"] 5 | 6 | RUN echo "[oneAPI]" > /tmp/oneAPI.repo 7 | RUN echo "name=Intel® oneAPI repository">>/tmp/oneAPI.repo 8 | RUN echo "baseurl=https://yum.repos.intel.com/oneapi">>/tmp/oneAPI.repo 9 | RUN echo "enabled=1">>/tmp/oneAPI.repo 10 | RUN echo "gpgcheck=1">>/tmp/oneAPI.repo 11 | RUN echo "repo_gpgcheck=1">>/tmp/oneAPI.repo 12 | RUN echo "gpgkey=https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB">>/tmp/oneAPI.repo 13 | 14 | RUN mv /tmp/oneAPI.repo /etc/yum.repos.d 15 | 16 | RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* && dnf update -y \ 17 | && dnf install -y java-1.8.0-openjdk-devel vim unzip net-tools tzdata wget git gcc gcc-c++ make automake maven openssl openssl-devel patch gcc-toolset-11* libtool perl-IPC-Cmd intel-oneapi-mkl-devel-2024.1.x86_64 libaio-devel boost-devel \ 18 | && dnf clean all \ 19 | && ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime \ 20 | && echo ${TZ} > /etc/timezone \ 21 | && wget https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-x86_64.tar.gz \ 22 | && tar -zxvf cmake-3.26.4-linux-x86_64.tar.gz \ 23 | && mv cmake-3.26.4-linux-x86_64 /opt/ \ 24 | && rm -f cmake-3.26.4-linux-x86_64.tar.gz 25 | 26 | # install rust 27 | RUN wget https://sh.rustup.rs --content-disposition 28 | RUN sh rustup-init.sh -y 29 | 30 | # soure env 31 | RUN echo "source /opt/intel/oneapi/setvars.sh" >> /root/.bashrc 32 | 33 | ENV PATH="/opt/intel/oneapi:$PATH" 34 | ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk 35 | ENV PATH=/root/.cargo/bin:/opt/rh/gcc-toolset-11/root/usr/bin:/opt/cmake-3.26.4-linux-x86_64/bin:$PATH 36 | WORKDIR /opt 37 | -------------------------------------------------------------------------------- /docker/dev_build_from_docker.md: -------------------------------------------------------------------------------- 1 | # Use Docker Image 2 | 3 | We provide docker images of different operating systems to support compilation and development.including 4 | 5 | - ubuntu18.04 6 | - ubuntu22.04 7 | - centos7 8 | - centos8 9 | - rocky8.8 10 | - rocky9.2 11 | 12 | ## Build docker image 13 | 14 | For different operating systems, we can refer to the following commands to build 15 | 16 | `````` 17 | cd dingo-store 18 | 19 | docker build docker/ubuntu18/ -t dingo-store-ubuntu-18.04-dev 20 | 21 | docker build docker/ubuntu22/ -t dingo-store-ubuntu-22.04-dev:eureka 22 | 23 | docker build docker/centos7/ -t dingo-store-centos-7-dev 24 | 25 | docker build docker/centos8/ -t dingo-store-centos-8-dev 26 | 27 | docker build docker/rocky8/ -t dingo-store-rocky-8-dev:eureka 28 | 29 | docker build docker/rocky9/ -t dingo-store-rocky-9-dev:eureka 30 | `````` 31 | 32 | If you want to start quickly, we can refer to the following commands to pull container 33 | 34 | `````` 35 | docker pull dingodatabase/dingo-store-ubuntu-18.04-dev 36 | 37 | docker pull dingodatabase/dingo-store-ubuntu-22.04-dev:eureka 38 | 39 | docker pull dingodatabase/dingo-store-centos-7-dev 40 | 41 | docker pull dingodatabase/dingo-store-centos-8-dev 42 | 43 | docker pull dingodatabase/dingo-store-rocky-8-dev:eureka 44 | 45 | docker pull dingodatabase/dingo-store-rocky-9-dev:eureka 46 | `````` 47 | 48 | ## Use docker container 49 | 50 | After building the docker image succeed, we can use docker run to launch the docker service. rocky9 docker image for example: 51 | 52 | `````` 53 | docker run -it dingo-store-rocky-9-dev:eureka 54 | `````` 55 | 56 | -------------------------------------------------------------------------------- /docker/ubuntu18/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | ENV TZ=Asia/Shanghai \ 4 | DEBIAN_FRONTEND=noninteractive 5 | SHELL ["/bin/bash", "-c"] 6 | 7 | RUN chmod 777 /tmp && apt-get update \ 8 | && apt-get install -y openjdk-8-jdk vim unzip netcat net-tools tzdata wget git gcc g++ make automake maven openssl libssl-dev libtool libboost-dev libboost-program-options-dev libaio-dev \ 9 | && apt-get install -y software-properties-common \ 10 | && add-apt-repository -y ppa:ubuntu-toolchain-r/test \ 11 | && apt-get update \ 12 | && apt-get install -y gcc-11 g++-11 \ 13 | && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 \ 14 | && wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null \ 15 | && echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list \ 16 | && apt-get update && apt-get install -y intel-oneapi-mkl-devel-2024.1 \ 17 | && unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY \ 18 | && ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime \ 19 | && echo ${TZ} > /etc/timezone \ 20 | && dpkg-reconfigure --frontend noninteractive tzdata \ 21 | && rm -rf /var/lib/apt/lists/* \ 22 | && wget https://cmake.org/files/v3.25/cmake-3.25.2.tar.gz --no-check-certificate && tar -zxvf cmake-3.25.2.tar.gz && rm -f cmake-3.25.2.tar.gz && cd cmake-3.25.2 && ./bootstrap && make -j$(nproc) && make install && cd .. && rm -rf cmake-3.25.2 23 | 24 | # install rust 25 | RUN wget https://sh.rustup.rs --content-disposition 26 | RUN sh rustup-init.sh -y 27 | 28 | # soure env 29 | RUN echo "source /opt/intel/oneapi/setvars.sh" >> /root/.bashrc 30 | 31 | ENV PATH="/root/.cargo/bin:/opt/intel/oneapi:$PATH" 32 | 33 | 34 | ENV PATH="/root/.cargo/bin:$PATH" 35 | 36 | ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/ 37 | 38 | WORKDIR /opt 39 | -------------------------------------------------------------------------------- /docs/images/dingo-store-architecture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dingodb/dingo-store/23438693497dd316c3df27bfafd9a2874739edaa/docs/images/dingo-store-architecture.jpg -------------------------------------------------------------------------------- /docs/images/dingo_contact.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dingodb/dingo-store/23438693497dd316c3df27bfafd9a2874739edaa/docs/images/dingo_contact.jpg -------------------------------------------------------------------------------- /java/dingo-grpc-tools/src/main/java/io/dingodb/grpc/OneOfNestMethod.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.grpc; 2 | 3 | import com.squareup.javapoet.ClassName; 4 | import com.squareup.javapoet.MethodSpec; 5 | import com.squareup.javapoet.TypeName; 6 | import com.squareup.javapoet.TypeSpec; 7 | 8 | import static javax.lang.model.element.Modifier.ABSTRACT; 9 | import static javax.lang.model.element.Modifier.PUBLIC; 10 | 11 | public class OneOfNestMethod { 12 | 13 | public static void addNestMethod(ClassName nestName, TypeSpec.Builder nestBuilder) { 14 | if (nestName.simpleName().equals("VectorIndexParameterNest")) { 15 | nestBuilder.addMethod(MethodSpec 16 | .methodBuilder("getDimension") 17 | .addModifiers(PUBLIC, ABSTRACT) 18 | .returns(TypeName.INT) 19 | .build() 20 | ).addMethod(MethodSpec 21 | .methodBuilder("getMetricType") 22 | .addModifiers(PUBLIC, ABSTRACT) 23 | .returns(ClassName.bestGuess("io.dingodb.sdk.service.entity.common.MetricType")) 24 | .build() 25 | ); 26 | } 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /java/dingo-grpc-tools/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | io.dingodb.grpc.RpcMethodAnnotationProcessor 2 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/Context.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common; 18 | 19 | import io.dingodb.sdk.common.region.RegionEpoch; 20 | import lombok.AllArgsConstructor; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.Setter; 24 | import lombok.ToString; 25 | 26 | @Getter 27 | @ToString 28 | @EqualsAndHashCode 29 | @AllArgsConstructor 30 | public class Context { 31 | 32 | private DingoCommonId regionId; 33 | @Setter 34 | private RegionEpoch regionEpoch; 35 | } 36 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/DingoCommonId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common; 18 | 19 | public interface DingoCommonId { 20 | 21 | Type type(); 22 | 23 | long parentId(); 24 | 25 | long entityId(); 26 | 27 | enum Type { 28 | ENTITY_TYPE_SCHEMA, 29 | ENTITY_TYPE_TABLE, 30 | ENTITY_TYPE_PART, 31 | ENTITY_TYPE_INDEX, 32 | ENTITY_TYPE_REGION; 33 | } 34 | 35 | static boolean equals(DingoCommonId id1, DingoCommonId id2) { 36 | if (id1 == id2) { 37 | return true; 38 | } 39 | 40 | if (id1.parentId() != id2.parentId()) { 41 | return false; 42 | } 43 | if (id1.entityId() != id2.entityId()) { 44 | return false; 45 | } 46 | return id1.type() == id2.type(); 47 | } 48 | 49 | static int hashCode(DingoCommonId id) { 50 | int result = id.type().hashCode(); 51 | result = 31 * result + (int) (id.parentId() ^ (id.parentId() >>> 32)); 52 | result = 31 * result + (int) (id.entityId() ^ (id.entityId() >>> 32)); 53 | return result; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/KeyValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common; 18 | 19 | public class KeyValue extends Row { 20 | 21 | public KeyValue(byte[] primaryKey, byte[] raw) { 22 | super(primaryKey, new int[0], new int[0], new byte[][] {raw}); 23 | } 24 | 25 | public void setKey(byte[] key) { 26 | primaryKey = key; 27 | } 28 | 29 | public void setValue(byte[] value) { 30 | columns[0] = value; 31 | } 32 | 33 | public byte[] getKey() { 34 | return primaryKey; 35 | } 36 | 37 | public byte[] getValue() { 38 | return columns[0]; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/KeyValueWithExpect.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.common; 2 | 3 | import lombok.Getter; 4 | 5 | import java.util.Arrays; 6 | 7 | @Getter 8 | public class KeyValueWithExpect extends KeyValue { 9 | 10 | public final byte[] expect; 11 | 12 | public KeyValueWithExpect(byte[] primaryKey, byte[] raw, byte[] expect) { 13 | super(primaryKey, raw); 14 | this.expect = expect; 15 | } 16 | 17 | public KeyValueWithExpect(KeyValue keyValue, byte[] expect) { 18 | this(keyValue.getKey(), keyValue.getValue(), expect); 19 | } 20 | 21 | @Override 22 | public boolean equals(Object o) { 23 | if (this == o) { 24 | return true; 25 | } 26 | if (o == null || getClass() != o.getClass()) { 27 | return false; 28 | } 29 | if (!super.equals(o)) { 30 | return false; 31 | } 32 | KeyValueWithExpect that = (KeyValueWithExpect) o; 33 | return Arrays.equals(primaryKey, that.primaryKey); 34 | } 35 | 36 | @Override 37 | public int hashCode() { 38 | return Arrays.hashCode(primaryKey); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/Location.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | 23 | @Getter 24 | @AllArgsConstructor 25 | @EqualsAndHashCode 26 | public class Location { 27 | 28 | private String host; 29 | private int port; 30 | 31 | @Override 32 | public String toString() { 33 | return host + ":" + port; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/Range.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | 22 | @Getter 23 | @AllArgsConstructor 24 | public class Range { 25 | 26 | public final byte[] startKey; 27 | public final byte[] endKey; 28 | } 29 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/RangeWithOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021, Zetyun DataPortal All rights reserved. 3 | */ 4 | 5 | package io.dingodb.sdk.common; 6 | 7 | import lombok.AllArgsConstructor; 8 | import lombok.Getter; 9 | 10 | @Getter 11 | @AllArgsConstructor 12 | public class RangeWithOptions { 13 | 14 | private Range range; 15 | private boolean withStart; 16 | private boolean withEnd; 17 | } 18 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/Row.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.Setter; 24 | import lombok.ToString; 25 | 26 | @Getter 27 | @Setter 28 | @ToString 29 | @NoArgsConstructor 30 | @AllArgsConstructor 31 | @EqualsAndHashCode 32 | public class Row { 33 | 34 | protected byte[] primaryKey; 35 | protected int[] indexes; 36 | protected int[] width; 37 | protected byte[][] columns; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/cluster/Coordinator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.cluster; 18 | 19 | import io.dingodb.sdk.common.Location; 20 | 21 | public interface Coordinator { 22 | int state(); 23 | Location location(); 24 | 25 | boolean isLeader(); 26 | } 27 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/cluster/Executor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.cluster; 18 | 19 | import io.dingodb.sdk.common.Location; 20 | 21 | public interface Executor { 22 | 23 | Location serverLocation(); 24 | 25 | ExecutorUser executorUser(); 26 | 27 | String resourceTag(); 28 | } 29 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/cluster/ExecutorMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.cluster; 18 | 19 | import java.util.List; 20 | 21 | public interface ExecutorMap { 22 | 23 | long getEpoch(); 24 | 25 | List getExecutors(); 26 | } 27 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/cluster/ExecutorUser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.cluster; 18 | 19 | public interface ExecutorUser { 20 | 21 | String getUser(); 22 | 23 | String getKeyring(); 24 | } 25 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/cluster/InternalCoordinator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.cluster; 18 | 19 | import io.dingodb.sdk.common.Location; 20 | 21 | public class InternalCoordinator implements Coordinator { 22 | private int state; 23 | private Location location; 24 | 25 | private boolean isLeader; 26 | 27 | public InternalCoordinator(Location location, boolean isLeader) { 28 | this.location = location; 29 | this.isLeader = isLeader; 30 | this.state = 1; 31 | } 32 | 33 | public InternalCoordinator(Location location, boolean isLeader, int state) { 34 | this.location = location; 35 | this.isLeader = isLeader; 36 | this.state = state; 37 | } 38 | 39 | @Override 40 | public int state() { 41 | return state; 42 | } 43 | 44 | @Override 45 | public Location location() { 46 | return location; 47 | } 48 | 49 | @Override 50 | public boolean isLeader() { 51 | return isLeader; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/cluster/InternalExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.cluster; 18 | 19 | import io.dingodb.sdk.common.Location; 20 | 21 | public class InternalExecutor implements Executor { 22 | 23 | private Location serverLocation; 24 | private ExecutorUser executorUser; 25 | private String resourceTag; 26 | 27 | public InternalExecutor(Location serverLocation, ExecutorUser executorUser, String resourceTag) { 28 | this.serverLocation = serverLocation; 29 | this.executorUser = executorUser; 30 | this.resourceTag = resourceTag; 31 | } 32 | 33 | @Override 34 | public Location serverLocation() { 35 | return this.serverLocation; 36 | } 37 | 38 | @Override 39 | public ExecutorUser executorUser() { 40 | return this.executorUser; 41 | } 42 | 43 | @Override 44 | public String resourceTag() { 45 | return resourceTag; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/cluster/InternalExecutorMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.cluster; 18 | 19 | import java.util.List; 20 | 21 | public class InternalExecutorMap implements ExecutorMap { 22 | 23 | private long epoch; 24 | private List executors; 25 | 26 | public InternalExecutorMap(long epoch, List executors) { 27 | this.epoch = epoch; 28 | this.executors = executors; 29 | } 30 | 31 | @Override 32 | public long getEpoch() { 33 | return epoch; 34 | } 35 | 36 | @Override 37 | public List getExecutors() { 38 | return executors; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/cluster/InternalExecutorUser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.cluster; 18 | 19 | public class InternalExecutorUser implements ExecutorUser { 20 | 21 | private String user; 22 | private String keyring; 23 | 24 | public InternalExecutorUser(String user, String keyring) { 25 | this.user = user; 26 | this.keyring = keyring; 27 | } 28 | 29 | @Override 30 | public String getUser() { 31 | return user; 32 | } 33 | 34 | @Override 35 | public String getKeyring() { 36 | return keyring; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/cluster/InternalStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.cluster; 18 | 19 | import io.dingodb.sdk.common.Location; 20 | 21 | public class InternalStore implements Store { 22 | private long id; 23 | private int storeType; 24 | private int storeState; 25 | private Location serverLocation; 26 | private Location raftLocation; 27 | 28 | public InternalStore(long id, int storeType, int storeState, Location serverLocation, Location raftLocation) { 29 | this.id = id; 30 | this.storeType = storeType; 31 | this.storeState = storeState; 32 | this.serverLocation = serverLocation; 33 | this.raftLocation = raftLocation; 34 | } 35 | 36 | @Override 37 | public long id() { 38 | return id; 39 | } 40 | 41 | @Override 42 | public int storeType() { 43 | return storeType; 44 | } 45 | 46 | @Override 47 | public Location serverLocation() { 48 | return serverLocation; 49 | } 50 | 51 | @Override 52 | public Location raftLocation() { 53 | return raftLocation; 54 | } 55 | 56 | @Override 57 | public int storeState() { 58 | return storeState; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/cluster/Region.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.cluster; 18 | 19 | import io.dingodb.sdk.common.Location; 20 | 21 | import java.util.List; 22 | 23 | public interface Region { 24 | public long regionId(); 25 | public int regionState(); 26 | public int regionType(); 27 | public long createTime(); 28 | 29 | public long deleteTime(); 30 | 31 | public List followers(); 32 | 33 | public Location leader(); 34 | 35 | public long leaderStoreId(); 36 | } 37 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/cluster/Store.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.cluster; 18 | 19 | import io.dingodb.sdk.common.Location; 20 | 21 | public interface Store { 22 | public long id(); 23 | public int storeType(); 24 | public Location serverLocation(); 25 | public Location raftLocation(); 26 | 27 | public int storeState(); 28 | } 29 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/codec/KeyValueCodec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.codec; 18 | 19 | import io.dingodb.sdk.common.KeyValue; 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | 22 | public interface KeyValueCodec { 23 | Object[] decode(KeyValue keyValue); 24 | 25 | Object[] decodeKeyPrefix(byte[] keyPrefix); 26 | 27 | KeyValue encode(Object @NonNull [] record); 28 | 29 | byte[] encodeKey(Object[] record); 30 | 31 | default byte[] encodeKeyPrefix(Object[] record) { 32 | return encodeKeyPrefix(record, record.length); 33 | } 34 | 35 | byte[] encodeKeyPrefix(Object[] record, int columnCount); 36 | 37 | byte[] encodeMinKeyPrefix(); 38 | 39 | byte[] encodeMaxKeyPrefix(); 40 | 41 | byte[] resetPrefix(byte[] key, long prefix); 42 | } 43 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/index/BruteForceParam.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.common.index; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.EqualsAndHashCode; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | @Getter 10 | @ToString 11 | @EqualsAndHashCode 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | public class BruteForceParam { 15 | 16 | private Integer dimension; 17 | private VectorIndexParameter.MetricType metricType; 18 | } 19 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/index/DiskAnnParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.index; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.ToString; 24 | 25 | @Getter 26 | @ToString 27 | @EqualsAndHashCode 28 | @NoArgsConstructor 29 | @AllArgsConstructor 30 | public class DiskAnnParam { 31 | 32 | private Integer dimension; 33 | private VectorIndexParameter.MetricType metricType; 34 | } 35 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/index/FlatParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.index; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.ToString; 24 | 25 | @Getter 26 | @ToString 27 | @EqualsAndHashCode 28 | @NoArgsConstructor 29 | @AllArgsConstructor 30 | public class FlatParam { 31 | 32 | private Integer dimension; 33 | private VectorIndexParameter.MetricType metricType; 34 | } 35 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/index/HnswParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.index; 18 | 19 | import lombok.*; 20 | 21 | @Getter 22 | @ToString 23 | @EqualsAndHashCode 24 | @NoArgsConstructor 25 | @AllArgsConstructor 26 | public class HnswParam { 27 | 28 | private Integer dimension; 29 | private VectorIndexParameter.MetricType metricType; 30 | private Integer efConstruction; 31 | @Setter 32 | private Integer maxElements; 33 | private Integer nlinks; 34 | } 35 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/index/Index.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.index; 18 | 19 | import io.dingodb.sdk.common.partition.Partition; 20 | 21 | public interface Index { 22 | 23 | String getName(); 24 | 25 | Integer getVersion(); 26 | 27 | Partition getIndexPartition(); 28 | 29 | Integer getReplica(); 30 | 31 | IndexParameter getIndexParameter(); 32 | 33 | Boolean getIsAutoIncrement(); 34 | 35 | Long getAutoIncrement(); 36 | } 37 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/index/IndexMetrics.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.index; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | 22 | @Getter 23 | @AllArgsConstructor 24 | public class IndexMetrics { 25 | 26 | private Long rowsCount; 27 | private byte[] minKey; 28 | private byte[] maxKey; 29 | private Long partCount; 30 | 31 | private VectorIndexParameter.VectorIndexType indexType; 32 | private Long currentCount; 33 | private Long deletedCount; 34 | private Long maxId; 35 | private Long minId; 36 | private Long memoryBytes; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/index/IndexParameter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.index; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.ToString; 24 | 25 | @Getter 26 | @ToString 27 | @EqualsAndHashCode 28 | @NoArgsConstructor 29 | @AllArgsConstructor 30 | public class IndexParameter { 31 | 32 | private IndexType indexType; 33 | private VectorIndexParameter vectorIndexParameter; 34 | private ScalarIndexParameter scalarIndexParameter; 35 | 36 | public IndexParameter(IndexType indexType, VectorIndexParameter vectorIndexParameter) { 37 | this.indexType = indexType; 38 | this.vectorIndexParameter = vectorIndexParameter; 39 | } 40 | 41 | public IndexParameter(IndexType indexType, ScalarIndexParameter scalarIndexParameter) { 42 | this.indexType = indexType; 43 | this.scalarIndexParameter = scalarIndexParameter; 44 | } 45 | 46 | public enum IndexType { 47 | INDEX_TYPE_NONE, 48 | INDEX_TYPE_VECTOR, 49 | INDEX_TYPE_SCALAR 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/index/IvfFlatParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.index; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.ToString; 24 | 25 | @Getter 26 | @ToString 27 | @EqualsAndHashCode 28 | @NoArgsConstructor 29 | @AllArgsConstructor 30 | public class IvfFlatParam { 31 | 32 | private Integer dimension; 33 | private VectorIndexParameter.MetricType metricType; 34 | private Integer ncentroids; 35 | } 36 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/index/IvfPqParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.index; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.ToString; 24 | 25 | @Getter 26 | @ToString 27 | @EqualsAndHashCode 28 | @NoArgsConstructor 29 | @AllArgsConstructor 30 | public class IvfPqParam { 31 | 32 | private Integer dimension; 33 | private VectorIndexParameter.MetricType metricType; 34 | private Integer ncentroids; 35 | private Integer nsubvector; 36 | private Integer bucketInitSize; 37 | private Integer bucketMaxSize; 38 | private Integer nbitsPerIdx; 39 | } 40 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/index/ScalarIndexParameter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.index; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.ToString; 23 | 24 | @Getter 25 | @ToString 26 | @EqualsAndHashCode 27 | @AllArgsConstructor 28 | public class ScalarIndexParameter { 29 | 30 | private ScalarIndexType scalarIndexType; 31 | private boolean isUnique; 32 | 33 | @ToString 34 | public enum ScalarIndexType { 35 | SCALAR_INDEX_TYPE_NONE, 36 | SCALAR_INDEX_TYPE_LSM, 37 | SCALAR_INDEX_TYPE_BTREE 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/partition/Partition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.partition; 18 | 19 | import java.util.List; 20 | 21 | public interface Partition { 22 | 23 | @Deprecated 24 | String getFuncName(); 25 | 26 | default String getStrategy() { 27 | return getFuncName(); 28 | } 29 | 30 | List getCols(); 31 | 32 | List getDetails(); 33 | } 34 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/partition/PartitionDetail.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.partition; 18 | 19 | import io.dingodb.sdk.common.DingoCommonId; 20 | 21 | public interface PartitionDetail { 22 | 23 | default DingoCommonId id() { 24 | return null; 25 | } 26 | 27 | default String getPartName() { 28 | return null; 29 | } 30 | 31 | default String getOperator() { 32 | return null; 33 | } 34 | 35 | Object[] getOperand(); 36 | } 37 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/partition/PartitionDetailDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.partition; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.ToString; 22 | 23 | import java.util.List; 24 | 25 | @Getter 26 | @ToString 27 | @EqualsAndHashCode 28 | public class PartitionDetailDefinition implements PartitionDetail { 29 | 30 | private String partName; 31 | private String operator; 32 | private Object[] operand; 33 | 34 | public PartitionDetailDefinition(String partName, String operator, List operand) { 35 | this(partName, operator, operand.toArray()); 36 | } 37 | 38 | public PartitionDetailDefinition(Object partName, String operator, Object[] operand) { 39 | if (partName != null) { 40 | this.partName = partName.toString(); 41 | } 42 | this.operator = operator; 43 | this.operand = operand; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/partition/PartitionRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.partition; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NoArgsConstructor; 22 | import lombok.ToString; 23 | 24 | import java.util.Collections; 25 | import java.util.List; 26 | 27 | @Getter 28 | @ToString 29 | @NoArgsConstructor 30 | @EqualsAndHashCode 31 | public class PartitionRule implements Partition { 32 | 33 | String funcName; 34 | 35 | List cols; 36 | 37 | List details; 38 | 39 | public PartitionRule(String strategy, List details) { 40 | this(strategy, Collections.emptyList(), details); 41 | } 42 | 43 | public PartitionRule(String strategy, List cols, List details) { 44 | this.funcName = strategy; 45 | this.cols = cols; 46 | this.details = details; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/region/RegionEpoch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.region; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.ToString; 23 | 24 | @Getter 25 | @ToString 26 | @EqualsAndHashCode 27 | @AllArgsConstructor 28 | public class RegionEpoch { 29 | 30 | private Long confVersion; 31 | private Long version; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/region/RegionHeartbeatState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.region; 18 | 19 | public enum RegionHeartbeatState { 20 | 21 | REGION_ONLINE, // region is online 22 | REGION_DOWN // region is offline 23 | } 24 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/region/RegionState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.region; 18 | 19 | public enum RegionState { 20 | REGION_NEW, // create new region 21 | REGION_NORMAL, 22 | 23 | REGION_EXPAND, // start to expand 24 | REGION_EXPANDING, // leader start to expand region 25 | REGION_EXPANDED, // new peer joined raft 26 | 27 | REGION_SHRINK, // start to shrink 28 | REGION_SHIRINKING, // leader start to shrink region 29 | REGION_SHRANK, // shrink finish, maybe we don't need this state 30 | 31 | REGION_DELETE, // region need to delete 32 | REGION_DELETING, // region is deleting 33 | REGION_DELETED, // region is deleted 34 | 35 | REGION_SPLIT, // region need to split 36 | REGION_SPLITTING, // region is splitting 37 | REGION_SPLITED, // region is splited (split's past tense is split, not splited, use as a symbol here) 38 | 39 | REGION_MERGE, // region need to merge 40 | REGION_MERGING, // region is mergting 41 | REGION_MERGED, // region is merged 42 | 43 | // other state add here 44 | REGION_ILLEGAL, // region is not create by coordinator 45 | REGION_STANDBY 46 | } 47 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/region/RegionStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.region; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | 22 | @Getter 23 | @AllArgsConstructor 24 | public class RegionStatus { 25 | 26 | private RegionState state; 27 | 28 | private RegionHeartbeatState heartbeatState; 29 | } 30 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/serial/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.serial; 18 | 19 | public class Config { 20 | public final static int SCALE = 100; 21 | public final static int KEY_PREFIX_SIZE = 9; 22 | public final static int KEY_REVERSE_TAG_SIZE = 4; 23 | 24 | public final static byte CODEC_VERSION = 1; 25 | public final static byte CODEC_VERSION_V2 = 2; 26 | 27 | public final static int idUnit = 2; 28 | public final static int offsetUnit = 4; 29 | } 30 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/serial/schema/Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.serial.schema; 18 | 19 | import java.util.Locale; 20 | 21 | public enum Type { 22 | BOOLEAN, INTEGER, FLOAT, BIT, LONG, DOUBLE, BYTES, STRING, VECTOR, ARRAY, 23 | BOOLEANLIST, INTEGERLIST, FLOATLIST, LONGLIST, DOUBLELIST, STRINGLIST, DECIMAL; 24 | 25 | private final String name; 26 | 27 | Type() { 28 | this.name = this.name().toLowerCase(Locale.ENGLISH); 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/table/Column.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.table; 18 | 19 | public interface Column { 20 | 21 | int DEFAULT_PRECISION = -1; 22 | int DEFAULT_SCALE = Integer.MIN_VALUE; 23 | int DISABLE = 1; 24 | int HIDDEN = 1 << 1; 25 | 26 | String getName(); 27 | 28 | String getType(); 29 | 30 | String getElementType(); 31 | 32 | int getPrecision(); 33 | 34 | int getScale(); 35 | 36 | boolean isNullable(); 37 | 38 | int getPrimary(); 39 | 40 | String getDefaultValue(); 41 | 42 | boolean isAutoIncrement(); 43 | 44 | String getComment(); 45 | 46 | default int getState() { 47 | return DISABLE; 48 | } 49 | 50 | default int getCreateVersion() { 51 | return 1; 52 | } 53 | 54 | default int getUpdateVersion() { 55 | return 1; 56 | } 57 | 58 | default int getDeleteVersion() { 59 | return -1; 60 | } 61 | 62 | default boolean isPrimary() { 63 | return getPrimary() > -1; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/table/TableDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.table; 18 | 19 | import io.dingodb.sdk.common.index.IndexParameter; 20 | import io.dingodb.sdk.common.partition.Partition; 21 | import lombok.AllArgsConstructor; 22 | import lombok.Builder; 23 | import lombok.Getter; 24 | import lombok.EqualsAndHashCode; 25 | import lombok.ToString; 26 | 27 | import java.util.List; 28 | import java.util.Map; 29 | 30 | @Getter 31 | @Builder 32 | @ToString 33 | @EqualsAndHashCode 34 | @AllArgsConstructor 35 | public class TableDefinition implements Table { 36 | 37 | private String name; 38 | private List columns; 39 | private int version; 40 | private int ttl; 41 | private Partition partition; 42 | private String engine; 43 | private Map properties; 44 | private int replica; 45 | @Builder.Default 46 | private long autoIncrement = 1; 47 | private String createSql; 48 | private IndexParameter indexParameter; 49 | private String comment; 50 | private String charset; 51 | private String collate; 52 | private String tableType; 53 | private String rowFormat; 54 | private long createTime; 55 | private long updateTime; 56 | private int codecVersion; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/table/metric/TableMetrics.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.table.metric; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | 23 | @Getter 24 | @AllArgsConstructor 25 | @EqualsAndHashCode 26 | public class TableMetrics { 27 | 28 | private byte[] minKey; 29 | private byte[] maxKey; 30 | private long rowCount; 31 | private long partCount; 32 | } 33 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/utils/Any.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.utils; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.ToString; 21 | 22 | @ToString 23 | @EqualsAndHashCode 24 | public class Any { 25 | 26 | public static Any wrap(Object value) { 27 | return new Any(value); 28 | } 29 | 30 | private final Object value; 31 | 32 | public Any(Object value) { 33 | this.value = value; 34 | } 35 | 36 | public T getValue() { 37 | return (T) value; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/utils/Future.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.common.utils; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.experimental.Delegate; 5 | 6 | import java.util.concurrent.CompletableFuture; 7 | import java.util.concurrent.CompletionStage; 8 | 9 | @AllArgsConstructor 10 | public class Future implements java.util.concurrent.Future, CompletionStage { 11 | 12 | interface IFuture extends java.util.concurrent.Future { 13 | } 14 | 15 | interface ICompletionStage extends CompletionStage { 16 | } 17 | 18 | @Delegate(types = {IFuture.class, ICompletionStage.class}) 19 | private final CompletableFuture delegate; 20 | 21 | @Override 22 | public boolean cancel(boolean mayInterruptIfRunning) { 23 | throw new UnsupportedOperationException(); 24 | } 25 | 26 | @Override 27 | public CompletableFuture toCompletableFuture() { 28 | throw new UnsupportedOperationException(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/utils/ReflectionUtils.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.common.utils; 2 | 3 | import java.lang.reflect.ParameterizedType; 4 | 5 | public final class ReflectionUtils { 6 | 7 | private ReflectionUtils() { 8 | } 9 | 10 | public static Class getGenericType(Class cls, int n) { 11 | return (Class) ((ParameterizedType)cls.getGenericSuperclass()).getActualTypeArguments()[n]; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/ScalarField.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import lombok.Getter; 20 | import lombok.NoArgsConstructor; 21 | import lombok.ToString; 22 | 23 | @Getter 24 | @ToString 25 | @NoArgsConstructor 26 | public class ScalarField { 27 | 28 | private Object data; 29 | 30 | public ScalarField(Boolean data) { 31 | this.data = data; 32 | } 33 | 34 | public ScalarField(Integer data) { 35 | this.data = data; 36 | } 37 | 38 | public ScalarField(Long data) { 39 | this.data = data; 40 | } 41 | 42 | public ScalarField(Float data) { 43 | this.data = data; 44 | } 45 | 46 | public ScalarField(Double data) { 47 | this.data = data; 48 | } 49 | 50 | public ScalarField(String data) { 51 | this.data = data; 52 | } 53 | 54 | public ScalarField(byte[] data) { 55 | this.data = data; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/ScalarValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | import lombok.NoArgsConstructor; 22 | import lombok.ToString; 23 | 24 | import java.util.List; 25 | 26 | @Getter 27 | @ToString 28 | @NoArgsConstructor 29 | @AllArgsConstructor 30 | public class ScalarValue { 31 | 32 | private ScalarFieldType fieldType; 33 | private List fields; 34 | 35 | public enum ScalarFieldType { 36 | NONE, 37 | BOOL, 38 | INTEGER, 39 | LONG, 40 | FLOAT, 41 | DOUBLE, 42 | STRING, 43 | BYTES 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/Search.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import lombok.Getter; 20 | import lombok.NoArgsConstructor; 21 | import lombok.ToString; 22 | 23 | @Getter 24 | @ToString 25 | @NoArgsConstructor 26 | public class Search { 27 | 28 | private SearchFlatParam flat; 29 | private SearchIvfFlatParam ivfFlatParam; 30 | private SearchIvfPqParam ivfPqParam; 31 | private SearchHnswParam hnswParam; 32 | private SearchDiskAnnParam diskAnnParam; 33 | 34 | public Search(SearchFlatParam flat) { 35 | this.flat = flat; 36 | } 37 | 38 | public Search(SearchIvfFlatParam ivfFlatParam) { 39 | this.ivfFlatParam = ivfFlatParam; 40 | } 41 | 42 | public Search(SearchIvfPqParam ivfPqParam) { 43 | this.ivfPqParam = ivfPqParam; 44 | } 45 | 46 | public Search(SearchHnswParam hnswParam) { 47 | this.hnswParam = hnswParam; 48 | } 49 | 50 | public Search(SearchDiskAnnParam diskAnnParam) { 51 | this.diskAnnParam = diskAnnParam; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/SearchDiskAnnParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | public class SearchDiskAnnParam { 20 | } 21 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/SearchFlatParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | import lombok.NoArgsConstructor; 22 | 23 | @Getter 24 | @AllArgsConstructor 25 | @NoArgsConstructor 26 | public class SearchFlatParam { 27 | 28 | private Integer parallelOnQueries; 29 | } 30 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/SearchHnswParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | import lombok.NoArgsConstructor; 22 | 23 | @Getter 24 | @NoArgsConstructor 25 | @AllArgsConstructor 26 | public class SearchHnswParam { 27 | 28 | private Integer efSearch; 29 | } 30 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/SearchIvfFlatParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | import lombok.NoArgsConstructor; 22 | 23 | @Getter 24 | @NoArgsConstructor 25 | @AllArgsConstructor 26 | public class SearchIvfFlatParam { 27 | 28 | private Integer nprobe; 29 | private Integer parallelOnQueries; 30 | } 31 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/SearchIvfPqParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | import lombok.NoArgsConstructor; 22 | 23 | @Getter 24 | @NoArgsConstructor 25 | @AllArgsConstructor 26 | public class SearchIvfPqParam { 27 | 28 | private Integer nprobe; 29 | private Integer parallelOnQueries; 30 | private Integer recallNum; 31 | } 32 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/Vector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import lombok.Getter; 20 | import lombok.ToString; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | @Getter 26 | @ToString 27 | public class Vector { 28 | 29 | private int dimension; 30 | private ValueType valueType; 31 | private List floatValues; 32 | private List binaryValues; 33 | 34 | public Vector() { 35 | } 36 | 37 | public Vector(int dimension, ValueType valueType, List floatValues, List binaryValues) { 38 | this.dimension = dimension; 39 | this.valueType = valueType; 40 | this.floatValues = floatValues; 41 | this.binaryValues = binaryValues; 42 | } 43 | 44 | public enum ValueType { 45 | FLOAT, 46 | BINARY 47 | } 48 | 49 | public static Vector getFloatInstance(int dimension, List values) { 50 | return new Vector(dimension, ValueType.FLOAT, values, new ArrayList<>()); 51 | } 52 | 53 | public static Vector getBinaryInstance(int dimension, List values) { 54 | return new Vector(dimension, ValueType.BINARY, new ArrayList<>(), values); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/VectorCalcDistance.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import io.dingodb.sdk.common.index.VectorIndexParameter; 20 | import lombok.AllArgsConstructor; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | 25 | import java.util.List; 26 | 27 | @Getter 28 | @NoArgsConstructor 29 | @EqualsAndHashCode 30 | @AllArgsConstructor 31 | public class VectorCalcDistance { 32 | 33 | private Long vectorId; 34 | private AlgorithmType algorithmType; 35 | private VectorIndexParameter.MetricType metricType; 36 | private List leftVectors; 37 | private List rightVectors; 38 | private Boolean isReturnNormalize; 39 | 40 | public enum AlgorithmType { 41 | ALGORITHM_NONE, 42 | ALGORITHM_FAISS, 43 | ALGORITHM_HNSWLIB 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/VectorDistance.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | import lombok.NoArgsConstructor; 22 | 23 | import java.util.List; 24 | 25 | @Getter 26 | @AllArgsConstructor 27 | @NoArgsConstructor 28 | public class VectorDistance { 29 | 30 | private List internalDistances; 31 | } 32 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/VectorDistanceRes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | 24 | import java.util.List; 25 | 26 | @Getter 27 | @NoArgsConstructor 28 | @AllArgsConstructor 29 | @EqualsAndHashCode 30 | public class VectorDistanceRes { 31 | 32 | private List leftVectors; 33 | private List rightVectors; 34 | private List distances; 35 | } 36 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/VectorIndexMetrics.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.common.vector; 2 | 3 | import io.dingodb.sdk.common.index.VectorIndexParameter; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | 7 | @Getter 8 | @AllArgsConstructor 9 | public class VectorIndexMetrics { 10 | 11 | private VectorIndexParameter.VectorIndexType vectorIndexType; 12 | private Long currentCount; 13 | private Long deletedCount; 14 | private Long maxId; 15 | private Long minId; 16 | private Long memoryBytes; 17 | 18 | public VectorIndexMetrics merge(VectorIndexMetrics other) { 19 | vectorIndexType = other.getVectorIndexType(); 20 | currentCount = Long.sum(this.currentCount, other.currentCount); 21 | deletedCount = Long.sum(this.deletedCount, other.deletedCount); 22 | memoryBytes = Long.sum(this.memoryBytes, other.memoryBytes); 23 | maxId = Long.max(this.maxId, other.maxId); 24 | minId = Long.min(this.minId, other.maxId); 25 | return this; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/VectorScanQuery.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.common.vector; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | @Getter 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | public class VectorScanQuery { 14 | 15 | private Long startId; 16 | private Boolean isReverseScan; 17 | private Long maxScanCount; 18 | private Long endId; 19 | 20 | private Boolean withoutVectorData; 21 | private Boolean withoutScalarData; 22 | private List selectedKeys; 23 | private Boolean withoutTableData; 24 | 25 | // Whether to use scalar filtering. 26 | private Boolean useScalarFilter; 27 | private Map scalarForFilter; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/VectorTableData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | 22 | @Getter 23 | @AllArgsConstructor 24 | public class VectorTableData { 25 | 26 | private byte[] key; 27 | private byte[] value; 28 | } 29 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/VectorWithDistance.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import io.dingodb.sdk.common.index.VectorIndexParameter; 20 | import lombok.AllArgsConstructor; 21 | import lombok.Getter; 22 | import lombok.experimental.Delegate; 23 | 24 | @Getter 25 | @AllArgsConstructor 26 | public class VectorWithDistance { 27 | 28 | @Delegate 29 | private VectorWithId withId; 30 | private float distance; 31 | private VectorIndexParameter.MetricType metricType; 32 | } 33 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/VectorWithDistanceResult.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.common.vector; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.util.List; 8 | 9 | @Getter 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | public class VectorWithDistanceResult { 13 | 14 | private List withDistance; 15 | } 16 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/common/vector/VectorWithId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.common.vector; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | 22 | import java.util.Map; 23 | 24 | @Getter 25 | @AllArgsConstructor 26 | public class VectorWithId { 27 | 28 | private long id; 29 | private Vector vector; 30 | private Map scalarData; 31 | private VectorTableData tableData; 32 | 33 | @Deprecated 34 | public VectorWithId(long id, Vector vector, Map scalarData) { 35 | this.id = id; 36 | this.vector = vector; 37 | this.scalarData = scalarData; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/grpc/serializer/Marshaller.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.grpc.serializer; 2 | 3 | import com.google.protobuf.CodedInputStream; 4 | import com.google.protobuf.CodedOutputStream; 5 | import io.dingodb.sdk.service.entity.Message; 6 | import io.grpc.MethodDescriptor; 7 | import lombok.SneakyThrows; 8 | 9 | import java.io.ByteArrayInputStream; 10 | import java.io.ByteArrayOutputStream; 11 | import java.io.InputStream; 12 | import java.util.function.Supplier; 13 | 14 | public class Marshaller implements MethodDescriptor.Marshaller { 15 | 16 | private final Supplier supplier; 17 | 18 | public Marshaller(Supplier supplier) { 19 | this.supplier = supplier; 20 | } 21 | 22 | public T newInstance() { 23 | return supplier.get(); 24 | } 25 | 26 | @SneakyThrows 27 | @Override 28 | public InputStream stream(T value) { 29 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 30 | CodedOutputStream out = CodedOutputStream.newInstance(baos); 31 | value.write(out); 32 | out.flush(); 33 | return new ByteArrayInputStream(baos.toByteArray()); 34 | } 35 | 36 | @SneakyThrows 37 | @Override 38 | public T parse(InputStream stream) { 39 | CodedInputStream inputStream = CodedInputStream.newInstance(stream); 40 | T message = newInstance(); 41 | message.read(inputStream); 42 | return message; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/service/Caller.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.service; 2 | 3 | import io.dingodb.sdk.service.entity.Message.Request; 4 | import io.dingodb.sdk.service.entity.Message.Response; 5 | import io.grpc.CallOptions; 6 | import io.grpc.Channel; 7 | import io.grpc.MethodDescriptor; 8 | 9 | public interface Caller { 10 | 11 | interface CallExecutor { 12 | RES call( 13 | MethodDescriptor method, 14 | REQ request, 15 | CallOptions options, 16 | Channel channel, 17 | long trace, 18 | ServiceCallCycles handlers 19 | ); 20 | } 21 | 22 | RES call( 23 | MethodDescriptor method, long requestId, REQ request, ServiceCallCycles handlers 24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/service/ChannelProvider.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.service; 2 | 3 | import io.dingodb.sdk.service.entity.Message; 4 | import io.grpc.Channel; 5 | 6 | public interface ChannelProvider { 7 | 8 | Channel channel(); 9 | 10 | void refresh(Channel channel, long trace); 11 | 12 | default void before(Message.Request message) { 13 | } 14 | 15 | default void after(Message.Response response) { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/service/Service.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.service; 2 | 3 | public interface Service> { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/service/ServiceMethodBuilder.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.service; 2 | 3 | import io.dingodb.sdk.grpc.serializer.Marshaller; 4 | import io.dingodb.sdk.service.entity.Message; 5 | import io.grpc.MethodDescriptor; 6 | 7 | import java.util.function.Supplier; 8 | 9 | public class ServiceMethodBuilder { 10 | 11 | public static MethodDescriptor buildUnary( 12 | String fullName, Supplier reqSupplier, Supplier resSupplier 13 | ) { 14 | return MethodDescriptor.newBuilder() 15 | .setType(MethodDescriptor.MethodType.UNARY) 16 | .setFullMethodName(fullName) 17 | .setSampledToLocalTracing(true) 18 | .setRequestMarshaller(new Marshaller<>(reqSupplier)) 19 | .setResponseMarshaller(new Marshaller<>(resSupplier)) 20 | .build(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/service/connector/UtilServiceConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.service.connector; 18 | 19 | import io.dingodb.sdk.common.Location; 20 | import io.dingodb.util.UtilServiceGrpc; 21 | import io.grpc.ManagedChannel; 22 | 23 | import java.util.Collections; 24 | import java.util.function.Supplier; 25 | 26 | public class UtilServiceConnector extends ServiceConnector { 27 | 28 | private final Supplier leaderSupplier; 29 | 30 | public UtilServiceConnector(Supplier leaderSupplier) { 31 | super(Collections.emptySet()); 32 | this.leaderSupplier = leaderSupplier; 33 | } 34 | 35 | @Override 36 | protected ManagedChannel transformToLeaderChannel(ManagedChannel channel) { 37 | Location leader = leaderSupplier.get(); 38 | if (leader == null || leader.getHost().isEmpty()) { 39 | return null; 40 | } 41 | return newChannel(leader); 42 | } 43 | 44 | @Override 45 | protected UtilServiceGrpc.UtilServiceBlockingStub newStub(ManagedChannel channel) { 46 | return UtilServiceGrpc.newBlockingStub(channel); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/service/entity/Numeric.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.service.entity; 2 | 3 | public interface Numeric { 4 | 5 | int number(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/service/entity/ServiceCallCycleEntity.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.service.entity; 2 | 3 | import io.grpc.CallOptions; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | 7 | @Builder 8 | @AllArgsConstructor 9 | public class ServiceCallCycleEntity { 10 | 11 | public final String step; 12 | @Builder.Default 13 | public final String status = "OK"; 14 | public final String remote; 15 | public final String method; 16 | @Builder.Default 17 | public final long timestamp = System.currentTimeMillis(); 18 | public final long trace; 19 | public final Message.Request request; 20 | public final Message.Response response; 21 | public final CallOptions options; 22 | public final Exception exception; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/service/lock/LockInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.service.lock; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.ToString; 22 | 23 | import java.nio.charset.StandardCharsets; 24 | 25 | @ToString 26 | @EqualsAndHashCode 27 | @AllArgsConstructor 28 | public class LockInfo { 29 | 30 | public final String key; 31 | public final String value; 32 | public final long revision; 33 | 34 | public LockInfo(byte[] key, byte[] value, long revision) { 35 | this.key = new String(key, StandardCharsets.UTF_8); 36 | this.value = new String(value, StandardCharsets.UTF_8); 37 | this.revision = revision; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/service/store/AggregationOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.service.store; 18 | 19 | public interface AggregationOperator { 20 | 21 | AggregationType getOperation(); 22 | 23 | int getIndexOfColumn(); 24 | 25 | interface AggregationType { 26 | int getCode(); 27 | } 28 | 29 | enum AggregationTypeEnum implements AggregationType { 30 | AGGREGATION_NONE(0), 31 | SUM(1), 32 | COUNT(2), 33 | COUNT_WITH_NULL(3), COUNTWITHNULL(3), 34 | MAX(4), 35 | MIN(5), 36 | SUM_0(6), SUM0(6) 37 | ; 38 | 39 | private final int code; 40 | 41 | AggregationTypeEnum(int code) { 42 | this.code = code; 43 | } 44 | 45 | public int getCode() { 46 | return code; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/service/store/Coprocessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 DataCanvas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.dingodb.sdk.service.store; 18 | 19 | import io.dingodb.sdk.common.table.Column; 20 | 21 | import java.util.List; 22 | 23 | public interface Coprocessor { 24 | 25 | int getSchemaVersion(); 26 | 27 | SchemaWrapper getOriginalSchema(); 28 | 29 | default SchemaWrapper getResultSchema() { 30 | throw new UnsupportedOperationException(); 31 | } 32 | 33 | List getSelection(); 34 | 35 | byte[] getExpression(); 36 | 37 | default List getGroupBy() { 38 | throw new UnsupportedOperationException(); 39 | } 40 | 41 | default List getAggregations() { 42 | throw new UnsupportedOperationException(); 43 | } 44 | 45 | interface SchemaWrapper { 46 | List getSchemas(); 47 | 48 | long getCommonId(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/main/java/io/dingodb/sdk/service/util/OnlineDdlLogUtils.java: -------------------------------------------------------------------------------- 1 | package io.dingodb.sdk.service.util; 2 | 3 | import io.dingodb.sdk.service.entity.Message; 4 | import io.dingodb.sdk.service.entity.store.TxnBatchGetRequest; 5 | import io.dingodb.sdk.service.entity.store.TxnPrewriteRequest; 6 | import io.dingodb.sdk.service.entity.store.TxnCommitRequest; 7 | import io.dingodb.sdk.service.entity.store.TxnScanRequest; 8 | import io.dingodb.sdk.service.entity.store.TxnGetRequest; 9 | import io.dingodb.sdk.service.entity.store.TxnBatchRollbackRequest; 10 | 11 | public final class OnlineDdlLogUtils { 12 | public static long regionId = 0L; 13 | public static boolean enableDdlSqlLog = false; 14 | 15 | public static boolean onlineDdlReq(Message.Request req) { 16 | if (enableDdlSqlLog) { 17 | return true; 18 | } 19 | if(req instanceof TxnPrewriteRequest) { 20 | return ((TxnPrewriteRequest) req).getContext().getRegionId() > regionId; 21 | } else if (req instanceof TxnBatchGetRequest) { 22 | return ((TxnBatchGetRequest) req).getContext().getRegionId() > regionId; 23 | } else if (req instanceof TxnCommitRequest) { 24 | return ((TxnCommitRequest) req).getContext().getRegionId() > regionId; 25 | } else if (req instanceof TxnScanRequest) { 26 | return ((TxnScanRequest) req).getContext().getRegionId() > regionId; 27 | } else if (req instanceof TxnGetRequest) { 28 | return ((TxnGetRequest) req).getContext().getRegionId() > regionId; 29 | } else if (req instanceof TxnBatchRollbackRequest) { 30 | return ((TxnBatchRollbackRequest) req).getContext().getRegionId() > regionId; 31 | } 32 | return true; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /java/dingo-sdk/src/test/resources/simplelogger.properties: -------------------------------------------------------------------------------- 1 | org.slf4j.simpleLogger.defaultLogLevel=info 2 | org.slf4j.simpleLogger.showDateTime=true 3 | org.slf4j.simpleLogger.showThreadId=true 4 | org.slf4j.simpleLogger.showThreadName=true 5 | org.slf4j.simpleLogger.showShortLogName=true 6 | org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss.SSS 7 | org.slf4j.simpleLogger.log.io.grpc.netty=info 8 | org.slf4j.simpleLogger.log.io.dingodb.sdk.service.ServiceCallCycles$Before=debug 9 | org.slf4j.simpleLogger.log.io.dingodb.sdk.service.ServiceCallCycles$RAfter=debug 10 | org.slf4j.simpleLogger.log.io.dingodb.sdk.service.ServiceCallCycles$OnRetry=debug 11 | org.slf4j.simpleLogger.log.io.dingodb.sdk.service.MetaServiceDescriptors$TsoService=debug 12 | org.slf4j.simpleLogger.log.io.dingodb.sdk.service.desc.version=debug -------------------------------------------------------------------------------- /scripts/check_store.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mydir="${BASH_SOURCE%/*}" 4 | if [[ ! -d "$mydir" ]]; then mydir="$PWD"; fi 5 | . $mydir/shflags 6 | 7 | DEFINE_integer retry_times 64 'retry times' 8 | 9 | BASE_DIR=$(dirname $(cd $(dirname $0); pwd)) 10 | DIST_DIR=$BASE_DIR/dist 11 | 12 | DINGODB_BIN=$BASE_DIR/build/bin/ 13 | 14 | echo ${DINGODB_BIN} 15 | 16 | cd ${DINGODB_BIN} 17 | 18 | times=0 19 | DINGODB_HAVE_STORE_AVAILABLE=0 20 | while [ "${DINGODB_HAVE_STORE_AVAILABLE}" -eq 0 -a ${times} -lt ${FLAGS_retry_times} ]; do 21 | DINGODB_HAVE_STORE_AVAILABLE=$(./dingodb_cli GetStoreMap |grep -c DINGODB_HAVE_STORE_AVAILABLE) 22 | times=`expr $times + 1` 23 | 24 | echo "avaiable store count = ${DINGODB_HAVE_STORE_AVAILABLE}, times = ${times}, wait 2 second" 25 | sleep 2 26 | done 27 | 28 | times=0 29 | DINGODB_HAVE_INDEX_AVAILABLE=0 30 | while [ "${DINGODB_HAVE_INDEX_AVAILABLE}" -eq 0 -a ${times} -lt ${FLAGS_retry_times} ]; do 31 | DINGODB_HAVE_INDEX_AVAILABLE=$(./dingodb_cli GetStoreMap |grep -c DINGODB_HAVE_INDEX_AVAILABLE) 32 | times=`expr $times + 1` 33 | 34 | echo "avaiable index count = ${DINGODB_HAVE_INDEX_AVAILABLE}, times = ${times}, wait 2 second" 35 | sleep 2 36 | done 37 | 38 | times=0 39 | DINGODB_HAVE_DOCUMENT_AVAILABLE=0 40 | while [ "${DINGODB_HAVE_DOCUMENT_AVAILABLE}" -eq 0 -a ${times} -lt ${FLAGS_retry_times} ]; do 41 | DINGODB_HAVE_DOCUMENT_AVAILABLE=$(./dingodb_cli GetStoreMap |grep -c DINGODB_HAVE_DOCUMENT_AVAILABLE) 42 | times=`expr $times + 1` 43 | 44 | echo "avaiable document count = ${DINGODB_HAVE_DOCUMENT_AVAILABLE}, times = ${times}, wait 2 second" 45 | sleep 2 46 | done 47 | 48 | ./dingodb_cli GetStoreMap 49 | 50 | echo "dingo-store is READY" 51 | 52 | -------------------------------------------------------------------------------- /scripts/deploy_parameters: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | SERVER_NUM=${FLAGS_server_num} 3 | DEFAULT_REPLICA_NUM=${FLAGS_server_num} 4 | SERVER_HOST=127.0.0.1 5 | SERVER_LISTEN_HOST=0.0.0.0 6 | RAFT_HOST=127.0.0.1 7 | RAFT_LISTEN_HOST=0.0.0.0 8 | DISKANN_SERVER_HOST=127.0.0.1 9 | STORE_INSTANCE_START_ID=20000 10 | SERVER_START_PORT=20000 11 | RAFT_START_PORT=20100 12 | COORDINATOR_INSTANCE_START_ID=22000 13 | COORDINATOR_SERVER_START_PORT=22000 14 | COORDINATOR_RAFT_START_PORT=22100 15 | INDEX_INSTANCE_START_ID=21000 16 | INDEX_SERVER_START_PORT=21000 17 | INDEX_RAFT_START_PORT=21100 18 | DOCUMENT_INSTANCE_START_ID=23000 19 | DOCUMENT_SERVER_START_PORT=23000 20 | DOCUMENT_RAFT_START_PORT=23100 21 | DISKANN_INSTANCE_START_ID=24000 22 | DISKANN_SERVER_START_PORT=24000 23 | DINGODB_ENABLE_LITE=0 24 | DEFAULT_MIN_SYSTEM_DISK_CAPACITY_FREE_RATIO=0.05 25 | DEFAULT_MIN_SYSTEM_MEMORY_CAPACITY_FREE_RATIO=0.20 26 | DINGODB_ENABLE_ROCKSDB_SYNC=0 27 | DINGODB_ENABLE_REGION_SPLIT_AND_MERGE_FOR_LITE=0 28 | 29 | -------------------------------------------------------------------------------- /scripts/format_code.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | 3 | BASE_DIR=$(dirname $(cd $(dirname $0); pwd)) 4 | 5 | find $BASE_DIR/src -name "*.cc" | xargs clang-format -style=file -i 6 | find $BASE_DIR/src -name "*.h" | xargs clang-format -style=file -i 7 | find $BASE_DIR/test -name "*.cc" | xargs clang-format -style=file -i 8 | find $BASE_DIR/test -name "*.h" | xargs clang-format -style=file -i 9 | -------------------------------------------------------------------------------- /scripts/gen_coverage.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | 3 | set -e 4 | 5 | BASE_DIR=$(dirname $(cd $(dirname $0); pwd)) 6 | SRC_DIR=${BASE_DIR}/src 7 | GCOV_OBJ_DIR=/tmp/gcov 8 | LCOV_INFO_FILEPATH=/tmp/lcov/coverage.info 9 | LCOV_OUTPUT_DIR=/tmp/lcov/out 10 | 11 | echo "copy gcno and gcda file..." 12 | if [ ! -d ${GCOV_OBJ_DIR} ];then 13 | mkdir ${GCOV_OBJ_DIR} 14 | fi 15 | find $BASE_DIR/build -name "*.gcno" | grep 'DINGODB_OBJS.dir' | xargs -i mv {} ${GCOV_OBJ_DIR} 16 | find $BASE_DIR/build -name "*.gcda" | grep 'DINGODB_OBJS.dir' | xargs -i mv {} ${GCOV_OBJ_DIR} 17 | 18 | echo "generate gcov file..." 19 | cd ${GCOV_OBJ_DIR} 20 | src_filenames=`find ${SRC_DIR} -name "*.cc" | grep -v 'client' | grep -v 'sdk' | xargs -n1 basename` 21 | for filename in ${src_filenames[*]}; do 22 | gcno_filename=${filename}.gcno 23 | gcda_filename=${filename}.gcda 24 | if [ -f ${gcno_filename} -a -f ${gcda_filename} ];then 25 | gcov ${gcno_filename} --object-directory=${GCOV_OBJ_DIR} --source-prefix=${SRC_DIR} --relative-only 26 | fi 27 | done 28 | 29 | echo "generate material for web report used by lcov..." 30 | if [ -f ${LCOV_INFO_FILEPATH} ];then 31 | rm -f ${LCOV_INFO_FILEPATH} 32 | fi 33 | lcov --capture --directory ${GCOV_OBJ_DIR} --output-file ${LCOV_INFO_FILEPATH} --include '*src/*' 34 | 35 | 36 | echo "generate web report..." 37 | if [ -d ${LCOV_OUTPUT_DIR} ];then 38 | rm -rf ${LCOV_OUTPUT_DIR} 39 | fi 40 | genhtml ${LCOV_INFO_FILEPATH} --title 'dingo-store unit test' --output-directory ${LCOV_OUTPUT_DIR} 41 | 42 | echo "starting http server..." 43 | cd ${LCOV_OUTPUT_DIR} 44 | python3 -m http.server 9002 -------------------------------------------------------------------------------- /scripts/prepare_xdprocks.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | 3 | 4 | mydir="${BASH_SOURCE%/*}" 5 | if [[ ! -d "$mydir" ]]; then mydir="$PWD"; fi 6 | . $mydir/shflags 7 | 8 | DEFINE_string xdprocks_dir '' 'xdprocks path' 9 | 10 | # parse the command-line 11 | FLAGS "$@" || exit 1 12 | eval set -- "${FLAGS_ARGV}" 13 | 14 | if [ "${FLAGS_xdprocks_dir}" == "" ]; then 15 | echo "xdprocks directory is empty." 16 | exit 1 17 | fi 18 | 19 | echo "prepare xdprocks, dir: ${FLAGS_xdprocks_dir}." 20 | 21 | XDPROCKS_INCLUDE_DIR=${FLAGS_xdprocks_dir}/include 22 | 23 | if [ ! -d ${XDPROCKS_INCLUDE_DIR}/xdprocks ]; then 24 | set -ex 25 | 26 | if [ -d ${XDPROCKS_INCLUDE_DIR}/rocksdb ]; then 27 | cp -r ${XDPROCKS_INCLUDE_DIR}/rocksdb ${XDPROCKS_INCLUDE_DIR}/xdprocks 28 | rm -rf ${XDPROCKS_INCLUDE_DIR}/rocksdb_backup 29 | mv -f ${XDPROCKS_INCLUDE_DIR}/rocksdb ${XDPROCKS_INCLUDE_DIR}/rocksdb_backup 30 | elif [ -d ${XDPROCKS_INCLUDE_DIR}/rocksdb_backup ]; then 31 | cp -r ${XDPROCKS_INCLUDE_DIR}/rocksdb_backup ${XDPROCKS_INCLUDE_DIR}/xdprocks 32 | else 33 | echo "not exist rocksdb include directory." 34 | exit 1 35 | fi 36 | 37 | find ${XDPROCKS_INCLUDE_DIR}/xdprocks -name "*.h" | xargs sed -i -e 's/ROCKSDB_NAMESPACE/XDPROCKS_NAMESPACE/g' -e 's/ROCKSDB_MAJOR/XDPROCKS_MAJOR/g' -e 's/ROCKSDB_MINOR/XDPROCKS_MINOR/g' -e 's/ROCKSDB_PATCH/XDPROCKS_PATCH/g' -e 's/rocksdb\//xdprocks\//g' 38 | fi 39 | 40 | echo "prepare xdprocks header file finish." -------------------------------------------------------------------------------- /scripts/start_server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The ulimit is setup in start_server, the paramter of ulimit is: 3 | # ulimit -n 1048576 4 | # ulimit -u 4194304 5 | # ulimit -c unlimited 6 | # If set ulimit failed, please use root or sudo to execute sysctl.sh to increase kernal limit. 7 | 8 | mydir="${BASH_SOURCE%/*}" 9 | if [[ ! -d "$mydir" ]]; then mydir="$PWD"; fi 10 | . $mydir/shflags 11 | 12 | DEFINE_string role 'store' 'server role' 13 | DEFINE_integer server_num 3 'server number' 14 | 15 | # parse the command-line 16 | FLAGS "$@" || exit 1 17 | eval set -- "${FLAGS_ARGV}" 18 | 19 | echo "role: ${FLAGS_role}" 20 | 21 | BASE_DIR=$(dirname $(cd $(dirname $0); pwd)) 22 | DIST_DIR=$BASE_DIR/dist 23 | 24 | SERVER_NUM=${FLAGS_server_num} 25 | 26 | source $mydir/deploy_func.sh 27 | 28 | for ((i=1; i<=$SERVER_NUM; ++i)); do 29 | program_dir=$BASE_DIR/dist/${FLAGS_role}${i} 30 | 31 | start_server ${FLAGS_role} ${program_dir} 32 | done 33 | 34 | echo "Finish..." 35 | -------------------------------------------------------------------------------- /src/br/backup_sdk_meta.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_BR_BACKUP_SDK_META_H_ 16 | #define DINGODB_BR_BACKUP_SDK_META_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "br/interation.h" 23 | #include "butil/status.h" 24 | #include "fmt/core.h" 25 | #include "proto/meta.pb.h" 26 | 27 | namespace br { 28 | 29 | class BackupSdkMeta : public std::enable_shared_from_this { 30 | public: 31 | BackupSdkMeta(ServerInteractionPtr coordinator_interaction, const std::string &storage_internal); 32 | ~BackupSdkMeta(); 33 | 34 | BackupSdkMeta(const BackupSdkMeta&) = delete; 35 | const BackupSdkMeta& operator=(const BackupSdkMeta&) = delete; 36 | BackupSdkMeta(BackupSdkMeta&&) = delete; 37 | BackupSdkMeta& operator=(BackupSdkMeta&&) = delete; 38 | 39 | std::shared_ptr GetSelf(); 40 | 41 | butil::Status GetSdkMetaFromCoordinator(); 42 | 43 | butil::Status Run(); 44 | 45 | butil::Status Backup(); 46 | 47 | std::shared_ptr GetBackupMeta(); 48 | 49 | protected: 50 | private: 51 | ServerInteractionPtr coordinator_interaction_; 52 | std::string storage_internal_; 53 | std::shared_ptr meta_all_; 54 | std::shared_ptr backup_sdk_meta_; 55 | }; 56 | 57 | } // namespace br 58 | 59 | #endif // DINGODB_BR_BACKUP_SDK_META_H_ -------------------------------------------------------------------------------- /src/br/helper.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_BR_HELPER_H_ 16 | #define DINGODB_BR_HELPER_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "butil/endpoint.h" 23 | #include "fmt/core.h" 24 | 25 | namespace br { 26 | 27 | class Helper { 28 | public: 29 | static std::string Ltrim(const std::string& s, const std::string& delete_str); 30 | 31 | static std::string Rtrim(const std::string& s, const std::string& delete_str); 32 | 33 | static std::string Trim(const std::string& s, const std::string& delete_str); 34 | 35 | static int GetRandInt(); 36 | 37 | static std::vector StringToEndpoints(const std::string& str); 38 | 39 | static std::vector VectorToEndpoints(std::vector addrs); 40 | 41 | static std::vector GetAddrsFromFile(const std::string& path); 42 | }; 43 | 44 | } // namespace br 45 | 46 | #endif // DINGODB_BR_HELPER_H_ -------------------------------------------------------------------------------- /src/br/sst_file_reader.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_BR_SST_FILE_READER_H_ 16 | #define DINGODB_BR_SST_FILE_READER_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "butil/status.h" 22 | #include "rocksdb/convenience.h" 23 | #include "rocksdb/db.h" 24 | #include "rocksdb/options.h" 25 | #include "rocksdb/sst_file_reader.h" 26 | 27 | namespace br { 28 | class SstFileReader { 29 | public: 30 | SstFileReader(); 31 | ~SstFileReader() = default; 32 | 33 | SstFileReader(SstFileReader&& rhs) = delete; 34 | SstFileReader& operator=(SstFileReader&& rhs) = delete; 35 | 36 | butil::Status ReadFile(const std::string& filename, std::map& kvs); 37 | 38 | private: 39 | rocksdb::Options options_; 40 | std::unique_ptr sst_reader_; 41 | }; 42 | 43 | using SstFileReaderPtr = std::unique_ptr; 44 | 45 | } // namespace br 46 | 47 | #endif // DINGODB_BR_SST_FILE_READER_H_ -------------------------------------------------------------------------------- /src/br/sst_file_writer.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "br/sst_file_writer.h" 16 | 17 | #include 18 | #include 19 | 20 | #include "fmt/core.h" 21 | #include "rocksdb/advanced_options.h" 22 | #include "rocksdb/filter_policy.h" 23 | #include "rocksdb/write_batch.h" 24 | 25 | namespace br { 26 | 27 | butil::Status SstFileWriter::SaveFile(const std::map& kvs, const std::string& filename) { 28 | auto status = sst_writer_->Open(filename); 29 | if (!status.ok()) { 30 | return butil::Status(status.code(), status.ToString()); 31 | } 32 | 33 | for (const auto& [key, value] : kvs) { 34 | status = sst_writer_->Put(key, value); 35 | if (!status.ok()) { 36 | return butil::Status(status.code(), status.ToString()); 37 | } 38 | } 39 | 40 | status = sst_writer_->Finish(); 41 | if (!status.ok()) { 42 | return butil::Status(status.code(), status.ToString()); 43 | } 44 | 45 | return butil::Status(); 46 | } 47 | 48 | } // namespace br -------------------------------------------------------------------------------- /src/br/sst_file_writer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_BR_SST_FILE_WRITER_H_ 16 | #define DINGODB_BR_SST_FILE_WRITER_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "butil/status.h" 22 | #include "proto/common.pb.h" 23 | #include "rocksdb/convenience.h" 24 | #include "rocksdb/db.h" 25 | #include "rocksdb/options.h" 26 | 27 | namespace br { 28 | class SstFileWriter { 29 | public: 30 | SstFileWriter(const rocksdb::Options& options) 31 | : options_(options), 32 | sst_writer_(std::make_unique(rocksdb::EnvOptions(), options_, nullptr, true)) {} 33 | ~SstFileWriter() = default; 34 | 35 | SstFileWriter(SstFileWriter&& rhs) = delete; 36 | SstFileWriter& operator=(SstFileWriter&& rhs) = delete; 37 | 38 | butil::Status SaveFile(const std::map& kvs, const std::string& filename); 39 | 40 | int64_t GetSize() { return sst_writer_->FileSize(); } 41 | 42 | private: 43 | rocksdb::Options options_; 44 | std::unique_ptr sst_writer_; 45 | }; 46 | using SstFileWriterPtr = std::shared_ptr; 47 | } // namespace br 48 | 49 | #endif // DINGODB_BR_SST_FILE_WRITER_H_ -------------------------------------------------------------------------------- /src/br/tool.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_BR_TOOL_H_ 16 | #define DINGODB_BR_TOOL_H_ 17 | 18 | #include 19 | 20 | #include "br/parameter.h" 21 | #include "br/tool_client.h" 22 | #include "br/tool_diff.h" 23 | #include "br/tool_dump.h" 24 | #include "butil/status.h" 25 | #include "fmt/core.h" 26 | 27 | namespace br { 28 | 29 | class Tool : public std::enable_shared_from_this { 30 | public: 31 | Tool(const ToolParams& params); 32 | ~Tool(); 33 | 34 | Tool(const Tool&) = delete; 35 | const Tool& operator=(const Tool&) = delete; 36 | Tool(Tool&&) = delete; 37 | Tool& operator=(Tool&&) = delete; 38 | 39 | std::shared_ptr GetSelf(); 40 | 41 | butil::Status Init(); 42 | 43 | butil::Status Run(); 44 | 45 | butil::Status Finish(); 46 | 47 | protected: 48 | private: 49 | ToolParams tool_params_; 50 | std::shared_ptr tool_dump_; 51 | std::shared_ptr tool_diff_; 52 | std::shared_ptr tool_client_; 53 | }; 54 | 55 | } // namespace br 56 | 57 | #endif // DINGODB_BR_TOOL_H_ -------------------------------------------------------------------------------- /src/client_v2/dump.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_CLIENT_DUMP_H_ 16 | #define DINGODB_CLIENT_DUMP_H_ 17 | 18 | #include "client_v2/restore.h" 19 | #include "client_v2/store.h" 20 | 21 | namespace client_v2 { 22 | 23 | butil::Status DumpDb(DumpDbOptions const& opt); 24 | butil::Status DumpRegion(CheckRestoreRegionDataOptions const& opt, dingodb::pb::common::Region region, std::string cf, 25 | std::vector& kvs); 26 | 27 | } // namespace client_v2 28 | 29 | #endif // DINGODB_CLIENT_DUMP_H_ -------------------------------------------------------------------------------- /src/common/role.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "common/role.h" 16 | 17 | #include 18 | #include 19 | 20 | #include "gflags/gflags.h" 21 | 22 | DEFINE_string(role, "", "server role [coordinator|store|index]"); 23 | 24 | namespace dingodb { 25 | 26 | static std::string ToUpper(const std::string& str) { 27 | std::string result; 28 | for (char c : str) { 29 | result += std::toupper(c); 30 | } 31 | return result; 32 | } 33 | 34 | pb::common::ClusterRole GetRole() { 35 | static pb::common::ClusterRole role = pb::common::ClusterRole::ILLEGAL; 36 | if (role == pb::common::ClusterRole::ILLEGAL) { 37 | pb::common::ClusterRole_Parse(ToUpper(FLAGS_role), &role); 38 | } 39 | 40 | return role; 41 | } 42 | 43 | std::string& GetRoleName() { return FLAGS_role; } 44 | 45 | void SetRole(std::string role) { FLAGS_role = role; } 46 | 47 | } // namespace dingodb 48 | -------------------------------------------------------------------------------- /src/common/role.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_COMMON_ROLE_H_ 16 | #define DINGODB_COMMON_ROLE_H_ 17 | 18 | #include "proto/common.pb.h" 19 | 20 | namespace dingodb { 21 | 22 | pb::common::ClusterRole GetRole(); 23 | std::string& GetRoleName(); 24 | 25 | // for unit test 26 | void SetRole(std::string role); 27 | 28 | } // namespace dingodb 29 | 30 | #endif // DINGODB_COMMON_ROLE_H_ -------------------------------------------------------------------------------- /src/common/serial_helper.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_COMMON_SERIAL_HELPER_H_ 16 | #define DINGODB_COMMON_SERIAL_HELPER_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "proto/common.pb.h" 22 | 23 | namespace dingodb { 24 | 25 | class SerialHelper { 26 | public: 27 | static bool IsLE() { 28 | uint32_t i = 1; 29 | char* c = (char*)&i; 30 | return *c == 1; 31 | } 32 | 33 | // write value 34 | static void WriteLong(int64_t value, std::string& output); 35 | static int64_t ReadLong(const std::string_view& value); 36 | 37 | // write ~value 38 | static void WriteLongWithNegation(int64_t value, std::string& output); 39 | static int64_t ReadLongWithNegation(const std::string_view& value); 40 | 41 | // highest bit ~ 42 | static void WriteLongComparable(int64_t data, std::string& output); 43 | static int64_t ReadLongComparable(const std::string& value); 44 | static int64_t ReadLongComparable(const std::string_view& value); 45 | }; 46 | 47 | } // namespace dingodb 48 | 49 | #endif // DINGODB_COMMON_SERIAL_HELPER_H_ -------------------------------------------------------------------------------- /src/common/syscheck.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_SYSCHECK_H_ 16 | #define DINGODB_SYSCHECK_H_ 17 | 18 | #include 19 | 20 | namespace dingodb { 21 | 22 | #ifdef __linux__ 23 | int CheckTHPEnabled(std::string &error_msg); 24 | int CheckOvercommit(std::string &error_msg); 25 | #endif 26 | 27 | int DoSystemCheck(); 28 | 29 | } // namespace dingodb 30 | 31 | #endif // DINGODB_SYSCHECK_H_ 32 | -------------------------------------------------------------------------------- /src/common/tracker.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "common/tracker.h" 16 | 17 | #include 18 | 19 | namespace dingodb { 20 | 21 | bvar::LatencyRecorder Tracker::service_queue_latency("dingo_tracker_service_queue"); 22 | bvar::LatencyRecorder Tracker::prepair_commit_latency("dingo_tracker_prepair_commit"); 23 | bvar::LatencyRecorder Tracker::raft_commit_latency("dingo_tracker_raft_commit"); 24 | bvar::LatencyRecorder Tracker::raft_queue_wait_latency("dingo_tracker_raft_queue_wait"); 25 | bvar::LatencyRecorder Tracker::raft_apply_latency("dingo_tracker_raft_apply"); 26 | bvar::LatencyRecorder Tracker::read_store_latency("dingo_tracker_read_store"); 27 | 28 | bvar::LatencyRecorder Tracker::store_write_latency("dingo_tracker_store_write"); 29 | bvar::LatencyRecorder Tracker::vector_index_write_latency("dingo_tracker_vector_index_write"); 30 | bvar::LatencyRecorder Tracker::document_index_write_latency("dingo_tracker_document_index_write"); 31 | 32 | } // namespace dingodb -------------------------------------------------------------------------------- /src/common/uuid.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_COMMON_UUID_H_ 16 | #define DINGODB_COMMON_UUID_H_ 17 | 18 | #include 19 | #include 20 | 21 | namespace dingodb { 22 | 23 | class UUIDGenerator { 24 | public: 25 | UUIDGenerator() = default; 26 | ~UUIDGenerator() = default; 27 | 28 | static std::string GenerateUUID(); 29 | static std::string GenerateUUIDV3(const std::string& seed); 30 | 31 | private: 32 | static std::string GenerateHex(const std::string& seed, uint32_t length); 33 | static std::string GenerateHex(uint32_t length); 34 | static unsigned char GenerateRandomChar(); 35 | }; 36 | 37 | } // namespace dingodb 38 | 39 | #endif // DINGODB_COMMON_UUID_H_ -------------------------------------------------------------------------------- /src/common/version.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_COMMON_VERSION_H_ 16 | #define DINGODB_COMMON_VERSION_H_ 17 | 18 | #include "gflags/gflags.h" 19 | #include "proto/common.pb.h" 20 | 21 | namespace dingodb { 22 | 23 | #ifndef GIT_VERSION 24 | #define GIT_VERSION "unknown" 25 | #endif 26 | 27 | #ifndef MAJOR_VERSION 28 | #define MAJOR_VERSION "v0.9.0" 29 | #endif 30 | 31 | #ifndef MINOR_VERSION 32 | #define MINOR_VERSION "0" 33 | #endif 34 | 35 | #ifndef GIT_TAG_NAME 36 | #define GIT_TAG_NAME "v0.9.0" 37 | #endif 38 | 39 | #ifndef GIT_COMMIT_USER 40 | #define GIT_COMMIT_USER "unknown" 41 | #endif 42 | 43 | #ifndef GIT_COMMIT_MAIL 44 | #define GIT_COMMIT_MAIL "unknown" 45 | #endif 46 | 47 | #ifndef GIT_COMMIT_TIME 48 | #define GIT_COMMIT_TIME "unknown" 49 | #endif 50 | 51 | #ifndef DINGO_BUILD_TYPE 52 | #define DINGO_BUILD_TYPE "unknown" 53 | #endif 54 | 55 | #ifndef DINGO_CONTRIB_BUILD_TYPE 56 | #define DINGO_CONTRIB_BUILD_TYPE "unknown" 57 | #endif 58 | 59 | DECLARE_bool(show_version); 60 | 61 | void DingoShowVerion(); 62 | void DingoLogVerion(); 63 | 64 | pb::common::VersionInfo GetVersionInfo(); 65 | 66 | } // namespace dingodb 67 | 68 | #endif // DINGODB_COMMON_VERSION_H_ 69 | -------------------------------------------------------------------------------- /src/config/config.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_CONFIG_H_ 16 | #define DINGODB_CONFIG_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | namespace dingodb { 24 | 25 | class Config { 26 | public: 27 | Config() = default; 28 | virtual ~Config() = default; 29 | 30 | virtual int Load(const std::string& data) = 0; 31 | virtual int LoadFile(const std::string& filename) = 0; 32 | virtual int ReloadFile(const std::string& filename) = 0; 33 | 34 | virtual bool GetBool(const std::string& key) = 0; 35 | virtual int GetInt(const std::string& key) = 0; 36 | virtual int64_t GetInt64(const std::string& key) = 0; 37 | virtual double GetDouble(const std::string& key) = 0; 38 | virtual std::string GetString(const std::string& key) = 0; 39 | virtual std::string GetStringOrNullIfNotExists(const std::string& key) = 0; 40 | 41 | virtual std::vector GetIntList(const std::string& key) = 0; 42 | virtual std::vector GetStringList(const std::string& key) = 0; 43 | 44 | virtual std::map GetIntMap(const std::string& key) = 0; 45 | virtual std::map GetStringMap(const std::string& key) = 0; 46 | 47 | virtual std::string ToString() = 0; 48 | }; 49 | 50 | using ConfigPtr = std::shared_ptr; 51 | 52 | } // namespace dingodb 53 | 54 | #endif // DINGODB_CONFIG_H_ 55 | -------------------------------------------------------------------------------- /src/config/config_manager.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_CONFIG_MANAGER_H_ 16 | #define DINGODB_CONFIG_MANAGER_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "bthread/types.h" 23 | #include "config/config.h" 24 | 25 | namespace dingodb { 26 | 27 | // Manage all config 28 | class ConfigManager { 29 | public: 30 | static ConfigManager &GetInstance(); 31 | 32 | bool IsExist(const std::string &name); 33 | void Register(const std::string &name, std::shared_ptr config); 34 | std::shared_ptr GetConfig(const std::string &name); 35 | std::shared_ptr GetRoleConfig(); 36 | 37 | ConfigManager(const ConfigManager &) = delete; 38 | const ConfigManager &operator=(const ConfigManager &) = delete; 39 | 40 | private: 41 | ConfigManager(); 42 | ~ConfigManager(); 43 | 44 | bthread_mutex_t mutex_; 45 | std::map > configs_; 46 | }; 47 | 48 | } // namespace dingodb 49 | 50 | #endif // DINGODB_CONFIG_MANAGER_H 51 | -------------------------------------------------------------------------------- /src/diskann/diskann_item_parameter.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "diskann/diskann_item_parameter.h" 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "butil/status.h" 27 | #include "common/constant.h" 28 | #include "common/logging.h" 29 | #include "common/synchronization.h" 30 | #include "diskann/diskann_core.h" 31 | #include "diskann/diskann_utils.h" 32 | #include "fmt/core.h" 33 | #include "proto/common.pb.h" 34 | #include "proto/error.pb.h" 35 | 36 | namespace dingodb {} // namespace dingodb 37 | -------------------------------------------------------------------------------- /src/diskann/diskann_item_runtime.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_DISKANN_DISKANN_ITEM_RUNTIME_H_ // NOLINT 16 | #define DINGODB_DISKANN_DISKANN_ITEM_RUNTIME_H_ 17 | 18 | #include 19 | 20 | #include "common/runnable.h" 21 | #include "config/config.h" 22 | 23 | namespace dingodb { 24 | 25 | class DiskANNItemRuntime { 26 | public: 27 | explicit DiskANNItemRuntime() = delete; 28 | 29 | ~DiskANNItemRuntime() = delete; 30 | 31 | static bool Init(); 32 | static WorkerSetPtr GetImportWorkerSet(); 33 | static WorkerSetPtr GetBuildWorkerSet(); 34 | static WorkerSetPtr GetLoadWorkerSet(); 35 | static WorkerSetPtr GetSearchWorkerSet(); 36 | static WorkerSetPtr GetMiscWorkerSet(); 37 | static uint32_t GetNumBthreads(); 38 | 39 | protected: 40 | private: 41 | static inline WorkerSetPtr import_worker_set; 42 | static inline WorkerSetPtr build_worker_set; 43 | static inline WorkerSetPtr load_worker_set; 44 | static inline WorkerSetPtr search_worker_set; 45 | static inline WorkerSetPtr misc_worker_set; 46 | static inline uint32_t num_bthreads = 0; 47 | }; 48 | 49 | } // namespace dingodb 50 | 51 | #endif // DINGODB_DISKANN_DISKANN_ITEM_RUNTIME_H_ // NOLINT 52 | -------------------------------------------------------------------------------- /src/engine/snapshot.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_ENGINE_SNAPSHOT_H_ 16 | #define DINGODB_ENGINE_SNAPSHOT_H_ 17 | 18 | #include 19 | 20 | namespace dingodb { 21 | 22 | class Snapshot { 23 | public: 24 | Snapshot() = default; 25 | virtual ~Snapshot() = default; 26 | 27 | virtual const void* Inner() = 0; 28 | }; 29 | 30 | using SnapshotPtr = std::shared_ptr; 31 | 32 | } // namespace dingodb 33 | 34 | #endif // DINGODB_ENGINE_SNAPSHOT_H_ -------------------------------------------------------------------------------- /src/event/event.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "event/event.h" 16 | 17 | namespace dingodb { 18 | 19 | void EventListenerCollection::Register(std::shared_ptr listener) { 20 | auto it = listeners_.find(listener->GetType()); 21 | if (it == listeners_.end()) { 22 | EventListenerChain chain; 23 | listeners_.insert(std::make_pair(listener->GetType(), chain)); 24 | } 25 | listeners_[listener->GetType()].push_back(listener); 26 | } 27 | 28 | EventListenerCollection::EventListenerChain EventListenerCollection::Get(EventType type) { 29 | auto it = listeners_.find(type); 30 | if (it == listeners_.end()) { 31 | return {}; 32 | } 33 | 34 | return it->second; 35 | } 36 | 37 | } // namespace dingodb -------------------------------------------------------------------------------- /src/handler/handler.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "handler/handler.h" 16 | 17 | #include "common/logging.h" 18 | 19 | namespace dingodb { 20 | 21 | void HandlerCollection::Register(std::shared_ptr handler) { 22 | if (handlers_.find(handler->GetType()) != handlers_.end()) { 23 | DINGO_LOG(ERROR) << "Handler already exist " << static_cast(handler->GetType()); 24 | return; 25 | } 26 | 27 | handlers_.insert(std::make_pair(handler->GetType(), handler)); 28 | } 29 | 30 | std::shared_ptr HandlerCollection::GetHandler(HandlerType type) { 31 | auto it = handlers_.find(type); 32 | if (it == handlers_.end()) { 33 | return nullptr; 34 | } 35 | return it->second; 36 | } 37 | 38 | std::vector> HandlerCollection::GetHandlers() { 39 | std::vector> handlers; 40 | handlers.reserve(handlers_.size()); 41 | for (auto [_, handler] : handlers_) { 42 | handlers.push_back(handler); 43 | } 44 | 45 | return handlers; 46 | } 47 | 48 | } // namespace dingodb 49 | -------------------------------------------------------------------------------- /src/log/log_storage_manager.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "log/log_storage_manager.h" 16 | 17 | #include 18 | 19 | namespace dingodb { 20 | 21 | void LogStorageManager::AddLogStorage(int64_t region_id, std::shared_ptr log_storage) { 22 | BAIDU_SCOPED_LOCK(mutex_); 23 | 24 | log_storages_.insert(std::make_pair(region_id, log_storage)); 25 | } 26 | 27 | void LogStorageManager::DeleteStorage(int64_t region_id) { 28 | BAIDU_SCOPED_LOCK(mutex_); 29 | 30 | log_storages_.erase(region_id); 31 | } 32 | 33 | std::shared_ptr LogStorageManager::GetRaftLogStorage(int64_t region_id) { 34 | BAIDU_SCOPED_LOCK(mutex_); 35 | 36 | auto it = log_storages_.find(region_id); 37 | if (it == log_storages_.end()) { 38 | return nullptr; 39 | } 40 | 41 | return it->second; 42 | } 43 | 44 | } // namespace dingodb -------------------------------------------------------------------------------- /src/log/log_storage_manager.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_LOG_STORAGE_MANAGER_H_ 16 | #define DINGODB_LOG_STORAGE_MANAGER_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "log/segment_log_storage.h" 23 | 24 | namespace dingodb { 25 | 26 | class LogStorageManager { 27 | public: 28 | LogStorageManager() { bthread_mutex_init(&mutex_, nullptr); } 29 | ~LogStorageManager() { bthread_mutex_destroy(&mutex_); } 30 | 31 | void AddLogStorage(int64_t region_id, std::shared_ptr log_storage); 32 | void DeleteStorage(int64_t region_id); 33 | std::shared_ptr GetRaftLogStorage(int64_t region_id); 34 | 35 | private: 36 | bthread_mutex_t mutex_; 37 | std::map> log_storages_; 38 | }; 39 | 40 | } // namespace dingodb 41 | 42 | #endif // DINGODB_LOG_STORAGE_MANAGER_H_ -------------------------------------------------------------------------------- /src/meta/meta_reader.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_META_META_READER_H_ 16 | #define DINGODB_META_META_READER_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "engine/raw_engine.h" 22 | #include "proto/common.pb.h" 23 | 24 | namespace dingodb { 25 | 26 | class MetaReader { 27 | public: 28 | MetaReader(std::shared_ptr engine) : engine_(engine) {} 29 | ~MetaReader() = default; 30 | 31 | MetaReader(const MetaReader&) = delete; 32 | const MetaReader& operator=(const MetaReader&) = delete; 33 | 34 | std::shared_ptr Get(const std::string& key); 35 | butil::Status Get(const std::string& key, pb::common::KeyValue& kv); 36 | bool Scan(const std::string& prefix, std::vector& kvs); 37 | 38 | // with Snapshot 39 | butil::Status Get(std::shared_ptr snapshot, const std::string& key, pb::common::KeyValue& kv); 40 | std::shared_ptr Get(std::shared_ptr snapshot, const std::string& key); 41 | bool Scan(std::shared_ptr, const std::string& prefix, std::vector& kvs); 42 | 43 | private: 44 | std::shared_ptr engine_; 45 | }; 46 | 47 | using MetaReaderPtr = std::shared_ptr; 48 | 49 | } // namespace dingodb 50 | 51 | #endif // DINGODB_META_META_READER_H_ -------------------------------------------------------------------------------- /src/meta/meta_writer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_META_META_WRITER_H_ 16 | #define DINGODB_META_META_WRITER_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "engine/raw_engine.h" 22 | #include "proto/common.pb.h" 23 | 24 | namespace dingodb { 25 | 26 | class MetaWriter { 27 | public: 28 | MetaWriter(std::shared_ptr engine) : engine_(engine) {} 29 | ~MetaWriter() = default; 30 | 31 | MetaWriter(const MetaWriter &) = delete; 32 | const MetaWriter &operator=(const MetaWriter &) = delete; 33 | 34 | bool Put(std::shared_ptr kv); 35 | bool Put(std::vector kvs); 36 | bool PutAndDelete(std::vector kvs_to_put, std::vector keys_to_delete); 37 | bool Delete(const std::string &key); 38 | bool DeleteRange(const std::string &start_key, const std::string &end_key); 39 | bool DeletePrefix(const std::string &prefix); 40 | 41 | private: 42 | std::shared_ptr engine_; 43 | }; 44 | 45 | using MetaWriterPtr = std::shared_ptr; 46 | 47 | } // namespace dingodb 48 | 49 | #endif // DINGODB_META_META_WRITER_H_ -------------------------------------------------------------------------------- /src/metrics/store_bvar_metrics.cc: -------------------------------------------------------------------------------- 1 | // Licensed under the Apache License, Version 2.0 (the "License"); 2 | // you may not use this file except in compliance with the License. 3 | // You may obtain a copy of the License at 4 | // 5 | // http://www.apache.org/licenses/LICENSE-2.0 6 | // 7 | // Unless required by applicable law or agreed to in writing, software 8 | // distributed under the License is distributed on an "AS IS" BASIS, 9 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | // See the License for the specific language governing permissions and 11 | // limitations under the License. 12 | 13 | #include "metrics/store_bvar_metrics.h" 14 | 15 | namespace dingodb { 16 | 17 | StoreBvarMetrics& StoreBvarMetrics::GetInstance() { 18 | static StoreBvarMetrics store_bvar_metrics; 19 | return store_bvar_metrics; 20 | } 21 | 22 | } // namespace dingodb -------------------------------------------------------------------------------- /src/raft/raft_node_manager.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_RAFT_RAFT_NODE_MANAGER_H_ 16 | #define DINGODB_RAFT_RAFT_NODE_MANAGER_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "raft/raft_node.h" 24 | 25 | namespace dingodb { 26 | 27 | // raft node manager 28 | class RaftNodeManager { 29 | public: 30 | RaftNodeManager(); 31 | ~RaftNodeManager(); 32 | 33 | RaftNodeManager(const RaftNodeManager &) = delete; 34 | const RaftNodeManager &operator=(const RaftNodeManager &) = delete; 35 | 36 | bool IsExist(int64_t node_id); 37 | std::shared_ptr GetNode(int64_t node_id); 38 | std::vector> GetAllNode(); 39 | void AddNode(int64_t node_id, std::shared_ptr node); 40 | void DeleteNode(int64_t node_id); 41 | 42 | private: 43 | bthread_mutex_t mutex_; 44 | 45 | std::map> nodes_; 46 | }; 47 | using RaftNodeManagerPtr = std::shared_ptr; 48 | 49 | } // namespace dingodb 50 | 51 | #endif // DINGODB_RAFT_RAFT_NODE_MANAGER_H_ 52 | -------------------------------------------------------------------------------- /src/report/web.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_INTEGRATION_TEST_REPORT_WEB_ 16 | #define DINGODB_INTEGRATION_TEST_REPORT_WEB_ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "gtest/gtest.h" 24 | #include "proto/common.pb.h" 25 | 26 | namespace dingodb::report::web { 27 | 28 | class Web { 29 | public: 30 | Web() = default; 31 | ~Web() = default; 32 | 33 | static void GenIntegrationTestReport(const testing::UnitTest* unit_test, const pb::common::VersionInfo& version_info, 34 | const std::string& allure_url, const std::string& directory_path); 35 | 36 | static void GenUnitTestReport(const testing::UnitTest* unit_test, const pb::common::VersionInfo& version_info, 37 | const std::string& allure_url, const std::string& coverage_url, 38 | const std::string& directory_path); 39 | 40 | private: 41 | static std::string GenVersionContent(const pb::common::VersionInfo& version_info); 42 | static std::string GenTestResultContent(const testing::UnitTest* unit_test); 43 | static std::string GenAllureLinkContent(const std::string& allure_url); 44 | static std::string GenCoverageLinkContent(const std::string& url); 45 | }; 46 | 47 | } // namespace dingodb::report::web 48 | 49 | #endif // DINGODB_INTEGRATION_TEST_REPORT_WEB_ -------------------------------------------------------------------------------- /src/scan/scan_filter.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "scan/scan_filter.h" 16 | 17 | namespace dingodb { 18 | 19 | ScanFilter::ScanFilter(bool key_only, size_t max_fetch_cnt, int64_t max_bytes_rpc) 20 | : key_only_(key_only), 21 | max_fetch_cnt_(max_fetch_cnt), 22 | max_bytes_rpc_(max_bytes_rpc), 23 | cur_fetch_cnt_(0), 24 | cur_bytes_rpc_(0) {} 25 | 26 | bool ScanFilter::UptoLimit(const pb::common::KeyValue& kv) { 27 | cur_fetch_cnt_++; 28 | if (cur_fetch_cnt_ >= max_fetch_cnt_) { 29 | return true; 30 | } 31 | 32 | cur_bytes_rpc_ += kv.key().size(); 33 | if (!key_only_) { 34 | cur_bytes_rpc_ += kv.value().size(); 35 | } 36 | 37 | if (cur_bytes_rpc_ >= max_bytes_rpc_) { 38 | return true; 39 | } 40 | 41 | return false; 42 | } 43 | 44 | void ScanFilter::Reset() { 45 | cur_fetch_cnt_ = 0; 46 | cur_bytes_rpc_ = 0; 47 | } 48 | 49 | void ScanFilter::Reset(bool key_only, size_t max_fetch_cnt, int64_t max_bytes_rpc) { 50 | key_only_ = key_only; 51 | max_fetch_cnt_ = max_fetch_cnt; 52 | max_bytes_rpc_ = max_bytes_rpc; 53 | cur_fetch_cnt_ = 0; 54 | cur_bytes_rpc_ = 0; 55 | } 56 | } // namespace dingodb 57 | -------------------------------------------------------------------------------- /src/scan/scan_filter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_ENGINE_SCAN_FILTER_H_ // NOLINT 16 | #define DINGODB_ENGINE_SCAN_FILTER_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "proto/common.pb.h" 22 | 23 | namespace dingodb { 24 | 25 | class ScanFilter { 26 | public: 27 | explicit ScanFilter(bool key_only, size_t max_fetch_cnt, int64_t max_bytes_rpc); 28 | ~ScanFilter() = default; 29 | ScanFilter(const ScanFilter& rhs) = default; 30 | ScanFilter& operator=(const ScanFilter& rhs) = default; 31 | ScanFilter(ScanFilter&& rhs) = default; 32 | ScanFilter& operator=(ScanFilter&& rhs) = default; 33 | 34 | bool UptoLimit(const pb::common::KeyValue& kv); 35 | 36 | void Reset(); 37 | 38 | void Reset(bool key_only, size_t max_fetch_cnt, int64_t max_bytes_rpc); 39 | 40 | size_t GetCurFetchCnt() const { return cur_fetch_cnt_; } 41 | size_t GetCurBytesRpc() const { return cur_bytes_rpc_; } 42 | 43 | private: 44 | bool key_only_; 45 | size_t max_fetch_cnt_; 46 | int64_t max_bytes_rpc_; 47 | size_t cur_fetch_cnt_; 48 | int64_t cur_bytes_rpc_; 49 | }; 50 | 51 | } // namespace dingodb 52 | 53 | #endif // DINGODB_ENGINE_SCAN_FILTER_H_ // NOLINT 54 | -------------------------------------------------------------------------------- /src/server/job_service.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_TASK_LIST_SERVICE_H_ 16 | #define DINGODB_TASK_LIST_SERVICE_H_ 17 | 18 | #include 19 | 20 | #include "coordinator/coordinator_control.h" 21 | #include "proto/cluster_stat.pb.h" 22 | 23 | namespace dingodb { 24 | 25 | class JobImpl : public pb::cluster::job { 26 | public: 27 | JobImpl() = default; 28 | void default_method(::google::protobuf::RpcController* controller, const pb::cluster::JobListRequest* request, 29 | pb::cluster::JobListResponse* response, ::google::protobuf::Closure* done) override; 30 | void SetControl(std::shared_ptr controller) { controller_ = controller; } 31 | 32 | private: 33 | std::shared_ptr controller_; 34 | }; 35 | 36 | } // namespace dingodb 37 | 38 | #endif // DINGODB_TASK_LIST_SERVICE_H_ -------------------------------------------------------------------------------- /src/server/push_service.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_PUSH_SERVICE_H_ 16 | #define DINGODB_PUSH_SERVICE_H_ 17 | 18 | #include "proto/push.pb.h" 19 | 20 | namespace dingodb { 21 | 22 | class PushServiceImpl : public pb::push::PushService { 23 | public: 24 | PushServiceImpl(); 25 | void PushHeartbeat(google::protobuf::RpcController* controller, 26 | const dingodb::pb::push::PushHeartbeatRequest* request, 27 | dingodb::pb::push::PushHeartbeatResponse* /*response*/, google::protobuf::Closure* done) override; 28 | void PushStoreOperation(google::protobuf::RpcController* controller, 29 | const dingodb::pb::push::PushStoreOperationRequest* request, 30 | dingodb::pb::push::PushStoreOperationResponse* /*response*/, 31 | google::protobuf::Closure* done) override; 32 | }; 33 | 34 | } // namespace dingodb 35 | 36 | #endif // DINGODB_PUSH_SERVICE_H_ 37 | -------------------------------------------------------------------------------- /src/server/region_service.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_REGION_SERVICE_H_ 16 | #define DINGODB_REGION_SERVICE_H_ 17 | 18 | #include 19 | 20 | #include "brpc/builtin/tabbed.h" 21 | #include "coordinator/coordinator_control.h" 22 | #include "proto/cluster_stat.pb.h" 23 | 24 | namespace dingodb { 25 | 26 | class RegionImpl : public pb::cluster::region, public brpc::Tabbed { 27 | public: 28 | RegionImpl() = default; 29 | void default_method(::google::protobuf::RpcController* controller, const pb::cluster::RegionRequest* request, 30 | pb::cluster::RegionResponse* response, ::google::protobuf::Closure* done) override; 31 | void GetTabInfo(brpc::TabInfoList*) const override; 32 | void SetControl(std::shared_ptr controller) { coordinator_controller_ = controller; } 33 | 34 | void PrintRegions(std::ostream& os, bool use_html); 35 | 36 | private: 37 | std::shared_ptr coordinator_controller_; 38 | }; 39 | 40 | } // namespace dingodb 41 | 42 | #endif // DINGODB_REGION_SERVICE_H_ -------------------------------------------------------------------------------- /src/server/store_metrics_service.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_STORE_METRICS_SERVICE_H_ 16 | #define DINGODB_STORE_METRICS_SERVICE_H_ 17 | 18 | #include 19 | 20 | #include "coordinator/coordinator_control.h" 21 | #include "proto/cluster_stat.pb.h" 22 | 23 | namespace dingodb { 24 | 25 | class StoreMetricsImpl : public pb::cluster::store_metrics { 26 | public: 27 | StoreMetricsImpl() = default; 28 | void default_method(::google::protobuf::RpcController* controller, const pb::cluster::StoreMetricsRequest* request, 29 | pb::cluster::StoreMetricsResponse* response, ::google::protobuf::Closure* done) override; 30 | void SetControl(std::shared_ptr controller) { controller_ = controller; } 31 | 32 | private: 33 | std::shared_ptr controller_; 34 | }; 35 | 36 | } // namespace dingodb 37 | 38 | #endif // DINGODB_STORE_METRICS_SERVICE_H_ -------------------------------------------------------------------------------- /src/server/store_operation_service.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_STORE_OPERATION_SERVICE_H_ 16 | #define DINGODB_STORE_OPERATION_SERVICE_H_ 17 | 18 | #include 19 | 20 | #include "coordinator/coordinator_control.h" 21 | #include "proto/cluster_stat.pb.h" 22 | 23 | namespace dingodb { 24 | 25 | class StoreOperationImpl : public pb::cluster::store_operation { 26 | public: 27 | StoreOperationImpl() = default; 28 | void default_method(::google::protobuf::RpcController* controller, const pb::cluster::StoreOperationRequest* request, 29 | pb::cluster::StoreOperationResponse* response, ::google::protobuf::Closure* done) override; 30 | void SetControl(std::shared_ptr controller) { controller_ = controller; } 31 | 32 | private: 33 | std::shared_ptr controller_; 34 | }; 35 | 36 | } // namespace dingodb 37 | 38 | #endif // DINGODB_STORE_OPERATION_SERVICE_H_ -------------------------------------------------------------------------------- /src/server/table_service.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_TABLE_SERVICE_H_ 16 | #define DINGODB_TABLE_SERVICE_H_ 17 | 18 | #include 19 | 20 | #include "brpc/builtin/tabbed.h" 21 | #include "coordinator/coordinator_control.h" 22 | #include "proto/cluster_stat.pb.h" 23 | 24 | namespace dingodb { 25 | 26 | class TableImpl : public pb::cluster::table, public brpc::Tabbed { 27 | public: 28 | TableImpl() = default; 29 | void default_method(::google::protobuf::RpcController* controller, const pb::cluster::TableRequest* request, 30 | pb::cluster::TableResponse* response, ::google::protobuf::Closure* done) override; 31 | void GetTabInfo(brpc::TabInfoList*) const override; 32 | void SetControl(std::shared_ptr controller) { coordinator_controller_ = controller; } 33 | 34 | void PrintSchemaTables(std::ostream& os, bool use_html); 35 | 36 | private: 37 | std::shared_ptr coordinator_controller_; 38 | }; 39 | 40 | } // namespace dingodb 41 | 42 | #endif // DINGODB_TABLE_SERVICE_H_ -------------------------------------------------------------------------------- /src/server/util_service.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_UTIL_SERVICE_H_ 16 | #define DINGODB_UTIL_SERVICE_H_ 17 | 18 | #include "engine/storage.h" 19 | #include "proto/util.pb.h" 20 | 21 | namespace dingodb { 22 | 23 | class UtilServiceImpl : public pb::util::UtilService { 24 | public: 25 | UtilServiceImpl() = default; 26 | 27 | void VectorCalcDistance(google::protobuf::RpcController* controller, 28 | const ::dingodb::pb::index::VectorCalcDistanceRequest* request, 29 | ::dingodb::pb::index::VectorCalcDistanceResponse* response, 30 | ::google::protobuf::Closure* done) override; 31 | 32 | void SetStorage(StoragePtr storage) { storage_ = storage; } 33 | void SetReadWorkSet(WorkerSetPtr worker_set) { read_worker_set_ = worker_set; } 34 | 35 | private: 36 | std::shared_ptr storage_; 37 | // Run service request. 38 | WorkerSetPtr read_worker_set_; 39 | }; 40 | 41 | void DoVectorCalcDistance(StoragePtr storage, google::protobuf::RpcController* controller, 42 | const pb::index::VectorCalcDistanceRequest* request, 43 | pb::index::VectorCalcDistanceResponse* response, google::protobuf::Closure* done); 44 | 45 | } // namespace dingodb 46 | 47 | #endif // DINGODB_INDEx_SERVICE_H_ 48 | -------------------------------------------------------------------------------- /src/simd/distances_avx.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Copyright (C) 2019-2023 Zilliz. All rights reserved. 16 | 17 | #ifndef DINGODB_SIMD_DISTANCES_AVX_H_ 18 | #define DINGODB_SIMD_DISTANCES_AVX_H_ 19 | 20 | #include 21 | #include 22 | 23 | namespace dingodb { 24 | 25 | /// Squared L2 distance between two vectors 26 | float fvec_L2sqr_avx(const float* x, const float* y, size_t d); 27 | 28 | /// inner product 29 | float fvec_inner_product_avx(const float* x, const float* y, size_t d); 30 | 31 | /// L1 distance 32 | float fvec_L1_avx(const float* x, const float* y, size_t d); 33 | 34 | /// infinity distance 35 | float fvec_Linf_avx(const float* x, const float* y, size_t d); 36 | 37 | } // namespace dingodb 38 | 39 | #endif // DINGODB_SIMD_DISTANCES_AVX_H_ //NOLINT 40 | -------------------------------------------------------------------------------- /src/simd/distances_avx512.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Copyright (C) 2019-2023 Zilliz. All rights reserved. 16 | 17 | #ifndef DINGODB_SIMD_DISTANCES_AVX512_H_ 18 | #define DINGODB_SIMD_DISTANCES_AVX512_H_ 19 | 20 | #include 21 | #include 22 | 23 | namespace dingodb { 24 | 25 | float fvec_L2sqr_avx512(const float* x, const float* y, size_t d); 26 | 27 | /// inner product 28 | float fvec_inner_product_avx512(const float* x, const float* y, size_t d); 29 | 30 | /// L1 distance 31 | float fvec_L1_avx512(const float* x, const float* y, size_t d); 32 | 33 | /// infinity distance 34 | float fvec_Linf_avx512(const float* x, const float* y, size_t d); 35 | 36 | } // namespace dingodb 37 | 38 | #endif // DINGODB_SIMD_DISTANCES_AVX512_H_ //NOLINT 39 | -------------------------------------------------------------------------------- /src/simd/distances_ref.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Copyright (C) 2019-2023 Zilliz. All rights reserved. 16 | 17 | #ifndef DINGODB_SIMD_DISTANCES_REF_H_ 18 | #define DINGODB_SIMD_DISTANCES_REF_H_ 19 | 20 | #include 21 | 22 | namespace dingodb { 23 | 24 | /// Squared L2 distance between two vectors 25 | float fvec_L2sqr_ref(const float* x, const float* y, size_t d); 26 | 27 | /// inner product 28 | float fvec_inner_product_ref(const float* x, const float* y, size_t d); 29 | 30 | /// L1 distance 31 | float fvec_L1_ref(const float* x, const float* y, size_t d); 32 | 33 | /// infinity distance 34 | float fvec_Linf_ref(const float* x, const float* y, size_t d); 35 | 36 | /// squared norm of a vector 37 | float fvec_norm_L2sqr_ref(const float* x, size_t d); 38 | 39 | /// compute ny square L2 distance between x and a set of contiguous y vectors 40 | void fvec_L2sqr_ny_ref(float* dis, const float* x, const float* y, size_t d, size_t ny); 41 | 42 | /// compute the inner product between nx vectors x and one y 43 | void fvec_inner_products_ny_ref(float* ip, const float* x, const float* y, size_t d, size_t ny); 44 | 45 | void fvec_madd_ref(size_t n, const float* a, float bf, const float* b, float* c); 46 | 47 | int fvec_madd_and_argmin_ref(size_t n, const float* a, float bf, const float* b, float* c); 48 | 49 | } // namespace dingodb 50 | 51 | #endif // DINGODB_SIMD_DISTANCES_REF_H_ //NOLINT 52 | -------------------------------------------------------------------------------- /src/simd/distances_sse.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Copyright (C) 2019-2023 Zilliz. All rights reserved. 16 | 17 | #ifndef DINGODB_SIMD_DISTANCES_SSE_H_ 18 | #define DINGODB_SIMD_DISTANCES_SSE_H_ 19 | 20 | #include 21 | namespace dingodb { 22 | 23 | /// Squared L2 distance between two vectors 24 | float fvec_L2sqr_sse(const float* x, const float* y, size_t d); 25 | 26 | /// inner product 27 | float fvec_inner_product_sse(const float* x, const float* y, size_t d); 28 | 29 | /// L1 distance 30 | float fvec_L1_sse(const float* x, const float* y, size_t d); 31 | 32 | /// infinity distance 33 | float fvec_Linf_sse(const float* x, const float* y, size_t d); 34 | 35 | float fvec_norm_L2sqr_sse(const float* x, size_t d); 36 | 37 | void fvec_L2sqr_ny_sse(float* dis, const float* x, const float* y, size_t d, size_t ny); 38 | 39 | void fvec_inner_products_ny_sse(float* ip, const float* x, const float* y, size_t d, size_t ny); 40 | 41 | void fvec_madd_sse(size_t n, const float* a, float bf, const float* b, float* c); 42 | 43 | int fvec_madd_and_argmin_sse(size_t n, const float* a, float bf, const float* b, float* c); 44 | 45 | } // namespace dingodb 46 | 47 | #endif /* DINGODB_SIMD_DISTANCES_SSE_H_ */ 48 | -------------------------------------------------------------------------------- /src/simd/hook.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Copyright (C) 2019-2023 Zilliz. All rights reserved. 16 | 17 | #ifndef DINGODB_SIMD_HOOK_H_ 18 | #define DINGODB_SIMD_HOOK_H_ 19 | 20 | #include 21 | namespace dingodb { 22 | 23 | extern float (*fvec_inner_product)(const float*, const float*, size_t); 24 | extern float (*fvec_L2sqr)(const float*, const float*, size_t); 25 | extern float (*fvec_L1)(const float*, const float*, size_t); 26 | extern float (*fvec_Linf)(const float*, const float*, size_t); 27 | extern float (*fvec_norm_L2sqr)(const float*, size_t); 28 | extern void (*fvec_L2sqr_ny)(float*, const float*, const float*, size_t, size_t); 29 | extern void (*fvec_inner_products_ny)(float*, const float*, const float*, size_t, size_t); 30 | extern void (*fvec_madd)(size_t, const float*, float, const float*, float*); 31 | extern int (*fvec_madd_and_argmin)(size_t, const float*, float, const float*, float*); 32 | 33 | #if defined(__x86_64__) 34 | extern bool use_avx512; 35 | extern bool use_avx2; 36 | extern bool use_sse4_2; 37 | #endif 38 | 39 | #if defined(__x86_64__) 40 | bool cpu_support_avx512(); 41 | bool cpu_support_avx2(); 42 | bool cpu_support_sse4_2(); 43 | #endif 44 | 45 | void fvec_hook(std::string& simd_type); 46 | 47 | void fvec_hook_info(std::string& simd_type); 48 | 49 | } // namespace dingodb 50 | 51 | #endif // DINGODB_SIMD_HOOK_H_ // NOLINT 52 | -------------------------------------------------------------------------------- /src/store/store_controller.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | namespace dingodb {} // namespace dingodb 16 | -------------------------------------------------------------------------------- /src/store/store_controller.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef DINGODB_STORE_STORE_CONTROL_H_ 16 | #define DINGODB_STORE_STORE_CONTROL_H_ 17 | 18 | namespace dingodb { 19 | 20 | class StoreController { 21 | public: 22 | StoreController() = default; 23 | ~StoreController() = default; 24 | 25 | StoreController(const StoreController &) = delete; 26 | const StoreController &operator=(const StoreController &) = delete; 27 | 28 | static bool Init() { return true; } 29 | void Destroy() {} 30 | }; 31 | 32 | } // namespace dingodb 33 | 34 | #endif // DINGODB_STORE_STORE_CONTROL_H_ -------------------------------------------------------------------------------- /test/unit_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | enable_testing() 2 | 3 | add_subdirectory(common) 4 | add_subdirectory(coprocessor) 5 | add_subdirectory(engine) 6 | add_subdirectory(mvcc) 7 | add_subdirectory(vector) 8 | add_subdirectory(misc) 9 | add_subdirectory(document) 10 | add_subdirectory(txn) 11 | add_subdirectory(br) 12 | 13 | set(UNIT_TEST_BIN "dingodb_unit_test") 14 | 15 | add_executable(${UNIT_TEST_BIN} main.cc) 16 | 17 | add_dependencies(${UNIT_TEST_BIN} ${DEPEND_LIBS}) 18 | 19 | set(UNIT_TEST_LIBS 20 | $ 21 | $ 22 | ${DYNAMIC_LIB} 23 | ${VECTOR_LIB} 24 | $ 25 | $ 26 | $ 27 | $ 28 | $ 29 | $ 30 | $ 31 | $ 32 | $) 33 | 34 | set(UNIT_TEST_LIBS ${UNIT_TEST_LIBS} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} "-Xlinker \"-(\"" ${BLAS_LIBRARIES} 35 | "-Xlinker \"-)\"") 36 | 37 | target_link_libraries(${UNIT_TEST_BIN} ${UNIT_TEST_LIBS}) 38 | -------------------------------------------------------------------------------- /test/unit_test/br/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) 2 | 3 | file(GLOB UNIT_TEST_BR_SRCS "./*.cc") 4 | 5 | add_library(UNIT_TEST_BR_OBJS OBJECT ${UNIT_TEST_BR_SRCS}) 6 | 7 | add_dependencies(UNIT_TEST_BR_OBJS ${DEPEND_LIBS}) 8 | -------------------------------------------------------------------------------- /test/unit_test/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) 2 | 3 | file(GLOB UNIT_TEST_COMMON_SRCS "./*.cc") 4 | 5 | add_library(UNIT_TEST_COMMON_OBJS OBJECT ${UNIT_TEST_COMMON_SRCS}) 6 | 7 | add_dependencies(UNIT_TEST_COMMON_OBJS ${DEPEND_LIBS}) -------------------------------------------------------------------------------- /test/unit_test/common/test_log.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "common/logging.h" 23 | 24 | class DingoLoggerTest : public testing::Test { 25 | protected: 26 | void SetUp() override {} 27 | void TearDown() override {} 28 | }; 29 | 30 | // TEST(DingoLoggerTest, DingoLOGTest) { 31 | // google::InitGoogleLogging("DingoLoggerTest1"); 32 | // EXPECT_EQ(FLAGS_v, 0); 33 | // int debug_level = 100; 34 | // FLAGS_v = debug_level; 35 | // DINGO_LOG(INFO) << "This is an info log message."; 36 | // DINGO_LOG(DEBUG) << "This is an debug log from dingodb."; 37 | // VLOG(1) << "This is a log"; 38 | // EXPECT_EQ(FLAGS_v, debug_level); 39 | // } 40 | -------------------------------------------------------------------------------- /test/unit_test/common/test_uuid.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "common/helper.h" 24 | #include "common/uuid.h" 25 | #include "fmt/core.h" 26 | 27 | class UUIDGeneratorTest : public testing::Test { 28 | protected: 29 | void SetUp() override {} 30 | void TearDown() override {} 31 | }; 32 | 33 | TEST_F(UUIDGeneratorTest, GenerateUUID) { 34 | // uuid format: xxxx-xx-xx-xx-xxxxxx 35 | std::string uuid = dingodb::UUIDGenerator::GenerateUUID(); 36 | ASSERT_EQ(36, uuid.size()); 37 | 38 | // validate format 39 | std::vector parts; 40 | dingodb::Helper::SplitString(uuid, '-', parts); 41 | ASSERT_EQ(5, parts.size()); 42 | ASSERT_EQ(8, parts[0].size()); 43 | ASSERT_EQ(4, parts[1].size()); 44 | ASSERT_EQ(4, parts[2].size()); 45 | ASSERT_EQ(4, parts[3].size()); 46 | ASSERT_EQ(12, parts[4].size()); 47 | } 48 | 49 | TEST_F(UUIDGeneratorTest, GenerateUUIDV3) { 50 | // uuid format: xxxx-xx-xx-xx-xxxxxx 51 | // specified seed 52 | std::string uuid = dingodb::UUIDGenerator::GenerateUUIDV3("hell world"); 53 | ASSERT_EQ("656c6c20-656c-656c-656c-656c6c20776f", uuid); 54 | } -------------------------------------------------------------------------------- /test/unit_test/common/test_write_data.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include 18 | 19 | #include "engine/write_data.h" 20 | #include "fmt/core.h" 21 | 22 | class WriteDataBuilderTest : public testing::Test { 23 | protected: 24 | void SetUp() override {} 25 | void TearDown() override {} 26 | }; 27 | 28 | TEST_F(WriteDataBuilderTest, BuildWriteData) { 29 | std::vector kvs; 30 | for (int i = 0; i < 1; ++i) { 31 | dingodb::pb::common::KeyValue kv; 32 | kv.set_key(fmt::format("key000000-{}", i)); 33 | kv.set_value("value00000000-{}", i); 34 | kvs.push_back(kv); 35 | } 36 | 37 | auto writedata = dingodb::WriteDataBuilder::BuildWrite("default", kvs, 100); 38 | for (auto& datum : writedata->Datums()) { 39 | auto* request = datum->TransformToRaft(); 40 | delete request; 41 | } 42 | 43 | EXPECT_EQ(true, true); 44 | } -------------------------------------------------------------------------------- /test/unit_test/coprocessor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) 2 | 3 | file(GLOB UNIT_TEST_COPROCESSOR_SRCS "./*.cc") 4 | 5 | add_library(UNIT_TEST_COPROCESSOR_OBJS OBJECT ${UNIT_TEST_COPROCESSOR_SRCS}) 6 | 7 | add_dependencies(UNIT_TEST_COPROCESSOR_OBJS ${DEPEND_LIBS}) -------------------------------------------------------------------------------- /test/unit_test/document/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) 2 | 3 | file(GLOB UNIT_TEST_DOCUMENT_SRCS "./*.cc") 4 | 5 | add_library(UNIT_TEST_DOCUMENT_OBJS OBJECT ${UNIT_TEST_DOCUMENT_SRCS}) 6 | 7 | add_dependencies(UNIT_TEST_DOCUMENT_OBJS ${DEPEND_LIBS}) -------------------------------------------------------------------------------- /test/unit_test/engine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) 2 | 3 | file(GLOB UNIT_TEST_ENGINE_SRCS "./*.cc") 4 | 5 | add_library(UNIT_TEST_ENGINE_OBJS OBJECT ${UNIT_TEST_ENGINE_SRCS}) 6 | 7 | add_dependencies(UNIT_TEST_ENGINE_OBJS ${DEPEND_LIBS}) -------------------------------------------------------------------------------- /test/unit_test/misc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) 2 | 3 | file(GLOB UNIT_TEST_MISC_SRCS "./*.cc") 4 | 5 | add_library(UNIT_TEST_MISC_OBJS OBJECT ${UNIT_TEST_MISC_SRCS}) 6 | 7 | add_dependencies(UNIT_TEST_MISC_OBJS ${DEPEND_LIBS}) -------------------------------------------------------------------------------- /test/unit_test/misc/test_region_controller.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | #include "store/region_controller.h" 21 | 22 | class RegionControlExecutorTest : public testing::Test { 23 | protected: 24 | void SetUp() override {} 25 | void TearDown() override {} 26 | }; 27 | 28 | class TestTask : public dingodb::TaskRunnable { 29 | public: 30 | TestTask() = default; 31 | ~TestTask() override = default; 32 | 33 | std::string Type() override { return ""; } 34 | void Run() override { 35 | bthread_usleep(1 * 1000 * 1000); 36 | LOG(INFO) << "TestTask run..."; 37 | } 38 | }; 39 | 40 | TEST_F(RegionControlExecutorTest, Stop) { 41 | auto region_executor = std::make_shared(1000); 42 | 43 | region_executor->Init(); 44 | 45 | LOG(INFO) << "here 0001"; 46 | 47 | region_executor->Execute(std::make_shared()); 48 | 49 | LOG(INFO) << "here 0002"; 50 | 51 | region_executor->Execute(std::make_shared()); 52 | LOG(INFO) << "here 0003"; 53 | 54 | region_executor->Stop(); 55 | 56 | LOG(INFO) << "here 0004"; 57 | } -------------------------------------------------------------------------------- /test/unit_test/misc/test_store_meta_manager.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 dingodb.com, Inc. All Rights Reserved 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | #include "meta/store_meta_manager.h" 21 | 22 | class StoreRegionMetaTest : public testing::Test { 23 | protected: 24 | void SetUp() override {} 25 | void TearDown() override {} 26 | }; 27 | 28 | TEST_F(StoreRegionMetaTest, ParseRegionId) { 29 | dingodb::StoreRegionMeta store_region_meta(nullptr, nullptr); 30 | 31 | int64_t region_id = store_region_meta.ParseRegionId("META_REGION_11111"); 32 | 33 | EXPECT_EQ(11111, region_id); 34 | } 35 | 36 | TEST_F(StoreRegionMetaTest, AddRegion) { 37 | auto store_region_mata = std::make_shared(nullptr, nullptr); 38 | dingodb::pb::common::RegionDefinition definition; 39 | definition.set_id(1001); 40 | store_region_mata->AddRegion(dingodb::store::Region::New(definition)); 41 | auto region = store_region_mata->GetRegion(1001); 42 | EXPECT_NE(nullptr, region); 43 | EXPECT_EQ(1001, region->Id()); 44 | } -------------------------------------------------------------------------------- /test/unit_test/mvcc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) 2 | 3 | file(GLOB UNIT_TEST_MVCC_SRCS "./*.cc") 4 | 5 | add_library(UNIT_TEST_MVCC_OBJS OBJECT ${UNIT_TEST_MVCC_SRCS}) 6 | 7 | add_dependencies(UNIT_TEST_MVCC_OBJS ${DEPEND_LIBS}) -------------------------------------------------------------------------------- /test/unit_test/txn/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) 2 | 3 | file(GLOB UNIT_TEST_TXN_SRCS "./*.cc") 4 | 5 | add_library(UNIT_TEST_TXN_OBJS OBJECT ${UNIT_TEST_TXN_SRCS}) 6 | 7 | add_dependencies(UNIT_TEST_TXN_OBJS ${DEPEND_LIBS}) -------------------------------------------------------------------------------- /test/unit_test/vector/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) 2 | 3 | file(GLOB UNIT_TEST_VECTOR_SRCS "./*.cc") 4 | 5 | file(GLOB_RECURSE UNIT_TEST_DISKANN_SRCS "./*diskann*.cc") 6 | 7 | if(NOT WITH_DISKANN) 8 | list(REMOVE_ITEM UNIT_TEST_VECTOR_SRCS ${UNIT_TEST_DISKANN_SRCS}) 9 | endif() 10 | 11 | add_library(UNIT_TEST_VECTOR_OBJS OBJECT ${UNIT_TEST_VECTOR_SRCS}) 12 | 13 | add_dependencies(UNIT_TEST_VECTOR_OBJS ${DEPEND_LIBS}) 14 | --------------------------------------------------------------------------------