Skip to content

Commit

Permalink
Merge pull request #44 from kspangsege/avoid_all_upper_case_names
Browse files Browse the repository at this point in the history
Avoid all upper case names
  • Loading branch information
astigsen committed Feb 7, 2013
2 parents 5e718e8 + f268759 commit e9b589b
Show file tree
Hide file tree
Showing 34 changed files with 794 additions and 807 deletions.
257 changes: 128 additions & 129 deletions src/tightdb/array.cpp

Large diffs are not rendered by default.

535 changes: 264 additions & 271 deletions src/tightdb/array.hpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/tightdb/array_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace tightdb {


ArrayBinary::ArrayBinary(ArrayParent* parent, size_t pndx, Allocator& alloc):
Array(COLUMN_HASREFS, parent, pndx, alloc),
m_offsets(COLUMN_NORMAL, NULL, 0, alloc), m_blob(NULL, 0, alloc)
Array(coldef_HasRefs, parent, pndx, alloc),
m_offsets(coldef_Normal, NULL, 0, alloc), m_blob(NULL, 0, alloc)
{
// Add subarrays for long string
Array::add(m_offsets.GetRef());
Expand Down
2 changes: 1 addition & 1 deletion src/tightdb/array_blob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ArrayBlob : public Array {
// Implementation:

inline ArrayBlob::ArrayBlob(ArrayParent *parent, std::size_t pndx, Allocator& alloc):
Array(COLUMN_NORMAL, parent, pndx, alloc)
Array(coldef_Normal, parent, pndx, alloc)
{
// Manually set wtype as array constructor in initiatializer list
// will not be able to call correct virtual function
Expand Down
2 changes: 1 addition & 1 deletion src/tightdb/array_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ArrayString : public Array {

inline size_t ArrayString::create_empty_string_array(Allocator& alloc)
{
return create_empty_array(COLUMN_NORMAL, TDB_MULTIPLY, alloc); // Throws
return create_empty_array(coldef_Normal, TDB_MULTIPLY, alloc); // Throws
}

inline ArrayString::ArrayString(ArrayParent *parent, size_t ndx_in_parent,
Expand Down
4 changes: 2 additions & 2 deletions src/tightdb/array_string_long.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
namespace tightdb {

ArrayStringLong::ArrayStringLong(ArrayParent* parent, size_t pndx, Allocator& alloc):
Array(COLUMN_HASREFS, parent, pndx, alloc),
m_offsets(COLUMN_NORMAL, NULL, 0, alloc), m_blob(NULL, 0, alloc)
Array(coldef_HasRefs, parent, pndx, alloc),
m_offsets(coldef_Normal, NULL, 0, alloc), m_blob(NULL, 0, alloc)
{
// Add subarrays for long string
Array::add(m_offsets.GetRef());
Expand Down
6 changes: 3 additions & 3 deletions src/tightdb/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
# define TIGHTDB_STATIC_ASSERT(condition, message) static_assert(condition, message)
#else
# define TIGHTDB_STATIC_ASSERT(condition, message) typedef \
tightdb::static_assert_dummy<sizeof(tightdb::STATIC_ASSERTION_FAILURE<bool(condition)>)> \
tightdb::static_assert_dummy<sizeof(tightdb::TIGHTDB_STATIC_ASSERTION_FAILURE<bool(condition)>)> \
TIGHTDB_JOIN(_tightdb_static_assert_, __LINE__)
# define TIGHTDB_JOIN(x,y) TIGHTDB_JOIN2(x,y)
# define TIGHTDB_JOIN2(x,y) x ## y
namespace tightdb {
template<bool> struct STATIC_ASSERTION_FAILURE;
template<> struct STATIC_ASSERTION_FAILURE<true> {};
template<bool> struct TIGHTDB_STATIC_ASSERTION_FAILURE;
template<> struct TIGHTDB_STATIC_ASSERTION_FAILURE<true> {};
template<int> struct static_assert_dummy {};
}
#endif
Expand Down
30 changes: 15 additions & 15 deletions src/tightdb/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void merge_core_references(Array* vals, Array* idx0, Array* idx1, Array* idxres)
void merge_core(const Array& a0, const Array& a1, Array& res);
Array* merge(const Array& ArrayList);
void merge_references(Array* valuelist, Array* indexlists, Array** indexresult);

// Input:
// vals: An array of values
// idx0: Array of indexes pointing into vals, sorted with respect to vals
Expand Down Expand Up @@ -148,7 +148,7 @@ Array* merge(const Array& arrayList)
{
const size_t size = arrayList.Size();

if (size == 1)
if (size == 1)
return NULL; // already sorted

Array leftHalf, rightHalf;
Expand Down Expand Up @@ -180,9 +180,9 @@ Array* merge(const Array& arrayList)
// Clean-up
leftHalf.Destroy();
rightHalf.Destroy();
if (left)
if (left)
left->Destroy();
if (right)
if (right)
right->Destroy();
delete left;
delete right;
Expand Down Expand Up @@ -264,7 +264,7 @@ bool ColumnBase::is_node_from_ref(size_t ref, Allocator& alloc) TIGHTDB_NOEXCEPT

Column::Column(Allocator& alloc): m_index(0)
{
m_array = new Array(COLUMN_NORMAL, 0, 0, alloc);
m_array = new Array(coldef_Normal, 0, 0, alloc);
Create();
}

Expand Down Expand Up @@ -296,8 +296,8 @@ void Column::Create()
{
// Add subcolumns for nodes
if (IsNode()) {
const Array offsets(COLUMN_NORMAL, 0, 0, m_array->GetAllocator());
const Array refs(COLUMN_HASREFS, 0, 0, m_array->GetAllocator());
const Array offsets(coldef_Normal, 0, 0, m_array->GetAllocator());
const Array refs(coldef_HasRefs, 0, 0, m_array->GetAllocator());
m_array->add(offsets.GetRef());
m_array->add(refs.GetRef());
}
Expand Down Expand Up @@ -353,7 +353,7 @@ void Column::UpdateParentNdx(int diff)
// Used by column b-tree code to ensure all leaf having same type
void Column::SetHasRefs()
{
m_array->SetType(COLUMN_HASREFS);
m_array->SetType(coldef_HasRefs);
}

/*
Expand All @@ -378,7 +378,7 @@ void Column::Clear()
{
m_array->Clear();
if (m_array->IsNode())
m_array->SetType(COLUMN_NORMAL);
m_array->SetType(coldef_Normal);
}

void Column::Set(size_t ndx, int64_t value)
Expand Down Expand Up @@ -434,32 +434,32 @@ void Column::fill(size_t count)

size_t Column::count(int64_t target) const
{
return size_t(aggregate<int64_t, int64_t, TDB_COUNT, EQUAL>(target, 0, Size(), NULL));
return size_t(aggregate<int64_t, int64_t, act_Count, Equal>(target, 0, Size(), NULL));
}

int64_t Column::sum(size_t start, size_t end) const
{
return aggregate<int64_t, int64_t, TDB_SUM, NONE>(0, start, end, NULL);
return aggregate<int64_t, int64_t, act_Sum, None>(0, start, end, NULL);
}

double Column::average(size_t start, size_t end) const
{
if (end == size_t(-1))
end = Size();
size_t size = end - start;
int64_t sum = aggregate<int64_t, int64_t, TDB_SUM, NONE>(0, start, end, NULL);
int64_t sum = aggregate<int64_t, int64_t, act_Sum, None>(0, start, end, NULL);
double avg = double( sum ) / double( size == 0 ? 1 : size );
return avg;
}

int64_t Column::minimum(size_t start, size_t end) const
{
return aggregate<int64_t, int64_t, TDB_MIN, NONE>(0, start, end, NULL);
return aggregate<int64_t, int64_t, act_Min, None>(0, start, end, NULL);
}

int64_t Column::maximum(size_t start, size_t end) const
{
return aggregate<int64_t, int64_t, TDB_MAX, NONE>(0, start, end, NULL);
return aggregate<int64_t, int64_t, act_Max, None>(0, start, end, NULL);
}


Expand Down Expand Up @@ -640,7 +640,7 @@ size_t Column::find_first(int64_t value, size_t start, size_t end) const
return m_array->ColumnFind(value, ref, cache);
}
else {
return TreeFind<int64_t, Column, EQUAL>(value, start, end);
return TreeFind<int64_t, Column, Equal>(value, start, end);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/tightdb/column.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ColumnBase {
static size_t get_size_from_ref(size_t ref, Allocator&) TIGHTDB_NOEXCEPT;
static bool is_node_from_ref(size_t ref, Allocator& alloc) TIGHTDB_NOEXCEPT;

template <typename T, typename R, ACTION action, class condition>
template <typename T, typename R, Action action, class condition>
R aggregate(T target, size_t start, size_t end, size_t *matchcount) const;


Expand All @@ -130,7 +130,7 @@ class Column : public ColumnBase {
public:
explicit Column(Allocator&);
Column(ColumnDef type, Allocator&);
Column(ColumnDef type=COLUMN_NORMAL, ArrayParent* = 0, size_t pndx = 0,
Column(ColumnDef type=coldef_Normal, ArrayParent* = 0, size_t pndx = 0,
Allocator& = Allocator::get_default());
Column(size_t ref, ArrayParent* = 0, size_t pndx = 0,
Allocator& = Allocator::get_default()); // Throws
Expand Down
2 changes: 1 addition & 1 deletion src/tightdb/column_basic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class BasicColumn : public ColumnBase {
virtual void LeafToDot(std::ostream& out, const Array& array) const;
#endif // TIGHTDB_DEBUG

template <typename R, ACTION action, class cond>
template <typename R, Action action, class cond>
R aggregate(T target, size_t start, size_t end, size_t *matchcount = (size_t*)0) const;
};

Expand Down
52 changes: 26 additions & 26 deletions src/tightdb/column_basic_tpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace tightdb {

// Predeclarations from query_engine.hpp
class ParentNode;
template<class T, class F> class BASICNODE;
template<class T, class F> class BasicNode;
template<class T> class SequentialGetter;


Expand All @@ -50,18 +50,18 @@ BasicColumn<T>::BasicColumn(size_t ref, ArrayParent* parent, size_t pndx, Alloca
template<typename T>
BasicColumn<T>::~BasicColumn()
{
if (IsNode())
if (IsNode())
delete m_array;
else
else
delete static_cast<BasicArray<T>*>(m_array);
}

template<typename T>
void BasicColumn<T>::Destroy()
{
if (IsNode())
if (IsNode())
m_array->Destroy();
else
else
static_cast<BasicArray<T>*>(m_array)->Destroy();
}

Expand All @@ -71,7 +71,7 @@ void BasicColumn<T>::UpdateRef(size_t ref)
{
TIGHTDB_ASSERT(is_node_from_ref(ref, m_array->GetAllocator())); // Can only be called when creating node

if (IsNode())
if (IsNode())
m_array->UpdateRef(ref);
else {
ArrayParent* const parent = m_array->GetParent();
Expand All @@ -83,7 +83,7 @@ void BasicColumn<T>::UpdateRef(size_t ref)
m_array = array;

// Update ref in parent
if (parent)
if (parent)
parent->update_child_ref(pndx, ref);
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ void BasicColumn<T>::Clear()

// Revert to generic array
BasicArray<T>* array = new BasicArray<T>(parent, pndx, m_array->GetAllocator());
if (parent)
if (parent)
parent->update_child_ref(pndx, array->GetRef());

// Remove original node
Expand All @@ -131,7 +131,7 @@ void BasicColumn<T>::Clear()

m_array = array;
}
else
else
static_cast<BasicArray<T>*>(m_array)->Clear();
}

Expand Down Expand Up @@ -191,12 +191,12 @@ template<typename T>
bool BasicColumn<T>::Compare(const BasicColumn& c) const
{
const size_t n = Size();
if (c.Size() != n)
if (c.Size() != n)
return false;
for (size_t i=0; i<n; ++i) {
const T v1 = Get(i);
const T v2 = c.Get(i);
if (v1 == v2)
if (v1 == v2)
return false;
}
return true;
Expand Down Expand Up @@ -267,7 +267,7 @@ size_t BasicColumn<T>::find_first(T value, size_t start, size_t end) const
{
TIGHTDB_ASSERT(value);

return TreeFind<T, BasicColumn<T>, EQUAL>(value, start, end);
return TreeFind<T, BasicColumn<T>, Equal>(value, start, end);
}

template<typename T>
Expand All @@ -284,13 +284,13 @@ void BasicColumn<T>::find_all(Array &result, T value, size_t start, size_t end)
template<typename T>
size_t BasicColumn<T>::count(T target) const
{
return size_t(ColumnBase::aggregate<T, int64_t, TDB_COUNT, EQUAL>(target, 0, Size(), NULL));
return size_t(ColumnBase::aggregate<T, int64_t, act_Count, Equal>(target, 0, Size(), NULL));
}

template<typename T>
typename BasicColumn<T>::SumType BasicColumn<T>::sum(size_t start, size_t end) const
{
return ColumnBase::aggregate<T, SumType, TDB_SUM, NONE>(0, start, end, NULL);
return ColumnBase::aggregate<T, SumType, act_Sum, None>(0, start, end, NULL);
}

template<typename T>
Expand All @@ -299,21 +299,21 @@ double BasicColumn<T>::average(size_t start, size_t end) const
if (end == size_t(-1))
end = Size();
size_t size = end - start;
double sum1 = ColumnBase::aggregate<T, SumType, TDB_SUM, NONE>(0, start, end, NULL);
double avg = sum1 / ( size == 0 ? 1 : size );
double sum1 = ColumnBase::aggregate<T, SumType, act_Sum, None>(0, start, end, NULL);
double avg = sum1 / ( size == 0 ? 1 : size );
return avg;
}

template<typename T>
T BasicColumn<T>::minimum(size_t start, size_t end) const
{
return ColumnBase::aggregate<T, T, TDB_MIN, NONE>(0, start, end, NULL);
return ColumnBase::aggregate<T, T, act_Min, None>(0, start, end, NULL);
}

template<typename T>
T BasicColumn<T>::maximum(size_t start, size_t end) const
{
return ColumnBase::aggregate<T, T, TDB_MAX, NONE>(0, start, end, NULL);
return ColumnBase::aggregate<T, T, act_Max, None>(0, start, end, NULL);
}

/*
Expand All @@ -334,15 +334,15 @@ template<typename T>
size_t BasicColumn<T>::count(T target) const
{
size_t count = 0;
if (m_array->IsNode()) {
const Array refs = NodeGetRefs();
const size_t n = refs.Size();
for (size_t i = 0; i < n; ++i) {
const size_t ref = refs.GetAsRef(i);
const BasicColumn<T> col(ref, NULL, 0, m_array->GetAllocator());
count += col.count(target);
}
}
Expand All @@ -359,15 +359,15 @@ T BasicColumn<T>::sum(size_t start, size_t end) const
end = Size();
double sum = 0;
if (m_array->IsNode()) {
const Array refs = NodeGetRefs();
const size_t n = refs.Size();
for (size_t i = start; i < n; ++i) {
const size_t ref = refs.GetAsRef(i);
const BasicColumn<T> col(ref, NULL, 0, m_array->GetAllocator());
sum += col.sum(start, end);
}
}
Expand Down Expand Up @@ -400,7 +400,7 @@ T BasicColumn<T>::minimum(size_t start, size_t end) const
if (m_array->IsNode()) {
const Array refs = NodeGetRefs();
const size_t n = refs.Size();
for (size_t i = start; i < n; ++i) {
const size_t ref = refs.GetAsRef(i);
const BasicColumn<T> col(ref, NULL, 0, m_array->GetAllocator());
Expand Down Expand Up @@ -429,7 +429,7 @@ T BasicColumn<T>::maximum(size_t start, size_t end) const
if (m_array->IsNode()) {
const Array refs = NodeGetRefs();
const size_t n = refs.Size();
for (size_t i = start; i < n; ++i) {
const size_t ref = refs.GetAsRef(i);
const BasicColumn<T> col(ref, NULL, 0, m_array->GetAllocator());
Expand Down
Loading

0 comments on commit e9b589b

Please sign in to comment.