Skip to content

BUG: Fix store proxy swaps, binary write results and root comparison - #1986

Open
joeykleingers wants to merge 1 commit into
BlueQuartzSoftware:developfrom
joeykleingers:topic/store-proxy-and-binary-write-fixes
Open

joeykleingers wants to merge 1 commit into
BlueQuartzSoftware:developfrom
joeykleingers:topic/store-proxy-and-binary-write-fixes

Conversation

@joeykleingers

Copy link
Copy Markdown
Contributor

Summary

This PR fixes four defects in simplnx data stores and in the test helper CompareDataStructures. Each one reported success or changed nothing where it should have failed or written data. The list-store fix also changes the output of Append Image Geometry, which now mirrors neighbor lists. It also removes an unused VTK writer that ignored the binary-write result. The paired SimplnxOoc pull request fixes the same binary-write defect in its out-of-core store. 8 files changed, +517 / −198 lines (most of the additions are tests).

1. Binary writes report failures

  • DataStore::writeBinaryFile(std::ostream&) checks fail() instead of bad(). A stream that is already in a failed state writes nothing; it was reported as success and is now error -10175.
  • DataStore::writeBinaryFile(const std::string&) closes the file and checks the result. The values are buffered until the file is closed, so a failure at that point (for example a full disk) left a truncated file that was reported as written. It is now error -10176, with the file path and what to check. A partly written file stays in place, as before.

2. Value proxy swap across two stores

std::iter_swap on iterators of two different numeric stores swapped an index with itself in the first store, so neither store changed. The AbstractDataStore value proxy now exchanges the two values when the stores differ. A swap inside one store still calls the store's own swap.

3. List proxy keeps its own tuple

The proxy that AbstractListStore iterators return writes its list back to its tuple when it goes away. Its swap exchanged the tuple indices together with the lists, and its move assignment took over the other proxy's tuple. As a result:

  • Swapping two tuples of one store changed nothing.
  • A swap between two stores wrote each list into the wrong tuple.
  • Assigning through iterators, as std::copy does, wrote nothing.

The proxy now keeps its store and tuple, and only the list values are exchanged or assigned.

Behavior change. With Mirror Geometry on, Append Image Geometry mirrors each appended array with std::swap_ranges. Because the list swap did nothing, neighbor lists were left in their unmirrored order while the other arrays were mirrored. They are now mirrored too. The Small_IN100_dream3d_v3 exemplar holds the unmirrored lists in its six Mirrored* containers. The mirrored test cases therefore check the appended neighbor lists against the lists that the test creates, and no longer compare the exemplar's neighbor lists. The test-data archive does not change.

4. CompareDataStructures compares the whole tree

Called without a path, UnitTest::CompareDataStructures compared only the total number of objects, because the loop over the children ran only for a group path. Any two structures of the same size compared equal. The loop now runs for the root too, after a check that both sides have the same number of children. Open PR #1983 moves this function, unchanged, to UnitTestCommon.cpp; whichever of the two merges second takes over the change.

5. Unused VTK writer removed

WriteVtkDataFunctor in SimplnxCore/utils/VtkUtilities.hpp ignored the result of writeBinaryFile. Nothing calls it: PR #1568 replaced its last use in Write Vtk Structured Points with writers that report stream errors, and Write Vtk Rectilinear Grid uses WriteVtkDataArrayFunctor. It is removed, with the include that only it used.

Test plan

  • Each new test fails on develop and passes with the fix:

    • binary write: failed stream, a file that cannot be closed (a test store closes the file early), and a file-size limit (POSIX only)
    • swaps across numeric and bool stores
    • list-store swap, assignment and std::copy
    • CompareDataStructures with a changed value and with different root children (both orders)
    • the mirrored neighbor lists of Append Image Geometry

    The write test of a successful file and the swap inside one store pass before and after.

  • macOS in-core Release build (DREAM3D-NX with this simplnx): all 4,381 tests; 1 is skipped (it needs native OpenGL).

  • macOS out-of-core Release build with SimplnxOoc: all 1,056 tests with the ooc label (without benchmarks).

  • After the last test changes, both builds again: the Append Image Geometry tests and every new test pass (16 in-core, 21 out-of-core, including the Python Append Image Geometry test).

  • After removing the VTK writer, both builds again: the Write Vtk Structured Points and Write Vtk Rectilinear Grid tests pass.

  • CI passes on Linux, macOS and Windows.

Related Issue

  • This PR has no related issue

* DataStore::writeBinaryFile reports a stream that is already in a
  failed state, and a file that could not be written completely when it
  is closed (new error -10176). Both were reported as success, which
  left a truncated file reported as written.
* The AbstractDataStore value proxy swap exchanges values between two
  different stores. It swapped an index with itself in the first store,
  so std::iter_swap across stores changed nothing.
* The AbstractListStore list proxy keeps its own store and tuple in swap
  and move assignment. Swapping two tuples changed nothing, a swap
  across stores wrote to the wrong tuple, and assigning through
  iterators (std::copy) wrote nothing. With Mirror Geometry on, Append
  Image Geometry therefore left neighbor lists unmirrored; it now
  mirrors them like the other arrays. The Small_IN100 exemplar holds
  the unmirrored lists, so the test checks the mirrored lists against
  the lists it creates.
* UnitTest::CompareDataStructures compares the children of the root
  when it is called without a path. It compared only the total number
  of objects, so any two structures of the same size compared equal.
* Remove WriteVtkDataFunctor from VtkUtilities.hpp. Nothing calls it,
  and it ignored the result of writeBinaryFile.
* Add regression tests for each fix.

Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
@joeykleingers joeykleingers self-assigned this Nov 17, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@joeykleingers

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant