核心功能: - ✅ Categories/Series双视图管理(category_view.rs + import_markdown.rs) - ✅ FUSE Multi-Volume支持(tree_type参数) - ✅ SSH/SFTP/SCP/rsync协议完整实现(4042行) - ✅ NFS/SMB Module Phase 1-3完成 - ✅ Archive Module Phase 1-4完成(2916行) - ✅ Download Center API完整实现 - ✅ S3兼容API实现(560行) Git配置修正: - ✅ 删除错误origin(gitea.momentry.ddns.net) - ✅ 删除m5max128(指向机器名) - ✅ 设置origin = m5max128gitea.momentry.ddns.net/admin/markbase - ✅ 设置m4minigitea = m4minigitea.momentry.ddns.net/warren/markbase 数据清理: - ✅ 删除38个临时SQLite(保留accusys.sqlite、demo.sqlite) - ✅ 删除.bak、test_*.bin、调试脚本等临时文件 - ✅ 删除临时目录(build/、download files/、raid_test/等) - ✅ 更新.gitignore排除临时文件 架构优化: - 52个文件修改,2434行新增,4739行删除 - Workspace成员整合(16个crate) - 数据库状态:accusys.sqlite保留(主demo测试) 远程同步: - ✅ 准备推送到m5max128gitea(远程Gitea) - ✅ 准备推送到m4minigitea(本地Gitea)
182 lines
6.3 KiB
Swift
182 lines
6.3 KiB
Swift
// MarkBaseFS Complete Usage Example
|
|
// Demonstrates all Frame Index Table and MarkBaseFMS features
|
|
|
|
import Foundation
|
|
|
|
print("====================================")
|
|
print("MarkBaseFS Complete Usage Example")
|
|
print("====================================")
|
|
print("")
|
|
|
|
// Step 1: Initialize MarkBaseFS
|
|
print("Step 1: Initialize MarkBaseFS")
|
|
let markbase = MarkBaseFS()
|
|
|
|
do {
|
|
try markbase.start()
|
|
print("MarkBaseFS started successfully")
|
|
print("")
|
|
|
|
// Step 2: Create Frame Index Table
|
|
print("Step 2: Create Frame Index Table")
|
|
let tempDir = FileManager.default.temporaryDirectory
|
|
let dbPath = tempDir.appendingPathComponent("markbasefs_example.sqlite").path
|
|
|
|
let frameTable = FrameIndexTable(dbPath: dbPath)
|
|
print("Frame Index Table created at: \(dbPath)")
|
|
print("")
|
|
|
|
// Step 3: Create MarkBaseFMS
|
|
print("Step 3: Create MarkBaseFMS")
|
|
let fms = MarkBaseFMS(frameIndexTable: frameTable)
|
|
print("MarkBaseFMS initialized")
|
|
print("")
|
|
|
|
// Step 4: Insert single frame
|
|
print("Step 4: Insert single frame")
|
|
let insertSuccess = fms.insertFrame(
|
|
frameId: "example_frame_001",
|
|
videoId: "example_video_001",
|
|
frameIndex: 1,
|
|
frameFile: "/example/video001/frame001.dpx",
|
|
frameOffset: 0,
|
|
frameSize: 1024000,
|
|
frameChecksum: "example_checksum_001"
|
|
)
|
|
print("Insert single frame: \(insertSuccess ? "SUCCESS" : "FAILED")")
|
|
print("")
|
|
|
|
// Step 5: Batch insert frames (100 frames)
|
|
print("Step 5: Batch insert 100 frames")
|
|
var frames: [(frameId: String, videoId: String, frameIndex: Int, frameFile: String, frameOffset: Int, frameSize: Int, frameChecksum: String)] = []
|
|
|
|
for i in 2...101 {
|
|
frames.append((
|
|
frameId: "example_frame_\(i)",
|
|
videoId: "example_video_001",
|
|
frameIndex: i,
|
|
frameFile: "/example/video001/frame\(i).dpx",
|
|
frameOffset: (i-1) * 1024000,
|
|
frameSize: 1024000,
|
|
frameChecksum: "example_checksum_\(i)"
|
|
))
|
|
}
|
|
|
|
let batchInsertSuccess = fms.insertFrames(frames: frames)
|
|
print("Batch insert: \(batchInsertSuccess ? "SUCCESS" : "FAILED")")
|
|
print("Total frames inserted: 101")
|
|
print("")
|
|
|
|
// Step 6: Query single frame
|
|
print("Step 6: Query single frame")
|
|
let frameInfo = fms.getFrame(frameId: "example_frame_001")
|
|
if let info = frameInfo {
|
|
print("Frame ID: \(info["frame_id"] ?? "")")
|
|
print("Video ID: \(info["video_id"] ?? "")")
|
|
print("Frame Index: \(info["frame_index"] ?? 0)")
|
|
print("Frame Size: \(info["frame_size"] ?? 0)")
|
|
print("Frame Checksum: \(info["frame_checksum"] ?? "")")
|
|
}
|
|
print("")
|
|
|
|
// Step 7: Query all frames for video
|
|
print("Step 7: Query all frames for video")
|
|
let allFrames = fms.getFramesForVideo(videoId: "example_video_001")
|
|
print("Total frames: \(allFrames.count)")
|
|
print("First frame: \(allFrames.first?["frame_id"] ?? "")")
|
|
print("Last frame: \(allFrames.last?["frame_id"] ?? "")")
|
|
print("")
|
|
|
|
// Step 8: Update frame
|
|
print("Step 8: Update frame")
|
|
let updateSuccess = fms.updateFrame(
|
|
frameId: "example_frame_001",
|
|
updates: [
|
|
"frame_size": 2048000,
|
|
"frame_checksum": "updated_checksum"
|
|
]
|
|
)
|
|
print("Update frame: \(updateSuccess ? "SUCCESS" : "FAILED")")
|
|
|
|
// Verify update
|
|
let updatedFrame = fms.getFrame(frameId: "example_frame_001")
|
|
if let info = updatedFrame {
|
|
print("Updated Frame Size: \(info["frame_size"] ?? 0)")
|
|
print("Updated Checksum: \(info["frame_checksum"] ?? "")")
|
|
}
|
|
print("")
|
|
|
|
// Step 9: Lock frame
|
|
print("Step 9: Lock frame")
|
|
let lockSuccess = fms.lockFrame(frameId: "example_frame_001")
|
|
print("Lock frame: \(lockSuccess ? "SUCCESS" : "FAILED")")
|
|
|
|
// Check lock state
|
|
let isLocked = fms.isFrameLocked(frameId: "example_frame_001")
|
|
print("Frame locked: \(isLocked ? "YES" : "NO")")
|
|
|
|
// Verify lock state
|
|
let lockedFrame = fms.getFrame(frameId: "example_frame_001")
|
|
if let info = lockedFrame {
|
|
print("Lock State: \(info["frame_lock_state"] ?? 0)")
|
|
}
|
|
print("")
|
|
|
|
// Step 10: Unlock frame
|
|
print("Step 10: Unlock frame")
|
|
let unlockSuccess = fms.unlockFrame(frameId: "example_frame_001")
|
|
print("Unlock frame: \(unlockSuccess ? "SUCCESS" : "FAILED")")
|
|
|
|
// Check lock state
|
|
let isUnlocked = fms.isFrameLocked(frameId: "example_frame_001")
|
|
print("Frame locked: \(isUnlocked ? "YES" : "NO")")
|
|
print("")
|
|
|
|
// Step 11: Delete frame
|
|
print("Step 11: Delete frame")
|
|
let deleteSuccess = fms.deleteFrame(frameId: "example_frame_001")
|
|
print("Delete frame: \(deleteSuccess ? "SUCCESS" : "FAILED")")
|
|
|
|
// Verify deletion
|
|
let deletedFrame = fms.getFrame(frameId: "example_frame_001")
|
|
print("Frame exists: \(deletedFrame != nil ? "YES" : "NO (deleted)")")
|
|
print("")
|
|
|
|
// Step 12: Performance test (1000 frames)
|
|
print("Step 12: Performance test (1000 frames)")
|
|
var perfFrames: [(frameId: String, videoId: String, frameIndex: Int, frameFile: String, frameOffset: Int, frameSize: Int, frameChecksum: String)] = []
|
|
|
|
for i in 1...1000 {
|
|
perfFrames.append((
|
|
frameId: "perf_frame_\(i)",
|
|
videoId: "perf_video",
|
|
frameIndex: i,
|
|
frameFile: "/perf/video/frame\(i).dpx",
|
|
frameOffset: (i-1) * 1024000,
|
|
frameSize: 1024000,
|
|
frameChecksum: "perf_checksum_\(i)"
|
|
))
|
|
}
|
|
|
|
let startTime = Date()
|
|
let perfInsertSuccess = fms.insertFrames(frames: perfFrames)
|
|
let endTime = Date()
|
|
let duration = endTime.timeIntervalSince(startTime)
|
|
|
|
print("Performance test: \(perfInsertSuccess ? "SUCCESS" : "FAILED")")
|
|
print("Inserted 1000 frames in \(String(format: "%.3f", duration)) seconds")
|
|
print("Average: \(String(format: "%.6f", duration / 1000.0)) seconds per frame")
|
|
print("Performance: \(String(format: "%.0f", 1000.0 / duration)) frames per second")
|
|
print("")
|
|
|
|
print("====================================")
|
|
print("All operations completed successfully!")
|
|
print("====================================")
|
|
print("")
|
|
|
|
markbase.stop()
|
|
|
|
} catch {
|
|
print("Error: \(error)")
|
|
exit(1)
|
|
} |