-
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.
Merge pull request #112 from CodeGov-org/fix/logs-pagination
fix: logs timestamp indexing in memory
- Loading branch information
Showing
9 changed files
with
183 additions
and
94 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
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 |
---|---|---|
@@ -1,18 +1,30 @@ | ||
use super::{Memory, LOGS_INDEX_MEMORY_ID, LOGS_MEMORY_ID, MEMORY_MANAGER}; | ||
use crate::repositories::LogEntry; | ||
use ic_stable_structures::Log; | ||
use super::{ | ||
Memory, LOGS_INDEX_MEMORY_ID, LOGS_MEMORY_ID, LOGS_TIMESTAMP_LEVEL_INDEX_MEMORY_ID, | ||
MEMORY_MANAGER, | ||
}; | ||
use crate::repositories::{LogEntry, LogId, LogTimestampKey}; | ||
use ic_stable_structures::{BTreeMap, Log}; | ||
|
||
pub type LogMemory = Log<LogEntry, Memory, Memory>; | ||
pub type LogTimestampIndexMemory = BTreeMap<LogTimestampKey, LogId, Memory>; | ||
|
||
pub fn init_logs() -> LogMemory { | ||
// TODO: handle the error | ||
LogMemory::init(get_logs_index_memory(), get_logs_memory()).unwrap() | ||
} | ||
|
||
pub fn init_log_timestamp_index() -> LogTimestampIndexMemory { | ||
LogTimestampIndexMemory::init(get_logs_timestamp_level_index_memory()) | ||
} | ||
|
||
fn get_logs_index_memory() -> Memory { | ||
MEMORY_MANAGER.with(|m| m.borrow().get(LOGS_INDEX_MEMORY_ID)) | ||
} | ||
|
||
fn get_logs_memory() -> Memory { | ||
MEMORY_MANAGER.with(|m| m.borrow().get(LOGS_MEMORY_ID)) | ||
} | ||
|
||
fn get_logs_timestamp_level_index_memory() -> Memory { | ||
MEMORY_MANAGER.with(|m| m.borrow().get(LOGS_TIMESTAMP_LEVEL_INDEX_MEMORY_ID)) | ||
} |
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.