Skip to content

function Base.show(io::IO, tree::RTree) prints entire tree, crashes REPL #9

@hs-ye

Description

@hs-ye

Hi team,

Wondering if we can discuss the behaviour of https://github.com/alyst/SpatialIndexing.jl/blob/master/src/rtree/show.jl

Specifically: the last line of the show() function, when we have large trees (200k+ nodes) and using this interactively, i have to remember to always suppress the output and never print the object in the REPL, or otherwise it will flood the REPL and i basically have to restart the julia session.

function Base.show(io::IO, tree::RTree)
    print(io, typeof(tree))
    print(io, "(variant="); print(io, tree.variant)
    print(io, ", tight_mbrs="); print(io, tree.tight_mbrs)
    print(io, ", nearmin_overlap="); print(io, tree.nearmin_overlap)
    print(io, ", fill_factor="); print(io, tree.fill_factor)
    print(io, ", split_factor="); print(io, tree.split_factor)
    print(io, ", reinsert_factor="); print(io, tree.reinsert_factor)

    print(io, ", leaf_capacity="); print(io, capacity(Leaf, tree))
    print(io, ", branch_capacity="); print(io, capacity(Branch, tree)); println(io, ")")
    print(io, length(tree)); print(io, " element(s) in "); print(io, height(tree));
    print(io, " level(s) ("); print(io, join(reverse(tree.nnodes_perlevel), ", ")); println(io, " node(s) per level):")
    # this line which recursively prints every branch/node
    _show(io, tree.root, recurse=true, indent=1)  end

Can we consider having changing this to print(io::IO, tree::RTree) and having show(io::IO, tree::RTree) without the final recursion call?

That will make working with the RTree interactively much easier, as users can control when they want to print the full tree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions