Skip to content

Commit e07770e

Browse files
authored
Merge pull request #502 from vizzuhq/old_dataframe_rename
Rename DataTable to DataTableOld.
2 parents d11c557 + 4d334e9 commit e07770e

File tree

11 files changed

+46
-45
lines changed

11 files changed

+46
-45
lines changed

src/apps/weblib/interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ void Interface::addRecord(ObjectRegistry::Handle chart,
322322
const char *Interface::dataMetaInfo(ObjectRegistry::Handle chart)
323323
{
324324
thread_local std::string res;
325-
res = Conv::toJSON(getChart(chart)->getTable().getInfos());
325+
res = getChart(chart)->getTable().getInfos();
326326
return res.c_str();
327327
}
328328

src/chart/generator/marker.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,17 @@ Conv::JSONObj &&Marker::appendToJSON(Conv::JSONObj &&jsonObj) const
158158
std::ranges::views::transform(cellInfo.categories,
159159
[this](const auto &pair)
160160
{
161-
return std::make_pair(pair.first.toString(table),
161+
return std::make_pair(
162+
pair.first.toString(table.get()),
162163
table.get()
163164
.getInfo(pair.first.getColIndex().value())
164165
.categories()[pair.second]);
165166
}))("values",
166167
std::ranges::views::transform(cellInfo.values,
167168
[this](const auto &pair)
168169
{
169-
return std::make_pair(pair.first.toString(table),
170+
return std::make_pair(
171+
pair.first.toString(table.get()),
170172
pair.second);
171173
}))("index", idx);
172174
}

src/chart/options/optionssetter.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,7 @@
55

66
#include "options.h"
77

8-
namespace Vizzu
9-
{
10-
11-
namespace Data
12-
{
13-
class DataTable;
14-
}
15-
16-
namespace Gen
8+
namespace Vizzu::Gen
179
{
1810

1911
class OptionsSetter
@@ -59,7 +51,6 @@ class OptionsSetter
5951
const Data::DataTable *table{};
6052
};
6153

62-
}
6354
}
6455

6556
#endif

src/data/datacube/datacube.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ DataCube::DataCube(const DataTable &table,
2323
auto size =
2424
idx.getType().isReal()
2525
? table.getInfo(idx.getColIndex().value())
26-
.dimensionValueCnt()
26+
.categories()
27+
.size()
2728
: idx.getType() == SeriesType::Index
2829
? table.getRowCount()
2930
: throw std::logic_error("internal error: cannot "
@@ -63,7 +64,7 @@ DataCube::DataCube(const DataTable &table,
6364
}
6465
}
6566

66-
MultiIndex DataCube::getIndex(const TableRow<double> &row,
67+
MultiIndex DataCube::getIndex(const DataTable::Row &row,
6768
const std::vector<SeriesIndex> &indices,
6869
size_t rowIndex)
6970
{
@@ -238,9 +239,9 @@ MultiDim::SubSliceIndex DataCube::subSliceIndex(
238239
for (const auto &pair : stringMarkerId) {
239240
auto colIdx = table->getColumn(pair.first);
240241
auto seriesIdx = table->getIndex(colIdx);
241-
const auto &values =
242-
table->getInfo(colIdx).dimensionValueIndexes();
243-
auto valIdx = values.at(pair.second);
242+
auto valIdx =
243+
table->getInfo(colIdx).dimensionValueIndexes().at(
244+
pair.second);
244245
auto dimIdx = getDimBySeries(SeriesIndex(seriesIdx));
245246
index.push_back(
246247
MultiDim::SliceIndex{dimIdx, MultiDim::Index{valIdx}});

src/data/datacube/datacube.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
namespace Vizzu::Data
1616
{
1717

18-
class DataTable;
1918
template <typename T> class TableRow;
2019

2120
using SubCellIndex =
@@ -101,7 +100,7 @@ class DataCube
101100
std::map<SeriesIndex, SubCellIndex> subIndexBySeries;
102101
std::vector<SeriesIndex> seriesBySubIndex;
103102

104-
static MultiDim::MultiIndex getIndex(const TableRow<double> &row,
103+
static MultiDim::MultiIndex getIndex(const DataTable::Row &row,
105104
const std::vector<SeriesIndex> &indices,
106105
size_t rowIndex);
107106

src/data/datacube/datastat.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ DataStat::DataStat(const DataTable &table,
1111
for (const auto &idx : indices) {
1212
if (idx.getType().isReal()) {
1313
auto valueCnt = table.getInfo(idx.getColIndex().value())
14-
.dimensionValueCnt();
14+
.categories()
15+
.size();
1516
usedColumnIDs.insert(
1617
{static_cast<size_t>(idx.getColIndex().value()),
1718
usedValues.size()});
@@ -37,7 +38,7 @@ size_t DataStat::usedValueCntOf(const SeriesIndex &index) const
3738
return 0;
3839
}
3940

40-
void DataStat::trackIndex(const TableRow<double> &row,
41+
void DataStat::trackIndex(const DataTable::Row &row,
4142
const std::vector<SeriesIndex> &indices)
4243
{
4344
for (auto i = 0U; i < indices.size(); ++i) {

src/data/datacube/datastat.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
namespace Vizzu::Data
1010
{
1111

12-
class DataTable;
13-
1412
class DataStat
1513
{
1614
public:
@@ -21,7 +19,7 @@ class DataStat
2119
size_t usedValueCntOf(const SeriesIndex &index) const;
2220

2321
private:
24-
void trackIndex(const TableRow<double> &row,
22+
void trackIndex(const DataTable::Row &row,
2523
const std::vector<SeriesIndex> &indices);
2624

2725
void countValues();

src/data/table/columninfo.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ const ColumnInfo::Values &ColumnInfo::categories() const
7171
return values;
7272
}
7373

74-
size_t ColumnInfo::dimensionValueCnt() const { return values.size(); }
75-
7674
std::string ColumnInfo::getName() const { return name; }
7775

78-
std::string ColumnInfo::getUnit() const { return unit; }
76+
const std::string &ColumnInfo::getUnit() const { return unit; }
7977

8078
Math::Range<double> ColumnInfo::getRange() const { return range; }
8179

src/data/table/columninfo.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Vizzu::Data
1111
{
1212

13-
enum TextType : uint32_t { Number, String };
13+
enum class TextType : uint32_t { Number, String };
1414

1515
class ColumnInfo
1616
{
@@ -34,10 +34,9 @@ class ColumnInfo
3434
[[nodiscard]] ContiType getContiType() const;
3535
[[nodiscard]] const ValueIndexes &dimensionValueIndexes() const;
3636
[[nodiscard]] const Values &categories() const;
37-
[[nodiscard]] size_t dimensionValueCnt() const;
3837

3938
[[nodiscard]] std::string getName() const;
40-
[[nodiscard]] std::string getUnit() const;
39+
[[nodiscard]] const std::string &getUnit() const;
4140
[[nodiscard]] Math::Range<double> getRange() const;
4241
[[nodiscard]] std::string toString() const;
4342
[[nodiscard]] size_t minByteWidth() const;

src/data/table/datatable.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
#include "datatable.h"
22

3+
#include "base/conv/auto_json.h"
4+
35
namespace Vizzu::Data
46
{
57

6-
DataTable::DataTable() = default;
8+
DataTableOld::DataTableOld() = default;
79

8-
void DataTable::pushRow(const std::span<const char *> &cells)
10+
void DataTableOld::pushRow(const std::span<const char *> &cells)
911
{
1012
std::vector<std::string> strCells(cells.begin(), cells.end());
1113
pushRow(TableRow<std::string>(std::move(strCells)));
1214
}
1315

14-
void DataTable::pushRow(const TableRow<std::string> &textRow)
16+
void DataTableOld::pushRow(const TableRow<std::string> &textRow)
1517
{
1618
Row row;
1719
for (auto i = 0U; i < getColumnCount(); ++i) {
@@ -23,7 +25,7 @@ void DataTable::pushRow(const TableRow<std::string> &textRow)
2325
}
2426

2527
template <typename T>
26-
DataTable::DataIndex DataTable::addTypedColumn(
28+
DataTableOld::DataIndex DataTableOld::addTypedColumn(
2729
const std::string &name,
2830
const std::string &unit,
2931
const std::span<T> &values)
@@ -83,14 +85,16 @@ DataTable::DataIndex DataTable::addTypedColumn(
8385
return getIndex(ColumnIndex(colIndex));
8486
}
8587

86-
DataTable::DataIndex DataTable::addColumn(const std::string &name,
88+
DataTableOld::DataIndex DataTableOld::addColumn(
89+
const std::string &name,
8790
const std::string &unit,
8891
const std::span<const double> &values)
8992
{
9093
return addTypedColumn(name, unit, values);
9194
}
9295

93-
DataTable::DataIndex DataTable::addColumn(const std::string &name,
96+
DataTableOld::DataIndex DataTableOld::addColumn(
97+
const std::string &name,
9498
const std::span<const char *> &categories,
9599
const std::span<const std::uint32_t> &values)
96100
{
@@ -101,29 +105,35 @@ DataTable::DataIndex DataTable::addColumn(const std::string &name,
101105
return addTypedColumn<const char *>(name, {}, realValues);
102106
}
103107

104-
const ColumnInfo &DataTable::getInfo(ColumnIndex index) const
108+
const ColumnInfo &DataTableOld::getInfo(ColumnIndex index) const
105109
{
106110
return infos[index];
107111
}
108112

109-
DataTable::DataIndex DataTable::getIndex(ColumnIndex index) const
113+
DataTableOld::DataIndex DataTableOld::getIndex(
114+
ColumnIndex index) const
110115
{
111116
return {index, infos[index].getType()};
112117
}
113118

114-
ColumnIndex DataTable::getColumn(const std::string &name) const
119+
ColumnIndex DataTableOld::getColumn(const std::string &name) const
115120
{
116121
auto it = indexByName.find(name);
117122
if (it != indexByName.end()) return it->second;
118123
throw std::logic_error("No column name exists: " + name);
119124
}
120125

121-
DataTable::DataIndex DataTable::getIndex(
126+
DataTableOld::DataIndex DataTableOld::getIndex(
122127
const std::string &name) const
123128
{
124129
return getIndex(getColumn(name));
125130
}
126131

127-
size_t DataTable::columnCount() const { return infos.size(); }
132+
size_t DataTableOld::columnCount() const { return infos.size(); }
133+
134+
std::string DataTableOld::getInfos() const
135+
{
136+
return Conv::toJSON(infos);
137+
}
128138

129139
}

0 commit comments

Comments
 (0)