refactor: simplify nonzero_triples and update workspace tooling
Remove the `sorted_slots` parameter from `nonzero_triples` and update callers to always sort slots internally. Introduce `MEMBERS_DIR` to workspace scripts to support scanning subdirectories for Cargo manifests. Bump crate-kit version to 0.1.1. - Remove `sorted_slots` field from `nonzero_triples` in `src/obicompactvec/src/views.rs` and always sort permutation by slot values internally. - Update `nonzero_iter` in `src/obicompactvec/src/intmatrix.rs` and `src/obicompactvec/src/bitmatrix/persistent.rs` to call `nonzero_triples` without the `false` argument, passing column views directly. - Add `MEMBERS_DIR` variable to `Makefile` and export it in `.crate-kit/dev-patch.mk` to define the workspace folder for member scanning. - Update `.crate-kit/scripts/deps-lib.sh` and `.crate-kit/scripts/dev-patch.sh` to check for `Cargo.toml` files relative to `$MEMBERS_DIR`, excluding the root manifest. - Change version in `.crate-kit/VERSION` from 0.3.4 to 0.1.1.
This commit is contained in:
1 parent
f1b4b4ebda
commit
f935fb66c4
8 files changed
+25
-23
No files matched your search
+1
-1
@@ -1 +1 @@
|
|||||||
0.3.4+0.1.1
|
0.3.6+0.1.1
|
||||||
@@ -11,7 +11,10 @@ CARGO_TOML ?= Cargo.toml
|
|||||||
-include $(DEVPATCH_DIR)/org.mk
|
-include $(DEVPATCH_DIR)/org.mk
|
||||||
REGISTRY ?=
|
REGISTRY ?=
|
||||||
REGISTRY_INDEX ?=
|
REGISTRY_INDEX ?=
|
||||||
export CARGO_TOML REGISTRY REGISTRY_INDEX FORGE_TOKEN_FILE
|
# MEMBERS_DIR: folder of the workspace when it is not the project root (e.g. src): its Cargo.toml and its
|
||||||
|
# members are scanned by dev-patch and deps-check, in addition to the root ones.
|
||||||
|
MEMBERS_DIR ?=
|
||||||
|
export CARGO_TOML MEMBERS_DIR REGISTRY REGISTRY_INDEX FORGE_TOKEN_FILE
|
||||||
|
|
||||||
# Private registry: the index comes from the environment, never from a file tracked by the repository (CI,
|
# Private registry: the index comes from the environment, never from a file tracked by the repository (CI,
|
||||||
# Docker and a repository cloned alone therefore work without configuration).
|
# Docker and a repository cloned alone therefore work without configuration).
|
||||||
@@ -23,7 +26,7 @@ endif
|
|||||||
|
|
||||||
# Joint development: .cargo/config.toml (local, ignored) is regenerated at EVERY invocation of
|
# Joint development: .cargo/config.toml (local, ignored) is regenerated at EVERY invocation of
|
||||||
# make, whatever the target, from the project's actual dependencies. Nothing to remember.
|
# make, whatever the target, from the project's actual dependencies. Nothing to remember.
|
||||||
DEV_PATCH_RUN := $(shell CARGO_TOML='$(CARGO_TOML)' REGISTRY='$(REGISTRY)' REGISTRY_INDEX='$(REGISTRY_INDEX)' $(DEVPATCH_DIR)/scripts/dev-patch.sh)
|
DEV_PATCH_RUN := $(shell CARGO_TOML='$(CARGO_TOML)' MEMBERS_DIR='$(MEMBERS_DIR)' REGISTRY='$(REGISTRY)' REGISTRY_INDEX='$(REGISTRY_INDEX)' $(DEVPATCH_DIR)/scripts/dev-patch.sh)
|
||||||
|
|
||||||
.PHONY: dev-patch
|
.PHONY: dev-patch
|
||||||
## dev-patch: Regenerates .cargo/config.toml (registry + local patches); already done at every make
|
## dev-patch: Regenerates .cargo/config.toml (registry + local patches); already done at every make
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ lock_entries() {
|
|||||||
manifests=("$CARGO_TOML")
|
manifests=("$CARGO_TOML")
|
||||||
# Root of a workspace whose member CARGO_TOML designates (workspace): shared dependencies.
|
# Root of a workspace whose member CARGO_TOML designates (workspace): shared dependencies.
|
||||||
[ "$CARGO_TOML" != Cargo.toml ] && [ -f Cargo.toml ] && manifests+=(Cargo.toml)
|
[ "$CARGO_TOML" != Cargo.toml ] && [ -f Cargo.toml ] && manifests+=(Cargo.toml)
|
||||||
for m in */Cargo.toml; do
|
# MEMBERS_DIR: folder holding the workspace (root Cargo.toml and members) when it is not the project root.
|
||||||
if [ -f "$m" ]; then manifests+=("$m"); fi
|
for m in */Cargo.toml ${MEMBERS_DIR:+"$MEMBERS_DIR/Cargo.toml" "$MEMBERS_DIR"/*/Cargo.toml}; do
|
||||||
|
if [ -f "$m" ] && [ "$m" != "$CARGO_TOML" ]; then manifests+=("$m"); fi
|
||||||
done
|
done
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
# (Cargo complains about it), whatever the number of crates coming out of a workspace.
|
# (Cargo complains about it), whatever the number of crates coming out of a workspace.
|
||||||
#
|
#
|
||||||
# Run by crate.mk on every make invocation. The file is rewritten only if it changes.
|
# Run by crate.mk on every make invocation. The file is rewritten only if it changes.
|
||||||
# Reads the root Cargo.toml and those of the direct subfolders (workspace members);
|
# Reads the root Cargo.toml and those of the direct subfolders (workspace members), and, if MEMBERS_DIR is set,
|
||||||
|
# those of that folder (its Cargo.toml and its direct subfolders);
|
||||||
# only the dependencies on one line `name = { …, registry = "<registry>" }` are seen.
|
# only the dependencies on one line `name = { …, registry = "<registry>" }` are seen.
|
||||||
# A .cargo/config.toml that was not generated by this script is never overwritten (warning).
|
# A .cargo/config.toml that was not generated by this script is never overwritten (warning).
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -31,7 +32,11 @@ manifests=("$CARGO_TOML")
|
|||||||
# Root of a workspace whose member CARGO_TOML designates (workspace): this is where the shared
|
# Root of a workspace whose member CARGO_TOML designates (workspace): this is where the shared
|
||||||
# dependencies ([workspace.dependencies]) are declared.
|
# dependencies ([workspace.dependencies]) are declared.
|
||||||
[ "$CARGO_TOML" != Cargo.toml ] && [ -f Cargo.toml ] && manifests+=(Cargo.toml)
|
[ "$CARGO_TOML" != Cargo.toml ] && [ -f Cargo.toml ] && manifests+=(Cargo.toml)
|
||||||
for m in */Cargo.toml; do [ -f "$m" ] && manifests+=("$m"); done
|
# MEMBERS_DIR: folder holding the workspace (root Cargo.toml and members), when it is not the project root
|
||||||
|
# (application workspace with its crates under src/: MEMBERS_DIR := src).
|
||||||
|
for m in */Cargo.toml ${MEMBERS_DIR:+"$MEMBERS_DIR/Cargo.toml" "$MEMBERS_DIR"/*/Cargo.toml}; do
|
||||||
|
[ -f "$m" ] && [ "$m" != "$CARGO_TOML" ] && manifests+=("$m")
|
||||||
|
done
|
||||||
|
|
||||||
registry_deps() {
|
registry_deps() {
|
||||||
sed -nE "s/^([A-Za-z0-9_-]+)[[:space:]]*=[[:space:]]*\{[^}]*registry[[:space:]]*=[[:space:]]*\"$REGISTRY\".*/\1/p" "$@"
|
sed -nE "s/^([A-Za-z0-9_-]+)[[:space:]]*=[[:space:]]*\{[^}]*registry[[:space:]]*=[[:space:]]*\"$REGISTRY\".*/\1/p" "$@"
|
||||||
|
|||||||
@@ -222,6 +222,8 @@ print-%:
|
|||||||
# Skipped when obi-kit is absent (CI, repository cloned alone): the committed copy is used.
|
# Skipped when obi-kit is absent (CI, repository cloned alone): the committed copy is used.
|
||||||
# Included last so that the default goal stays `build`.
|
# Included last so that the default goal stays `build`.
|
||||||
KIT_SRC ?= ../obi-kit
|
KIT_SRC ?= ../obi-kit
|
||||||
|
# The workspace (its Cargo.toml and its members) lives under src/: dev-patch and deps-check scan it too.
|
||||||
|
MEMBERS_DIR := $(CARGO_DIR)
|
||||||
$(shell [ -x '$(KIT_SRC)/tools/kit-copy.sh' ] && '$(KIT_SRC)/tools/kit-copy.sh' .crate-kit)
|
$(shell [ -x '$(KIT_SRC)/tools/kit-copy.sh' ] && '$(KIT_SRC)/tools/kit-copy.sh' .crate-kit)
|
||||||
|
|
||||||
include .crate-kit/dev-patch.mk
|
include .crate-kit/dev-patch.mk
|
||||||
|
|||||||
@@ -272,12 +272,9 @@ impl PersistentBitMatrix {
|
|||||||
Self::Implicit { .. } => {
|
Self::Implicit { .. } => {
|
||||||
Box::new(slots.iter().enumerate().map(|(i, _)| (i, 0usize, 1u32)))
|
Box::new(slots.iter().enumerate().map(|(i, _)| (i, 0usize, 1u32)))
|
||||||
}
|
}
|
||||||
Self::Columnar(_) | Self::Packed(_) => Box::new(nonzero_triples(
|
Self::Columnar(_) | Self::Packed(_) => {
|
||||||
slots,
|
Box::new(nonzero_triples(slots, self.n_cols(), |c| self.col_view(c)))
|
||||||
self.n_cols(),
|
}
|
||||||
|c| self.col_view(c),
|
|
||||||
false,
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -560,12 +560,9 @@ impl PersistentIntMatrix {
|
|||||||
) -> Box<dyn Iterator<Item = (usize, usize, u32)> + 'a> {
|
) -> Box<dyn Iterator<Item = (usize, usize, u32)> + 'a> {
|
||||||
match self {
|
match self {
|
||||||
Self::Sparse(m) => Box::new(m.nonzero_iter(slots)),
|
Self::Sparse(m) => Box::new(m.nonzero_iter(slots)),
|
||||||
Self::Columnar(_) | Self::Packed(_) => Box::new(nonzero_triples(
|
Self::Columnar(_) | Self::Packed(_) => {
|
||||||
slots,
|
Box::new(nonzero_triples(slots, self.n_cols(), |c| self.col_view(c)))
|
||||||
self.n_cols(),
|
}
|
||||||
|c| self.col_view(c),
|
|
||||||
false,
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -605,13 +605,10 @@ pub(crate) fn nonzero_triples<V: NonzeroSlotsView>(
|
|||||||
slots: &[usize],
|
slots: &[usize],
|
||||||
n_cols: usize,
|
n_cols: usize,
|
||||||
col_view: impl Fn(usize) -> V,
|
col_view: impl Fn(usize) -> V,
|
||||||
sorted_slots: bool,
|
|
||||||
) -> impl Iterator<Item = (usize, usize, u32)> {
|
) -> impl Iterator<Item = (usize, usize, u32)> {
|
||||||
let n = slots.len();
|
let n = slots.len();
|
||||||
let mut perm: Vec<usize> = (0..n).collect();
|
let mut perm: Vec<usize> = (0..n).collect();
|
||||||
if !sorted_slots {
|
perm.sort_by_key(|&i| slots[i]);
|
||||||
perm.sort_by_key(|&i| slots[i]);
|
|
||||||
}
|
|
||||||
let sorted_slots: Vec<usize> = perm.iter().map(|&i| slots[i]).collect();
|
let sorted_slots: Vec<usize> = perm.iter().map(|&i| slots[i]).collect();
|
||||||
let mut hits: Vec<(usize, usize, u32)> = Vec::new();
|
let mut hits: Vec<(usize, usize, u32)> = Vec::new();
|
||||||
for c in 0..n_cols {
|
for c in 0..n_cols {
|
||||||
|
|||||||
Reference in new issue
Block a user