Skip to content

Commit

Permalink
Fix start milvus failed on macos (milvus-io#19394)
Browse files Browse the repository at this point in the history
Signed-off-by: xige-16 <[email protected]>

Signed-off-by: xige-16 <[email protected]>
  • Loading branch information
xige-16 authored Sep 23, 2022
1 parent 6d6e14e commit d4bc004
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 45 deletions.
12 changes: 6 additions & 6 deletions internal/core/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ include_directories(${MILVUS_ENGINE_SRC})
include_directories(${MILVUS_THIRDPARTY_SRC})

set(FOUND_OPENBLAS "unknown")
add_subdirectory( pb )
add_subdirectory( exceptions )
add_subdirectory( utils )
add_subdirectory( log )
add_subdirectory( pb )
add_subdirectory( segcore )
add_subdirectory( query )
add_subdirectory( common )
add_subdirectory( indexbuilder )
add_subdirectory( config )
add_subdirectory( index )
add_subdirectory( common )
add_subdirectory( storage )
add_subdirectory( index )
add_subdirectory( query )
add_subdirectory( segcore )
add_subdirectory( indexbuilder )
2 changes: 2 additions & 0 deletions internal/core/src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ add_library(milvus_common SHARED ${COMMON_SRC})
if ( MSYS )
target_link_libraries(milvus_common
milvus_config
milvus_utils
milvus_log
yaml-cpp
boost_bitset_ext
Expand All @@ -32,6 +33,7 @@ if ( MSYS )
else()
target_link_libraries(milvus_common
milvus_config
milvus_utils
milvus_log
yaml-cpp
boost_bitset_ext
Expand Down
3 changes: 1 addition & 2 deletions internal/core/src/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ set(CONFIG_SRC
add_library(milvus_config STATIC ${CONFIG_SRC})

target_link_libraries(milvus_config
milvus_exceptions
knowhere
milvus_proto
milvus_utils
)
2 changes: 1 addition & 1 deletion internal/core/src/exceptions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ set(exceptions_files

add_library(milvus_exceptions STATIC ${exceptions_files})

target_link_libraries(milvus_exceptions PRIVATE milvus_proto)
target_link_libraries(milvus_exceptions milvus_proto)
1 change: 0 additions & 1 deletion internal/core/src/index/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "index/Utils.h"
#include "index/Meta.h"
#include "pb/index_cgo_msg.pb.h"
#include <google/protobuf/text_format.h>
#include "exceptions/EasyAssert.h"

Expand Down
1 change: 0 additions & 1 deletion internal/core/src/index/VectorMemIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "common/BitsetView.h"
#include "knowhere/index/vector_index/ConfAdapterMgr.h"
#include "knowhere/index/vector_index/adapter/VectorAdapter.h"
#include "pb/index_cgo_msg.pb.h"

namespace milvus::index {

Expand Down
3 changes: 3 additions & 0 deletions internal/core/src/indexbuilder/ScalarIndexCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "index/IndexInfo.h"
#include "index/Meta.h"
#include "index/Utils.h"
#include "pb/index_cgo_msg.pb.h"

#include <string>

Expand All @@ -22,6 +23,8 @@ namespace milvus::indexbuilder {
ScalarIndexCreator::ScalarIndexCreator(DataType dtype, const char* type_params, const char* index_params)
: dtype_(dtype) {
// TODO: move parse-related logic to a common interface.
proto::indexcgo::TypeParams type_params_;
proto::indexcgo::IndexParams index_params_;
milvus::index::ParseFromString(type_params_, std::string(type_params));
milvus::index::ParseFromString(index_params_, std::string(index_params));

Expand Down
3 changes: 0 additions & 3 deletions internal/core/src/indexbuilder/ScalarIndexCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#pragma once

#include "indexbuilder/IndexCreatorBase.h"
#include "pb/index_cgo_msg.pb.h"
#include <string>
#include <memory>
#include <common/CDataType.h>
Expand Down Expand Up @@ -40,8 +39,6 @@ class ScalarIndexCreator : public IndexCreatorBase {

private:
index::IndexBasePtr index_ = nullptr;
proto::indexcgo::TypeParams type_params_;
proto::indexcgo::IndexParams index_params_;
Config config_;
DataType dtype_;
};
Expand Down
3 changes: 3 additions & 0 deletions internal/core/src/indexbuilder/VecIndexCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "indexbuilder/VecIndexCreator.h"
#include "index/Utils.h"
#include "index/IndexFactory.h"
#include "pb/index_cgo_msg.pb.h"

#ifdef BUILD_DISK_ANN
#include "storage/DiskFileManagerImpl.h"
Expand All @@ -26,6 +27,8 @@ VecIndexCreator::VecIndexCreator(DataType data_type,
const char* serialized_type_params,
const char* serialized_index_params)
: data_type_(data_type) {
proto::indexcgo::TypeParams type_params_;
proto::indexcgo::IndexParams index_params_;
milvus::index::ParseFromString(type_params_, std::string(serialized_type_params));
milvus::index::ParseFromString(index_params_, std::string(serialized_index_params));

Expand Down
3 changes: 0 additions & 3 deletions internal/core/src/indexbuilder/VecIndexCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "indexbuilder/IndexCreatorBase.h"
#include "index/VectorIndex.h"
#include "index/IndexInfo.h"
#include "pb/index_cgo_msg.pb.h"

namespace milvus::indexbuilder {

Expand Down Expand Up @@ -51,8 +50,6 @@ class VecIndexCreator : public IndexCreatorBase {

private:
milvus::index::IndexBasePtr index_ = nullptr;
proto::indexcgo::TypeParams type_params_;
proto::indexcgo::IndexParams index_params_;
Config config_;
DataType data_type_;
};
Expand Down
11 changes: 1 addition & 10 deletions internal/core/src/segcore/load_index_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "index/IndexFactory.h"
#include "storage/Util.h"
#include "segcore/load_index_c.h"
#include "pb/index_cgo_msg.pb.h"

CStatus
NewLoadIndexInfo(CLoadIndexInfo* c_load_index_info) {
Expand Down Expand Up @@ -200,20 +199,12 @@ AppendIndexFilePath(CLoadIndexInfo c_load_index_info, const char* c_file_path) {
}

CStatus
AppendIndexInfo(
CLoadIndexInfo c_load_index_info, int64_t index_id, int64_t build_id, int64_t version, const char* c_index_params) {
AppendIndexInfo(CLoadIndexInfo c_load_index_info, int64_t index_id, int64_t build_id, int64_t version) {
try {
auto load_index_info = (milvus::index::LoadIndexInfo*)c_load_index_info;
load_index_info->index_id = index_id;
load_index_info->index_build_id = build_id;
load_index_info->index_version = version;
milvus::proto::indexcgo::IndexParams index_params;
milvus::index::ParseFromString(index_params, c_index_params);

for (auto i = 0; i < index_params.params().size(); i++) {
auto& param = index_params.params(i);
load_index_info->index_params[param.key()] = param.value();
}

auto status = CStatus();
status.error_code = Success;
Expand Down
3 changes: 1 addition & 2 deletions internal/core/src/segcore/load_index_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ AppendFieldInfo(CLoadIndexInfo c_load_index_info,
enum CDataType field_type);

CStatus
AppendIndexInfo(
CLoadIndexInfo c_load_index_info, int64_t index_id, int64_t build_id, int64_t version, const char* index_params);
AppendIndexInfo(CLoadIndexInfo c_load_index_info, int64_t index_id, int64_t build_id, int64_t version);

CStatus
AppendIndex(CLoadIndexInfo c_load_index_info, CBinarySet c_binary_set);
Expand Down
1 change: 0 additions & 1 deletion internal/core/src/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ aux_source_directory( ${MILVUS_ENGINE_SRC}/utils UTILS_FILES )

add_library( milvus_utils STATIC ${UTILS_FILES} )

target_link_libraries( milvus_utils PRIVATE milvus_exceptions)
25 changes: 10 additions & 15 deletions internal/querynode/load_index_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ import (
"path/filepath"
"unsafe"

"github.com/golang/protobuf/proto"

"github.com/milvus-io/milvus/api/commonpb"
"github.com/milvus-io/milvus/api/schemapb"
"github.com/milvus-io/milvus/internal/proto/indexcgopb"
"github.com/milvus-io/milvus/internal/proto/querypb"
)

Expand Down Expand Up @@ -65,11 +61,18 @@ func (li *LoadIndexInfo) appendLoadIndexInfo(bytesIndex [][]byte, indexInfo *que
return err
}

err = li.appendIndexInfo(indexInfo.IndexID, indexInfo.BuildID, indexInfo.IndexVersion, indexInfo.IndexParams)
err = li.appendIndexInfo(indexInfo.IndexID, indexInfo.BuildID, indexInfo.IndexVersion)
if err != nil {
return err
}

for _, param := range indexInfo.IndexParams {
err = li.appendIndexParam(param.Key, param.Value)
if err != nil {
return err
}
}

err = li.appendIndexData(bytesIndex, indexPaths)
return err
}
Expand All @@ -84,20 +87,12 @@ func (li *LoadIndexInfo) appendIndexParam(indexKey string, indexValue string) er
return HandleCStatus(&status, "AppendIndexParam failed")
}

func (li *LoadIndexInfo) appendIndexInfo(indexID int64, buildID int64, indexVersion int64, indexParams []*commonpb.KeyValuePair) error {
protoIndexParams := &indexcgopb.IndexParams{
Params: indexParams,
}

indexParamsStr := proto.MarshalTextString(protoIndexParams)
indexParamsPointer := C.CString(indexParamsStr)
defer C.free(unsafe.Pointer(indexParamsPointer))

func (li *LoadIndexInfo) appendIndexInfo(indexID int64, buildID int64, indexVersion int64) error {
cIndexID := C.int64_t(indexID)
cBuildID := C.int64_t(buildID)
cIndexVersion := C.int64_t(indexVersion)

status := C.AppendIndexInfo(li.cLoadIndexInfo, cIndexID, cBuildID, cIndexVersion, indexParamsPointer)
status := C.AppendIndexInfo(li.cLoadIndexInfo, cIndexID, cBuildID, cIndexVersion)
return HandleCStatus(&status, "AppendIndexInfo failed")
}

Expand Down

0 comments on commit d4bc004

Please sign in to comment.