Skip to content

Commit

Permalink
Update DataTable
Browse files Browse the repository at this point in the history
  • Loading branch information
morzhovets committed Jul 15, 2024
1 parent d01fd61 commit fadd6e1
Showing 1 changed file with 106 additions and 9 deletions.
115 changes: 106 additions & 9 deletions include/momo/DataTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace momo:
class DataTraits
class DataTable
class DataTableNative
\**********************************************************/

Expand Down Expand Up @@ -87,6 +88,9 @@ class DataTable
template<typename Item>
using Equality = DataEquality<Column<Item>>;

template<typename... Items>
using Equalities = DataEquality<Column<Items>...>;

template<typename Item, typename ItemArg>
using Assignment = DataAssignment<Column<Item>, ItemArg>;

Expand Down Expand Up @@ -744,44 +748,77 @@ class DataTable
}

template<typename... Items>
ConstSelection Select(Equality<Items>... equals) const
internal::EnableIf<(sizeof...(Items) > 1),
ConstSelection> Select(Equality<Items>... equals) const
{
return pvSelect<Selection>(EmptyRowFilter(), equals...);
}

template<typename RowFilter, typename... Items>
template<typename RowFilter = EmptyRowFilter,
typename... Items>
internal::EnableIf<internal::IsInvocable<const RowFilter&, bool, ConstRowReference>::value,
ConstSelection> Select(const RowFilter& rowFilter, Equality<Items>... equals) const
ConstSelection> Select(const RowFilter& rowFilter = RowFilter(),
Equality<Items>... equals) const
{
return pvSelect<Selection>(rowFilter, equals...);
}

template<typename RowFilter = EmptyRowFilter,
typename... Items>
internal::EnableIf<internal::IsInvocable<const RowFilter&, bool, ConstRowReference>::value,
ConstSelection> Select(Equalities<Items...> equals,
const RowFilter& rowFilter = RowFilter()) const
{
return pvSelect<Selection>(equals, rowFilter);
}

template<typename... Items>
Selection Select(Equality<Items>... equals)
internal::EnableIf<(sizeof...(Items) > 1),
Selection> Select(Equality<Items>... equals)
{
return pvSelect<Selection>(EmptyRowFilter(), equals...);
}

template<typename RowFilter, typename... Items>
template<typename RowFilter = EmptyRowFilter,
typename... Items>
internal::EnableIf<internal::IsInvocable<const RowFilter&, bool, ConstRowReference>::value,
Selection> Select(const RowFilter& rowFilter, Equality<Items>... equals)
Selection> Select(const RowFilter& rowFilter = RowFilter(), Equality<Items>... equals)
{
return pvSelect<Selection>(rowFilter, equals...);
}

template<typename RowFilter = EmptyRowFilter,
typename... Items>
internal::EnableIf<internal::IsInvocable<const RowFilter&, bool, ConstRowReference>::value,
Selection> Select(Equalities<Items...> equals, const RowFilter& rowFilter = RowFilter())
{
return pvSelect<Selection>(equals, rowFilter);
}

template<typename... Items>
size_t SelectCount(Equality<Items>... equals) const
internal::EnableIf<(sizeof...(Items) > 1),
size_t> SelectCount(Equality<Items>... equals) const
{
return pvSelect<size_t>(EmptyRowFilter(), equals...);
}

template<typename RowFilter, typename... Items>
template<typename RowFilter = EmptyRowFilter,
typename... Items>
internal::EnableIf<internal::IsInvocable<const RowFilter&, bool, ConstRowReference>::value,
size_t> SelectCount(const RowFilter& rowFilter, Equality<Items>... equals) const
size_t> SelectCount(const RowFilter& rowFilter = RowFilter(), Equality<Items>... equals) const
{
return pvSelect<size_t>(rowFilter, equals...);
}

template<typename RowFilter = EmptyRowFilter,
typename... Items>
internal::EnableIf<internal::IsInvocable<const RowFilter&, bool, ConstRowReference>::value,
size_t> SelectCount(Equalities<Items...> equals,
const RowFilter& rowFilter = RowFilter()) const
{
return pvSelect<size_t>(equals, rowFilter);
}

ConstRowHashPointer FindByUniqueHash(UniqueHashIndex uniqueHashIndex, const Row& row) const
{
return pvFindByUniqueHash(uniqueHashIndex, row);
Expand All @@ -792,6 +829,20 @@ class DataTable
return pvFindByUniqueHash(uniqueHashIndex, row);
}

template<typename Item, typename... Items>
ConstRowHashPointer FindByUniqueHash(Equalities<Item, Items...> equals,
UniqueHashIndex uniqueHashIndex = UniqueHashIndex::empty) const
{
return pvFindByHash<RowHashPointerProxy>(equals, uniqueHashIndex);
}

template<typename Item, typename... Items>
RowHashPointer FindByUniqueHash(Equalities<Item, Items...> equals,
UniqueHashIndex uniqueHashIndex = UniqueHashIndex::empty)
{
return pvFindByHash<RowHashPointerProxy>(equals, uniqueHashIndex);
}

template<typename Item, typename... Items>
ConstRowHashPointer FindByUniqueHash(UniqueHashIndex uniqueHashIndex, Equality<Item> equal,
Equality<Items>... equals) const
Expand All @@ -806,6 +857,20 @@ class DataTable
return pvFindByHash<RowHashPointerProxy>(uniqueHashIndex, equal, equals...);
}

template<typename Item, typename... Items>
ConstRowHashBounds FindByMultiHash(Equalities<Item, Items...> equals,
MultiHashIndex multiHashIndex = MultiHashIndex::empty) const
{
return pvFindByHash<RowHashBoundsProxy>(equals, multiHashIndex);
}

template<typename Item, typename... Items>
RowHashBounds FindByMultiHash(Equalities<Item, Items...> equals,
MultiHashIndex multiHashIndex = MultiHashIndex::empty)
{
return pvFindByHash<RowHashBoundsProxy>(equals, multiHashIndex);
}

template<typename Item, typename... Items>
ConstRowHashBounds FindByMultiHash(MultiHashIndex multiHashIndex, Equality<Item> equal,
Equality<Items>... equals) const
Expand Down Expand Up @@ -1307,6 +1372,20 @@ class DataTable
VersionKeeper(&mCrew.GetRemoveVersion()));
}

template<typename Result, typename... Items, typename RowFilter>
Result pvSelect(const Equalities<Items...>& equals, const RowFilter& rowFilter) const
{
return pvSelect<Result>(equals, rowFilter,
typename internal::SequenceMaker<sizeof...(Items)>::Sequence());
}

template<typename Result, typename... Items, typename RowFilter, size_t... sequence>
Result pvSelect(const Equalities<Items...>& equals, const RowFilter& rowFilter,
internal::Sequence<sequence...>) const
{
return pvSelect<Result>(rowFilter, equals.template Get<sequence>()...);
}

template<typename Result, typename RowFilter, typename Item, typename... Items,
size_t columnCount = 1 + sizeof...(Items)>
internal::EnableIf<(columnCount > DataTraits::selectEqualityMaxCount),
Expand Down Expand Up @@ -1457,6 +1536,20 @@ class DataTable
return RowHashPointerProxy(columnList, raws, VersionKeeper(&mCrew.GetRemoveVersion()));
}

template<typename RowBoundsProxy, typename... Items, typename Index>
RowBoundsProxy pvFindByHash(const Equalities<Items...>& equals, Index index) const
{
return pvFindByHash<RowBoundsProxy>(equals, index,
typename internal::SequenceMaker<sizeof...(Items)>::Sequence());
}

template<typename RowBoundsProxy, typename... Items, typename Index, size_t... sequence>
RowBoundsProxy pvFindByHash(const Equalities<Items...>& equals, Index index,
internal::Sequence<sequence...>) const
{
return pvFindByHash<RowBoundsProxy>(index, equals.template Get<sequence>()...);
}

template<typename RowBoundsProxy, typename Index, typename... Items,
size_t columnCount = sizeof...(Items)>
RowBoundsProxy pvFindByHash(Index index, const Equality<Items>&... equals) const
Expand Down Expand Up @@ -1527,6 +1620,10 @@ class DataTable
Indexes mIndexes;
};

template<typename TStruct,
typename TDataTraits = DataTraits>
using DataTableNative = DataTable<DataColumnListNative<TStruct>, TDataTraits>;

} // namespace momo

#endif // MOMO_INCLUDE_GUARD_DATA_TABLE

0 comments on commit fadd6e1

Please sign in to comment.