forked from milvus-io/milvus-storage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: shaoting-huang <[email protected]>
- Loading branch information
1 parent
e7ab8b4
commit b06e1c5
Showing
13 changed files
with
255 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
cpp/include/milvus-storage/packed/column_offset_mapping_c.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2024 Zilliz | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <stdint.h> | ||
|
||
typedef void* CColumnOffsetMapping; | ||
|
||
int NewColumnOffsetMapping(CColumnOffsetMapping* c_column_offset_mapping); | ||
|
||
void DeleteColumnOffsetMapping(CColumnOffsetMapping c_column_offset_mapping); | ||
|
||
int AddColumnOffset(CColumnOffsetMapping c_column_offset_mapping, | ||
const char* field_name, | ||
int64_t path_index, | ||
int64_t col_index); | ||
|
||
void GetColumnOffsetMappingKeys(CColumnOffsetMapping c_column_offset_mapping, void* keys); | ||
|
||
int GetColumnOffsetMappingSize(CColumnOffsetMapping c_column_offset_mapping); | ||
|
||
int GetColumnOffset(CColumnOffsetMapping c_column_offset_mapping, | ||
const char* field_name, | ||
int* path_index, | ||
int* col_index); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright 2024 Zilliz | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "packed/column_offset_mapping_c.h" | ||
#include "packed/column_group.h" | ||
|
||
int NewColumnOffsetMapping(CColumnOffsetMapping* c_column_offset_mapping) { | ||
try { | ||
auto column_offset_mapping = std::make_unique<milvus_storage::ColumnOffsetMapping>(); | ||
*c_column_offset_mapping = column_offset_mapping.release(); | ||
return 0; | ||
} catch (const std::exception& ex) { | ||
return -1; | ||
} | ||
} | ||
|
||
void DeleteColumnOffsetMapping(CColumnOffsetMapping c_column_offset_mapping) { | ||
auto column_offset_mapping = (milvus_storage::ColumnOffsetMapping*)c_column_offset_mapping; | ||
delete column_offset_mapping; | ||
} | ||
|
||
int AddColumnOffset(CColumnOffsetMapping c_column_offset_mapping, | ||
const char* field_name, | ||
int64_t path_index, | ||
int64_t col_index) { | ||
try { | ||
auto column_offset_mapping = (milvus_storage::ColumnOffsetMapping*)c_column_offset_mapping; | ||
std::string field_name_str(field_name); | ||
column_offset_mapping->AddColumnOffset(field_name_str, path_index, col_index); | ||
return 0; | ||
} catch (const std::exception& ex) { | ||
return -1; | ||
} | ||
} | ||
|
||
void GetColumnOffsetMappingKeys(CColumnOffsetMapping c_column_offset_mapping, void* keys) { | ||
auto column_offset_mapping = (milvus_storage::ColumnOffsetMapping*)c_column_offset_mapping; | ||
const char** keys_ = (const char**)keys; | ||
auto map_ = column_offset_mapping->GetMapping(); | ||
std::size_t i = 0; | ||
for (auto it = map_.begin(); it != map_.end(); ++it, i++) { | ||
keys_[i] = it->first.c_str(); | ||
} | ||
} | ||
|
||
int GetColumnOffsetMappingSize(CColumnOffsetMapping c_column_offset_mapping) { | ||
auto column_offset_mapping = (milvus_storage::ColumnOffsetMapping*)c_column_offset_mapping; | ||
return column_offset_mapping->Size(); | ||
} | ||
|
||
int GetColumnOffset(CColumnOffsetMapping c_column_offset_mapping, | ||
const char* field_name, | ||
int* path_index, | ||
int* col_index) { | ||
auto column_offset_mapping = (milvus_storage::ColumnOffsetMapping*)c_column_offset_mapping; | ||
std::string field_name_str(field_name); | ||
auto column_offset = column_offset_mapping->GetByFieldName(field_name_str); | ||
if (column_offset == nullptr) { | ||
return 0; | ||
} | ||
*path_index = column_offset->path_index; | ||
*col_index = column_offset->col_index; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.