Support an additional (optional) key in iddqd::IdOrdMap (“BiOrdMap”)

未关闭
#19 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
冷清
技术栈
rust
领域
backend

调研方向

首先阅读现有的 IdOrdMap API 及其当前的索引行为。审查提议的 BiOrdMap 设计以及构造函数、索引和迭代相关的问题,然后在实现之前确定预期的 API 和性能权衡。设计达成一致,并且新 map 的行为由适当的测试覆盖,即视为完成。

由索引模型根据 Issue 内容生成。

描述

I love this crate, thank you for all the work!

Quick notice: I’m happy to help drive this feature, but my bandwidth is very limited for the next 6 weeks.

Background
IdOrdMap<K,V> today maintains exactly one sorted key. I need one primary index (sorted) and a secondary key for fast lookup, without being forced to rebuild maps or sort on the fly.

I began this on Reddit but it’s complex enough to merit an in-repo API discussion.

Options

  1. Only primary sorted + secondary lookup
    • Simple, but if you later need to sort by the second key, you’re back to ad-hoc sorting or a separate map.
  2. Two always-sorted keys
    • Two B-trees under the hood; higher memory & insertion/removal cost.
  3. Primary sorted + optional sorted
    • Zero-cost if you don’t invoke the second sort.
    • API is trickier: needs either builders/constructors or trait-gated impls.

API Questions
• Should one hard-code a .with_secondary_index() constructor, or infer “sortable” from K: Ord + Clone?
• Does one expose separate .iter_by_primary()/.iter_by_secondary() methods, or a unified .iter(Index)?
• Is it better to have separate BiOrdMap vs. a single generic type with optional indices?

Initial Proposal
Introduce a BiOrdMap<K1, K2, V> that always provides:
• Primary sorted index on K1
• Secondary unsorted lookup by K2

This stays close to the existing API, provides a playground to refine constructors, method names, and performance trade-offs, and lays groundwork for an optional‐sort variant later.

Feedback and real-world use cases welcome!

主要语言
Rust
星标
411
派生
16
平均合并
21 分钟
30 天内合并 PR
2

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

oxidecomputer/iddqd 的其他 Issue

查看 oxidecomputer/iddqd 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。