Skip to content

Commit

Permalink
Remove typed_print (#7868)
Browse files Browse the repository at this point in the history
* remove typed_print

* fix compress all builder
  • Loading branch information
nicola-cab authored Jul 9, 2024
1 parent 3e32e5f commit 0e533a7
Show file tree
Hide file tree
Showing 15 changed files with 5 additions and 288 deletions.
11 changes: 5 additions & 6 deletions evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1863,19 +1863,18 @@ buildvariants:
- name: finalize_coverage_data

- name: macos-array-compression
display_name: "MacOS 11 arm64 (Compress Arrays)"
run_on: macos-1100-arm64
display_name: "MacOS 14 arm64 (Compress Arrays)"
run_on: macos-14-arm64
expansions:
cmake_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/cmake-3.26.3-macos-universal.tar.gz"
cmake_bindir: "./cmake_binaries/CMake.app/Contents/bin"
cmake_bindir: "/opt/homebrew/bin"
cmake_toolchain_file: "./tools/cmake/xcode.toolchain.cmake"
cmake_build_tool_options: "-sdk macosx"
cmake_generator: Xcode
max_jobs: $(sysctl -n hw.logicalcpu)
xcode_developer_dir: /Applications/Xcode13.1.app/Contents/Developer
xcode_developer_dir: /Applications/Xcode15.2.app/Contents/Developer
extra_flags: -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_OSX_ARCHITECTURES=arm64
compress: On
cmake_build_type: Debug
coveralls_flag_name: "macos-arm64"
tasks:
- name: compile_test

Expand Down
34 changes: 0 additions & 34 deletions src/realm/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,40 +1080,6 @@ bool QueryStateFindAll<IntegerColumn>::match(size_t index) noexcept
return (m_limit > m_match_count);
}

void Array::typed_print(std::string prefix) const
{
std::cout << "Generic Array " << header_to_string(get_header()) << " @ " << m_ref;
if (!is_attached()) {
std::cout << " Unattached";
return;
}
if (size() == 0) {
std::cout << " Empty" << std::endl;
return;
}
std::cout << " size = " << size() << " {";
if (has_refs()) {
std::cout << std::endl;
for (unsigned n = 0; n < size(); ++n) {
auto pref = prefix + " " + to_string(n) + ":\t";
RefOrTagged rot = get_as_ref_or_tagged(n);
if (rot.is_ref() && rot.get_as_ref()) {
Array a(m_alloc);
a.init_from_ref(rot.get_as_ref());
std::cout << pref;
a.typed_print(pref);
}
else if (rot.is_tagged()) {
std::cout << pref << rot.get_as_int() << std::endl;
}
}
std::cout << prefix << "}" << std::endl;
}
else {
std::cout << " Leaf of unknown type }" << std::endl;
}
}

ref_type ArrayPayload::typed_write(ref_type ref, _impl::ArrayWriterBase& out, Allocator& alloc)
{
Array arr(alloc);
Expand Down
2 changes: 0 additions & 2 deletions src/realm/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,6 @@ class Array : public Node, public ArrayParent {
/// log2. Possible results {0, 1, 2, 4, 8, 16, 32, 64}
static uint8_t bit_width(int64_t value);

void typed_print(std::string prefix) const;

protected:
friend class NodeTree;
void copy_on_write();
Expand Down
31 changes: 0 additions & 31 deletions src/realm/bplustree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,37 +867,6 @@ ref_type BPlusTreeBase::typed_write(ref_type ref, _impl::ArrayWriterBase& out, A
return written_node.write(out);
}

void BPlusTreeBase::typed_print(std::string prefix, Allocator& alloc, ref_type root, ColumnType col_type)
{
char* header = alloc.translate(root);
Array a(alloc);
a.init_from_ref(root);
if (NodeHeader::get_is_inner_bptree_node_from_header(header)) {
std::cout << "{" << std::endl;
REALM_ASSERT(a.has_refs());
for (unsigned j = 0; j < a.size(); ++j) {
auto pref = prefix + " " + std::to_string(j) + ":\t";
RefOrTagged rot = a.get_as_ref_or_tagged(j);
if (rot.is_ref() && rot.get_as_ref()) {
if (j == 0) {
std::cout << pref << "BPTree offsets as ArrayUnsigned as ";
Array a(alloc);
a.init_from_ref(rot.get_as_ref());
a.typed_print(prefix);
}
else {
std::cout << pref << "Subtree beeing ";
BPlusTreeBase::typed_print(pref, alloc, rot.get_as_ref(), col_type);
}
}
}
}
else {
std::cout << "BPTree Leaf[" << col_type << "] as ";
a.typed_print(prefix);
}
}

size_t BPlusTreeBase::size_from_header(const char* header)
{
auto node_size = Array::get_size_from_header(header);
Expand Down
2 changes: 0 additions & 2 deletions src/realm/bplustree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ class BPlusTreeBase {
}

static ref_type typed_write(ref_type, _impl::ArrayWriterBase&, Allocator&, TypedWriteFunc);
static void typed_print(std::string prefix, Allocator& alloc, ref_type root, ColumnType col_type);


protected:
template <class U>
Expand Down
72 changes: 0 additions & 72 deletions src/realm/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1713,76 +1713,4 @@ ref_type Cluster::typed_write(ref_type ref, _impl::ArrayWriterBase& out) const
}
return written_cluster.write(out);
}

void Cluster::typed_print(std::string prefix) const
{
REALM_ASSERT_DEBUG(!get_is_inner_bptree_node_from_header(get_header()));
std::cout << "Cluster of size " << size() << " " << header_to_string(get_header()) << std::endl;
const auto table = get_owning_table();
for (unsigned j = 0; j < size(); ++j) {
RefOrTagged rot = get_as_ref_or_tagged(j);
auto pref = prefix + " " + std::to_string(j) + ":\t";
if (rot.is_ref() && rot.get_as_ref()) {
if (j == 0) {
std::cout << pref << "Keys as ArrayUnsigned as ";
Array a(m_alloc);
a.init_from_ref(rot.get_as_ref());
a.typed_print(pref);
}
else {
auto col_key = table->m_leaf_ndx2colkey[j - 1];
auto col_type = col_key.get_type();
auto col_attr = col_key.get_attrs();
std::string attr_string;
if (col_attr.test(col_attr_Dictionary))
attr_string = "Dict:";
if (col_attr.test(col_attr_List))
attr_string = "List:";
if (col_attr.test(col_attr_Set))
attr_string = "Set:";
if (col_attr.test(col_attr_Nullable))
attr_string += "Null:";
std::cout << pref << "Column[" << attr_string << col_type << "] as ";
// special cases for the types we want to compress
if (col_attr.test(col_attr_List) || col_attr.test(col_attr_Set)) {
// That is a single bplustree
// propagation of nullable missing here?
// handling of mixed missing here?
BPlusTreeBase::typed_print(pref, m_alloc, rot.get_as_ref(), col_type);
}
else if (col_attr.test(col_attr_Dictionary)) {
Array dict_top(m_alloc);
dict_top.init_from_ref(rot.get_as_ref());
if (dict_top.size() == 0) {
std::cout << "{ empty }" << std::endl;
continue;
}
std::cout << "{" << std::endl;
auto ref0 = dict_top.get_as_ref(0);
if (ref0) {
auto p = pref + " 0:\t";
std::cout << p;
BPlusTreeBase::typed_print(p, m_alloc, ref0, col_type);
}
if (dict_top.size() == 1) {
continue; // is this really possible? or should all dicts have both trees?
}
auto ref1 = dict_top.get_as_ref(1);
if (ref1) {
auto p = pref + " 1:\t";
std::cout << p;
BPlusTreeBase::typed_print(p, m_alloc, dict_top.get_as_ref(1), col_type);
}
}
else {
// handle all other cases as generic arrays
Array a(m_alloc);
a.init_from_ref(rot.get_as_ref());
a.typed_print(pref);
}
}
}
}
}

} // namespace realm
8 changes: 0 additions & 8 deletions src/realm/cluster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,6 @@ class ClusterNode : public Array {
}
virtual ref_type typed_write(ref_type ref, _impl::ArrayWriterBase& out) const = 0;

virtual void typed_print(std::string prefix) const
{
static_cast<void>(get_owning_table());
std::cout << "ClusterNode as ";
Array::typed_print(prefix);
}

protected:
#if REALM_MAX_BPNODE_SIZE > 256
static constexpr int node_shift_factor = 8;
Expand Down Expand Up @@ -329,7 +322,6 @@ class Cluster : public ClusterNode {
void verify() const;
void dump_objects(int64_t key_offset, std::string lead) const override;
virtual ref_type typed_write(ref_type ref, _impl::ArrayWriterBase& out) const override;
virtual void typed_print(std::string prefix) const override;
static void remove_backlinks(const Table* origin_table, ObjKey origin_key, ColKey col,
const std::vector<ObjKey>& keys, CascadeState& state);
static void remove_backlinks(const Table* origin_table, ObjKey origin_key, ColKey col,
Expand Down
37 changes: 0 additions & 37 deletions src/realm/cluster_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,43 +165,6 @@ class ClusterNodeInner : public ClusterNode {
return written_node.write(out);
}

virtual void typed_print(std::string prefix) const override
{
REALM_ASSERT(get_is_inner_bptree_node_from_header(get_header()));
REALM_ASSERT(has_refs());
std::cout << "ClusterNodeInner " << header_to_string(get_header()) << std::endl;
for (unsigned j = 0; j < size(); ++j) {
RefOrTagged rot = get_as_ref_or_tagged(j);
auto pref = prefix + " " + std::to_string(j) + ":\t";
if (rot.is_ref() && rot.get_as_ref()) {
if (j == 0) {
std::cout << pref << "Keys as ArrayUnsigned as ";
Array a(m_alloc);
a.init_from_ref(rot.get_as_ref());
a.typed_print(pref);
}
else {
auto header = m_alloc.translate(rot.get_as_ref());
MemRef m(header, rot.get_as_ref(), m_alloc);
if (get_is_inner_bptree_node_from_header(header)) {
ClusterNodeInner a(m_alloc, m_tree_top);
a.init(m);
std::cout << pref;
a.typed_print(pref);
}
else {
Cluster a(j, m_alloc, m_tree_top);
a.init(m);
std::cout << pref;
a.typed_print(pref);
}
}
}
// just ignore entries, which are not refs.
}
Array::typed_print(prefix);
}

private:
static constexpr size_t s_key_ref_index = 0;
static constexpr size_t s_sub_tree_depth_index = 1;
Expand Down
11 changes: 0 additions & 11 deletions src/realm/cluster_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,6 @@ class ClusterTree {
return m_root->typed_write(ref, out);
}

void typed_print(std::string prefix) const
{
if (m_root) {
std::cout << prefix << "ClusterTree as ";
m_root->typed_print(prefix);
}
else {
std::cout << "Emtpy ClusterTree" << std::endl;
}
}

protected:
friend class Obj;
friend class Cluster;
Expand Down
42 changes: 0 additions & 42 deletions src/realm/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,48 +960,6 @@ ref_type Group::typed_write_tables(_impl::ArrayWriterBase& out) const
}
return dest.write(out);
}
void Group::table_typed_print(std::string prefix, ref_type ref) const
{
REALM_ASSERT(m_top.get_as_ref(1) == ref);
Array a(m_alloc);
a.init_from_ref(ref);
REALM_ASSERT(a.has_refs());
for (unsigned j = 0; j < a.size(); ++j) {
auto pref = prefix + " " + to_string(j) + ":\t";
RefOrTagged rot = a.get_as_ref_or_tagged(j);
if (rot.is_tagged() || rot.get_as_ref() == 0)
continue;
auto table_accessor = do_get_table(j);
REALM_ASSERT(table_accessor);
table_accessor->typed_print(pref, rot.get_as_ref());
}
}
void Group::typed_print(std::string prefix) const
{
std::cout << "Group top array" << std::endl;
for (unsigned j = 0; j < m_top.size(); ++j) {
auto pref = prefix + " " + to_string(j) + ":\t";
RefOrTagged rot = m_top.get_as_ref_or_tagged(j);
if (rot.is_ref() && rot.get_as_ref()) {
if (j == 1) {
// Tables
std::cout << pref << "All Tables" << std::endl;
table_typed_print(pref, rot.get_as_ref());
}
else {
Array a(m_alloc);
a.init_from_ref(rot.get_as_ref());
std::cout << pref;
a.typed_print(pref);
}
}
else {
std::cout << pref << rot.get_as_int() << std::endl;
}
}
std::cout << "}" << std::endl;
}


ref_type Group::DefaultTableWriter::write_names(_impl::OutputStream& out)
{
Expand Down
6 changes: 0 additions & 6 deletions src/realm/group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,6 @@ class Group : public ArrayParent {
}
#endif
ref_type typed_write_tables(_impl::ArrayWriterBase& out) const;
void table_typed_print(std::string prefix, ref_type ref) const;
void typed_print(std::string prefix) const;

protected:
static constexpr size_t s_table_name_ndx = 0;
Expand Down Expand Up @@ -1129,10 +1127,6 @@ class Group::TableWriter {
virtual ref_type write_names(_impl::OutputStream&) = 0;
virtual ref_type write_tables(_impl::OutputStream&) = 0;
virtual HistoryInfo write_history(_impl::OutputStream&) = 0;
void typed_print(std::string prefix)
{
m_group->typed_print(prefix);
}

virtual ~TableWriter() noexcept {}

Expand Down
5 changes: 0 additions & 5 deletions src/realm/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,6 @@ class Node : public NodeHeader {
}
}

void typed_print(int) const
{
std::cout << "Generic Node ERROR\n";
}

protected:
/// The total size in bytes (including the header) of a new empty
/// array. Must be a multiple of 8 (i.e., 64-bit aligned).
Expand Down
5 changes: 0 additions & 5 deletions src/realm/spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ class Spec {
void set_ndx_in_parent(size_t) noexcept;

void verify() const;
void typed_print(std::string prefix) const
{
std::cout << prefix << "Spec as ";
m_top.typed_print(prefix);
}

private:
// Underlying array structure.
Expand Down
Loading

0 comments on commit 0e533a7

Please sign in to comment.