logosdb 0.7.7 → 0.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -8
- package/binding.gyp +9 -9
- package/deps/core/include/logosdb/logosdb.h +530 -0
- package/deps/core/src/hnsw_index.cpp +345 -0
- package/deps/core/src/hnsw_index.h +77 -0
- package/deps/core/src/logosdb.cpp +781 -0
- package/deps/core/src/metadata.cpp +266 -0
- package/deps/core/src/metadata.h +69 -0
- package/deps/core/src/platform.cpp +342 -0
- package/deps/core/src/platform.h +94 -0
- package/deps/core/src/storage.cpp +764 -0
- package/deps/core/src/storage.h +131 -0
- package/deps/core/src/wal.cpp +570 -0
- package/deps/core/src/wal.h +99 -0
- package/deps/core/third_party/hnswlib/hnswlib/bruteforce.h +163 -0
- package/deps/core/third_party/hnswlib/hnswlib/hnswalg.h +1411 -0
- package/deps/core/third_party/hnswlib/hnswlib/hnswlib.h +228 -0
- package/deps/core/third_party/hnswlib/hnswlib/space_ip.h +400 -0
- package/deps/core/third_party/hnswlib/hnswlib/space_l2.h +324 -0
- package/deps/core/third_party/hnswlib/hnswlib/stop_condition.h +276 -0
- package/deps/core/third_party/hnswlib/hnswlib/visited_list_pool.h +78 -0
- package/deps/core/third_party/nlohmann/json.hpp +24765 -0
- package/package.json +21 -5
- package/scripts/vendor-core.mjs +66 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
// Platform abstraction layer for cross-platform compatibility
|
|
4
|
+
// Handles differences between POSIX (Linux/macOS) and Windows
|
|
5
|
+
|
|
6
|
+
#ifdef _WIN32
|
|
7
|
+
#define LOGOSDB_WINDOWS
|
|
8
|
+
#define NOMINMAX
|
|
9
|
+
#include <direct.h>
|
|
10
|
+
#include <io.h>
|
|
11
|
+
#include <windows.h>
|
|
12
|
+
#else
|
|
13
|
+
#define LOGOSDB_POSIX
|
|
14
|
+
#include <string.h> // For strdup
|
|
15
|
+
#include <sys/mman.h>
|
|
16
|
+
#include <unistd.h>
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
#include <cstddef>
|
|
20
|
+
#include <cstdint>
|
|
21
|
+
#include <string>
|
|
22
|
+
|
|
23
|
+
namespace logosdb
|
|
24
|
+
{
|
|
25
|
+
namespace internal
|
|
26
|
+
{
|
|
27
|
+
namespace platform
|
|
28
|
+
{
|
|
29
|
+
|
|
30
|
+
// Memory-mapped file abstraction
|
|
31
|
+
struct MappedFile
|
|
32
|
+
{
|
|
33
|
+
#ifdef LOGOSDB_WINDOWS
|
|
34
|
+
HANDLE file_handle = INVALID_HANDLE_VALUE;
|
|
35
|
+
HANDLE map_handle = INVALID_HANDLE_VALUE;
|
|
36
|
+
#else
|
|
37
|
+
int fd = -1;
|
|
38
|
+
#endif
|
|
39
|
+
uint8_t* data = nullptr;
|
|
40
|
+
size_t size = 0;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// File operations
|
|
44
|
+
bool file_exists(const std::string& path);
|
|
45
|
+
bool file_truncate(int fd, size_t size);
|
|
46
|
+
int file_sync(int fd);
|
|
47
|
+
|
|
48
|
+
// Memory mapping
|
|
49
|
+
bool mmap_open(const std::string& path, size_t& out_size, MappedFile& out_map, std::string& err);
|
|
50
|
+
bool mmap_resize(MappedFile& map, size_t new_size, std::string& err);
|
|
51
|
+
void mmap_close(MappedFile& map);
|
|
52
|
+
|
|
53
|
+
// Reservation mapping (for avoiding remap on append)
|
|
54
|
+
bool mmap_reserve(const std::string& path,
|
|
55
|
+
size_t reserve_size,
|
|
56
|
+
MappedFile& out_map,
|
|
57
|
+
std::string& err);
|
|
58
|
+
size_t mmap_commit(MappedFile& map, size_t file_size); // Returns actual committed size
|
|
59
|
+
|
|
60
|
+
// String utilities
|
|
61
|
+
char* string_duplicate(const char* str);
|
|
62
|
+
|
|
63
|
+
// Platform-specific wrapper macros
|
|
64
|
+
#ifdef _WIN32
|
|
65
|
+
inline bool file_truncate(int fd, size_t size)
|
|
66
|
+
{
|
|
67
|
+
return _chsize_s(fd, size) == 0;
|
|
68
|
+
}
|
|
69
|
+
inline int file_sync(int fd)
|
|
70
|
+
{
|
|
71
|
+
return _commit(fd);
|
|
72
|
+
}
|
|
73
|
+
inline char* string_duplicate(const char* str)
|
|
74
|
+
{
|
|
75
|
+
return _strdup(str);
|
|
76
|
+
}
|
|
77
|
+
#else
|
|
78
|
+
inline bool file_truncate(int fd, size_t size)
|
|
79
|
+
{
|
|
80
|
+
return ftruncate(fd, size) == 0;
|
|
81
|
+
}
|
|
82
|
+
inline int file_sync(int fd)
|
|
83
|
+
{
|
|
84
|
+
return fsync(fd);
|
|
85
|
+
}
|
|
86
|
+
inline char* string_duplicate(const char* str)
|
|
87
|
+
{
|
|
88
|
+
return strdup(str);
|
|
89
|
+
}
|
|
90
|
+
#endif
|
|
91
|
+
|
|
92
|
+
} // namespace platform
|
|
93
|
+
} // namespace internal
|
|
94
|
+
} // namespace logosdb
|