diff --git a/TightDB.vcxproj b/TightDB.vcxproj
index 9c2f3bd5e1e..218ad325767 100644
--- a/TightDB.vcxproj
+++ b/TightDB.vcxproj
@@ -599,6 +599,7 @@
+
diff --git a/TightDB.vcxproj.filters b/TightDB.vcxproj.filters
index c469b739b56..d1266af6e00 100644
--- a/TightDB.vcxproj.filters
+++ b/TightDB.vcxproj.filters
@@ -283,6 +283,9 @@
src\include
+
+ src\include
+
src\include
diff --git a/changelog.txt b/changelog.txt
index 903b8b523e3..387c6d13cff 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -13,6 +13,10 @@ Format:
==================
+2013-02-06 (Kristian Spangsege)
++ New enum DataType replaces ColumnType throughout the public API.
+
+
2013-01-27 (Kristian Spangsege)
+ New Group::Group(unattached_tag) added. Same for SharedGroup.
+ New Group::open(...) methods added. Same for SharedGroup.
@@ -25,6 +29,7 @@ Format:
- Group::set_shared() removed.
- SharedGroup::is_valid() removed. Errors are now reported as exceptions from the constructor.
+
2013-01-11 (Kristian Spangsege)
+ Simplified open-mode for Group constructor.
- Group::is_valid() removed. Errors are now reported as exceptions from the constructor.
@@ -37,10 +42,12 @@ Format:
+ Mixed::set_int() added (same for other value types except subtables).
+ Removed two-argument Mixed constructor for binary data since its signature is expected to be used for strings that are not zero-terminated.
+
2013-01-08 (Brian Munkholm)
----------
+ New: Added a bunch of methods to support two new column types: float and double.
+
2012-12-16 (Kristian Spangsege)
----------
+ my_table[i].foo.get() added for all column types except subtables. This is to avoid having to repeat the explicit column type in cast expressions when the actual value is needed.
diff --git a/doc/Tutorial/dyntable.cpp b/doc/Tutorial/dyntable.cpp
index 044ca39f9e6..ea37a6f1610 100644
--- a/doc/Tutorial/dyntable.cpp
+++ b/doc/Tutorial/dyntable.cpp
@@ -8,7 +8,7 @@ using namespace std;
int main(int argc, char *argv[]) {
Table t;
- t.add_column(COLUMN_TYPE_STRING, "name");
+ t.add_column(type_String, "name");
size_t name_ndx = t.get_column_index("name");
t.add_empty_row();
@@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
t.set_string(name_ndx, 1, "Joe");
// forgot about age
- t.add_column(COLUMN_TYPE_INT, "age");
+ t.add_column(type_Int, "age");
size_t age_ndx = t.get_column_index("age");
t.set_int(age_ndx, 0, 32);
t.set_int(age_ndx, 1, 18);
diff --git a/doc/ref_cpp/data/dyn_table_ref.yaml b/doc/ref_cpp/data/dyn_table_ref.yaml
index 838f741a7af..fbb323501ed 100644
--- a/doc/ref_cpp/data/dyn_table_ref.yaml
+++ b/doc/ref_cpp/data/dyn_table_ref.yaml
@@ -225,7 +225,7 @@ CATEGORIES :
TYPES : size_t
DESCR : The column index.
RETURN:
- TYPES : ColumnType
+ TYPES : DataType
DESCR : The column type.
EXAMPLES:
- CODE : ex_cpp_dyn_table_get_column_type
@@ -354,7 +354,7 @@ CATEGORIES :
const char* get_string(size_t column_ndx, size_t row_ndx) const;
BinaryData get_binary(size_t column_ndx, size_t row_ndx) const;
Mixed get_mixed(size_t column_ndx, size_t row_ndx) const;
- ColumnType get_mixed_type(size_t column_ndx, size_t row_ndx) const
+ DataType get_mixed_type(size_t column_ndx, size_t row_ndx) const
TableRef get_subtable(size_t column_ndx, size_t row_ndx);
ConstTableRef get_subtable(size_t column_ndx, size_t row_ndx) const;
@@ -367,7 +367,7 @@ CATEGORIES :
TYPES : size_t
DESCR : The row index.
RETURN:
- TYPES : [bool, int64_t, time_t, const char*, BinaryData, Mixed, ColumnType]
+ TYPES : [bool, int64_t, time_t, const char*, BinaryData, Mixed, DataType]
DESCR : The value.
EXAMPLES:
- CODE : ex_cpp_dyn_table_get_xxx
diff --git a/doc/ref_cpp/data/dyn_view_ref.yaml b/doc/ref_cpp/data/dyn_view_ref.yaml
index 878cb908662..4ca53f17e2a 100644
--- a/doc/ref_cpp/data/dyn_view_ref.yaml
+++ b/doc/ref_cpp/data/dyn_view_ref.yaml
@@ -186,7 +186,7 @@ CATEGORIES :
const char* get_string(size_t column_ndx, size_t row_ndx) const;
BinaryData get_binary(size_t column_ndx, size_t row_ndx) const;
Mixed get_mixed(size_t column_ndx, size_t row_ndx) const;
- ColumnType get_mixed_type(size_t column_ndx, size_t row_ndx) const
+ DataType get_mixed_type(size_t column_ndx, size_t row_ndx) const
TableRef get_subtable(size_t column_ndx, size_t row_ndx);
ConstTableRef get_subtable(size_t column_ndx, size_t row_ndx) const;
CONST : True
@@ -198,7 +198,7 @@ CATEGORIES :
TYPES : size_t
DESCR : The row index.
RETURN:
- TYPES : [bool, int64_t, time_t, const char*, BinaryData, Mixed, ColumnType, TableRef, ConstTableRef]
+ TYPES : [bool, int64_t, time_t, const char*, BinaryData, Mixed, DataType, TableRef, ConstTableRef]
DESCR : The value.
EXAMPLES:
- CODE : ex_cpp_dyn_view_get_xxx
diff --git a/doc/ref_cpp/data/mixed_ref.yaml b/doc/ref_cpp/data/mixed_ref.yaml
index 50679af1faf..4c6e0219e39 100644
--- a/doc/ref_cpp/data/mixed_ref.yaml
+++ b/doc/ref_cpp/data/mixed_ref.yaml
@@ -56,7 +56,7 @@ CATEGORIES:
This method retrieves the real type of a Mixed variable.
CONST : True
RETURN:
- TYPES : ColumnType
+ TYPES : DataType
DESCR : The type.
EXAMPLES:
- CODE : ex_cpp_mixed_get_type
diff --git a/doc/ref_cpp/data/typed_view_ref.yaml b/doc/ref_cpp/data/typed_view_ref.yaml
index a28912f1087..2ca9808c87c 100644
--- a/doc/ref_cpp/data/typed_view_ref.yaml
+++ b/doc/ref_cpp/data/typed_view_ref.yaml
@@ -128,7 +128,7 @@ CATEGORIES :
const char* get_string(size_t row_ndx) const;
BinaryData get_binary(size_t row_ndx) const;
Mixed get_mixed(size_t row_ndx) const;
- ColumnType get_mixed_type(size_t row_ndx) const
+ DataType get_mixed_type(size_t row_ndx) const
TableRef get_subtable(size_t row_ndx);
ConstTableRef get_subtable(size_t row_ndx) const;
CONST : True
@@ -137,7 +137,7 @@ CATEGORIES :
TYPES : size_t
DESCR : The row index.
RETURN:
- TYPES : [bool, int64_t, time_t, const char*, BinaryData, Mixed, ColumnType, TableRef, ConstTableRef]
+ TYPES : [bool, int64_t, time_t, const char*, BinaryData, Mixed, DataType, TableRef, ConstTableRef]
DESCR : The value.
EXAMPLES:
- CODE : ex_cpp_typed_view_get_xxx
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_avg.cpp b/doc/ref_cpp/examples/ex_query_dynamic_avg.cpp
index 690bbc97a21..e591f6ae079 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_avg.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_avg.cpp
@@ -19,8 +19,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "Name");
- s.add_column(COLUMN_TYPE_INT, "Age");
+ s.add_column(type_String, "Name");
+ s.add_column(type_Int, "Age");
table->update_from_spec();
table->add_empty_row(3);
@@ -44,4 +44,4 @@ int main()
assert(avg == (27 + 44) / 2.0);
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_beginswith.cpp b/doc/ref_cpp/examples/ex_query_dynamic_beginswith.cpp
index 8a72075f665..3409cf3f354 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_beginswith.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_beginswith.cpp
@@ -10,7 +10,7 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "Name");
+ s.add_column(type_String, "Name");
table->update_from_spec();
table->add_empty_row(5);
@@ -41,4 +41,4 @@ int main()
#endif
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_between.cpp b/doc/ref_cpp/examples/ex_query_dynamic_between.cpp
index 199a2b767e3..b07db90f627 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_between.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_between.cpp
@@ -20,8 +20,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
table->update_from_spec();
table->add_empty_row();
@@ -46,4 +46,4 @@ int main()
assert(!strcmp(view.get_string(0, 1), "Peter"));
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_constructor.cpp b/doc/ref_cpp/examples/ex_query_dynamic_constructor.cpp
index 3bacf175f34..15bf9f94e31 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_constructor.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_constructor.cpp
@@ -13,4 +13,4 @@ int main()
Query q = table->where();
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_contains.cpp b/doc/ref_cpp/examples/ex_query_dynamic_contains.cpp
index fe62d029fd2..4d34d4b92eb 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_contains.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_contains.cpp
@@ -10,7 +10,7 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "Name");
+ s.add_column(type_String, "Name");
table->update_from_spec();
table->add_empty_row(5);
@@ -39,4 +39,4 @@ int main()
#endif
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_count.cpp b/doc/ref_cpp/examples/ex_query_dynamic_count.cpp
index 93a26b6cd38..1a550930a28 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_count.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_count.cpp
@@ -34,4 +34,4 @@ int main()
assert(count3 == 1);
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_delete.cpp b/doc/ref_cpp/examples/ex_query_dynamic_delete.cpp
index cb9c177f751..f97b495b09a 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_delete.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_delete.cpp
@@ -20,8 +20,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
table->update_from_spec();
table->add_empty_row();
@@ -48,4 +48,4 @@ int main()
assert(table->size() == 1);
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_endswith.cpp b/doc/ref_cpp/examples/ex_query_dynamic_endswith.cpp
index 03ae8eb0ea2..0be59fd6387 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_endswith.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_endswith.cpp
@@ -10,7 +10,7 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "Name");
+ s.add_column(type_String, "Name");
table->update_from_spec();
table->add_empty_row(5);
@@ -41,4 +41,4 @@ int main()
#endif
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_equal.cpp b/doc/ref_cpp/examples/ex_query_dynamic_equal.cpp
index b8b5ef5549d..a667589ef4f 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_equal.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_equal.cpp
@@ -11,11 +11,11 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
- s.add_column(COLUMN_TYPE_BOOL, "male");
- s.add_column(COLUMN_TYPE_DATE, "hired");
- s.add_column(COLUMN_TYPE_BINARY, "photo");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
+ s.add_column(type_Bool, "male");
+ s.add_column(type_Date, "hired");
+ s.add_column(type_Binary, "photo");
table->update_from_spec();
// @@EndFold@@
@@ -54,4 +54,4 @@ int main()
assert(view5.size() == 1 && !strcmp(view5.get_string(0, 0), "Mary"));
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_find_all.cpp b/doc/ref_cpp/examples/ex_query_dynamic_find_all.cpp
index 54023765405..77e3cde3619 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_find_all.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_find_all.cpp
@@ -20,8 +20,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
table->update_from_spec();
table->add_empty_row();
@@ -54,4 +54,4 @@ int main()
assert(!strcmp(view.get_string(0, 1), "Peter"));
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_find_next.cpp b/doc/ref_cpp/examples/ex_query_dynamic_find_next.cpp
index 3e5a806692e..3ef97e66100 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_find_next.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_find_next.cpp
@@ -20,8 +20,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
table->update_from_spec();
table->add_empty_row();
@@ -53,4 +53,4 @@ int main()
assert(match == size_t(-1));
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_greater.cpp b/doc/ref_cpp/examples/ex_query_dynamic_greater.cpp
index 9833af3ed90..9f660fe99ff 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_greater.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_greater.cpp
@@ -20,8 +20,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
table->update_from_spec();
table->add_empty_row();
@@ -46,4 +46,4 @@ int main()
assert(!strcmp(view.get_string(0, 1), string("Peter")));
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_greater_equal.cpp b/doc/ref_cpp/examples/ex_query_dynamic_greater_equal.cpp
index af9cb7b9d46..b0b997c5f26 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_greater_equal.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_greater_equal.cpp
@@ -20,8 +20,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
table->update_from_spec();
table->add_empty_row();
@@ -46,4 +46,4 @@ int main()
assert(!strcmp(view.get_string(0, 1), "Peter"));
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_group.cpp b/doc/ref_cpp/examples/ex_query_dynamic_group.cpp
index a85fbc7f3cf..8aa1acde4dc 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_group.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_group.cpp
@@ -22,8 +22,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
table->update_from_spec();
table->add_empty_row();
@@ -57,4 +57,4 @@ int main()
assert(!strcmp(view.get_string(0, 2), "Alice"));
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_intro.cpp b/doc/ref_cpp/examples/ex_query_dynamic_intro.cpp
index e17e42b4ce2..27b8218b0d7 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_intro.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_intro.cpp
@@ -20,8 +20,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
table->update_from_spec();
table->add_empty_row();
@@ -45,4 +45,4 @@ int main()
assert(!strcmp(view.get_string(0, 0), "Peter"));
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_less.cpp b/doc/ref_cpp/examples/ex_query_dynamic_less.cpp
index 4a3e2eb1140..889f0e703c8 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_less.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_less.cpp
@@ -20,8 +20,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
table->update_from_spec();
table->add_empty_row();
@@ -45,4 +45,4 @@ int main()
assert(!strcmp(view.get_string(0, 0), "Alice"));
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_less_equal.cpp b/doc/ref_cpp/examples/ex_query_dynamic_less_equal.cpp
index bb026f6e683..6327f348afc 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_less_equal.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_less_equal.cpp
@@ -20,8 +20,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
table->update_from_spec();
table->add_empty_row();
@@ -46,4 +46,4 @@ int main()
assert(!strcmp(view.get_string(0, 1), "Peter"));
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_max.cpp b/doc/ref_cpp/examples/ex_query_dynamic_max.cpp
index a5015ad8871..1e858ac506a 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_max.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_max.cpp
@@ -19,8 +19,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "Name");
- s.add_column(COLUMN_TYPE_INT, "Age");
+ s.add_column(type_String, "Name");
+ s.add_column(type_Int, "Age");
table->update_from_spec();
table->add_empty_row();
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_min.cpp b/doc/ref_cpp/examples/ex_query_dynamic_min.cpp
index 50b9a997db3..9f4e24fd25c 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_min.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_min.cpp
@@ -19,8 +19,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "Name");
- s.add_column(COLUMN_TYPE_INT, "Age");
+ s.add_column(type_String, "Name");
+ s.add_column(type_Int, "Age");
table->update_from_spec();
table->add_empty_row();
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_not_equal.cpp b/doc/ref_cpp/examples/ex_query_dynamic_not_equal.cpp
index d6cb52b9801..870dda54a71 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_not_equal.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_not_equal.cpp
@@ -19,8 +19,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
table->update_from_spec();
table->add_empty_row();
@@ -43,4 +43,4 @@ int main()
assert(!strcmp(view.get_string(0, 0), "Alice"));
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_or.cpp b/doc/ref_cpp/examples/ex_query_dynamic_or.cpp
index a3e4122bc09..649b3818f9b 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_or.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_or.cpp
@@ -22,8 +22,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "name");
- s.add_column(COLUMN_TYPE_INT, "age");
+ s.add_column(type_String, "name");
+ s.add_column(type_Int, "age");
table->update_from_spec();
table->add_empty_row(4);
@@ -49,4 +49,4 @@ int main()
assert(!strcmp(view.get_string(0, 1), "Jack"));
// @@EndShow@@
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_dynamic_sum.cpp b/doc/ref_cpp/examples/ex_query_dynamic_sum.cpp
index efffb8ec6ce..5ec432fc364 100644
--- a/doc/ref_cpp/examples/ex_query_dynamic_sum.cpp
+++ b/doc/ref_cpp/examples/ex_query_dynamic_sum.cpp
@@ -19,8 +19,8 @@ int main()
TableRef table = group.get_table("test");
Spec& s = table->get_spec();
- s.add_column(COLUMN_TYPE_STRING, "Name");
- s.add_column(COLUMN_TYPE_INT, "Age");
+ s.add_column(type_String, "Name");
+ s.add_column(type_Int, "Age");
table->update_from_spec();
table->add_empty_row();
diff --git a/doc/ref_cpp/examples/ex_query_typed_avg.cpp b/doc/ref_cpp/examples/ex_query_typed_avg.cpp
index 1395d943f35..d364361135a 100644
--- a/doc/ref_cpp/examples/ex_query_typed_avg.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_avg.cpp
@@ -32,4 +32,4 @@ int main()
assert(avg2 == (60.0 + 70.0) / 2.0);
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_beginswith.cpp b/doc/ref_cpp/examples/ex_query_typed_beginswith.cpp
index 1a1da3b1320..8adbc2d23c2 100644
--- a/doc/ref_cpp/examples/ex_query_typed_beginswith.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_beginswith.cpp
@@ -37,4 +37,4 @@ int main()
// @@Fold@@
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_between.cpp b/doc/ref_cpp/examples/ex_query_typed_between.cpp
index df93ca10383..a1a8e0fa98f 100644
--- a/doc/ref_cpp/examples/ex_query_typed_between.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_between.cpp
@@ -33,4 +33,4 @@ int main()
assert(view5.size() == 1 && !strcmp(view5[0].name, "Jack"));
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_constructor.cpp b/doc/ref_cpp/examples/ex_query_typed_constructor.cpp
index f881a9d1523..287e5fc0ebe 100644
--- a/doc/ref_cpp/examples/ex_query_typed_constructor.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_constructor.cpp
@@ -19,4 +19,4 @@ void main()
// Expected result
assert(query.count() == 3);
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_count.cpp b/doc/ref_cpp/examples/ex_query_typed_count.cpp
index 4eeedc4501b..dcb9650988d 100644
--- a/doc/ref_cpp/examples/ex_query_typed_count.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_count.cpp
@@ -35,4 +35,4 @@ int main()
// @@Fold@@
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_equal.cpp b/doc/ref_cpp/examples/ex_query_typed_equal.cpp
index 1fa4e897003..560afc580c9 100644
--- a/doc/ref_cpp/examples/ex_query_typed_equal.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_equal.cpp
@@ -54,4 +54,4 @@ int main()
// assert(view6.size() == 1 && view6[0].name == "Bob");
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_find_all.cpp b/doc/ref_cpp/examples/ex_query_typed_find_all.cpp
index 257d46aeec0..df9cd7e51fb 100644
--- a/doc/ref_cpp/examples/ex_query_typed_find_all.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_find_all.cpp
@@ -61,4 +61,4 @@ int main()
assert(view4[1].name == "Peter");
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_find_next.cpp b/doc/ref_cpp/examples/ex_query_typed_find_next.cpp
index 19841fcbb73..98cf466239d 100644
--- a/doc/ref_cpp/examples/ex_query_typed_find_next.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_find_next.cpp
@@ -36,4 +36,4 @@ int main()
// @@Fold@@
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_greater.cpp b/doc/ref_cpp/examples/ex_query_typed_greater.cpp
index 5d0c79860f8..335fb1f102c 100644
--- a/doc/ref_cpp/examples/ex_query_typed_greater.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_greater.cpp
@@ -24,4 +24,4 @@ int main()
assert(!strcmp(view1[1].name, "Jack"));
}
// @@EndExample@@
-// @@EndFold@@
\ No newline at end of file
+// @@EndFold@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_greater_equal.cpp b/doc/ref_cpp/examples/ex_query_typed_greater_equal.cpp
index bcebca08cd2..8c644d7682e 100644
--- a/doc/ref_cpp/examples/ex_query_typed_greater_equal.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_greater_equal.cpp
@@ -24,4 +24,4 @@ int main()
assert(!strcmp(view1[1].name, "Jack"));
}
// @@EndExample@@
-// @@EndFold@@
\ No newline at end of file
+// @@EndFold@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_group.cpp b/doc/ref_cpp/examples/ex_query_typed_group.cpp
index 218119b09cb..6f55a945cc3 100644
--- a/doc/ref_cpp/examples/ex_query_typed_group.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_group.cpp
@@ -34,4 +34,4 @@ void main()
assert(!strcmp(view[2].name, "Alice"));
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_intro.cpp b/doc/ref_cpp/examples/ex_query_typed_intro.cpp
index fa1b812a864..40028afd14e 100644
--- a/doc/ref_cpp/examples/ex_query_typed_intro.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_intro.cpp
@@ -22,4 +22,4 @@ void main()
assert(!strcmp(view1[0].name, "Mary"));
assert(!strcmp(view1[1].name, "Joe"));
}
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_less.cpp b/doc/ref_cpp/examples/ex_query_typed_less.cpp
index ff2ad9e1642..cbd8bae7fb2 100644
--- a/doc/ref_cpp/examples/ex_query_typed_less.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_less.cpp
@@ -23,4 +23,4 @@ int main()
assert(!strcmp(view1[0].name, "Mary"));
}
// @@Fold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_max.cpp b/doc/ref_cpp/examples/ex_query_typed_max.cpp
index 2fbe5b9a415..d3494158c93 100644
--- a/doc/ref_cpp/examples/ex_query_typed_max.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_max.cpp
@@ -29,4 +29,4 @@ void main()
assert(weight == 40);
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_min.cpp b/doc/ref_cpp/examples/ex_query_typed_min.cpp
index 0644f78e4f7..0b159d27dfe 100644
--- a/doc/ref_cpp/examples/ex_query_typed_min.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_min.cpp
@@ -31,4 +31,4 @@ void main()
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_not_equal.cpp b/doc/ref_cpp/examples/ex_query_typed_not_equal.cpp
index 48e9fc74dc1..207fce75e78 100644
--- a/doc/ref_cpp/examples/ex_query_typed_not_equal.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_not_equal.cpp
@@ -27,4 +27,4 @@ int main()
assert(view2.size() == 1 && !strcmp(view2[0].name, "Mary"));
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_or.cpp b/doc/ref_cpp/examples/ex_query_typed_or.cpp
index 8569acd8565..340c8a4ac29 100644
--- a/doc/ref_cpp/examples/ex_query_typed_or.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_or.cpp
@@ -26,4 +26,4 @@ int main()
assert(!strcmp(view[1].name, "Joe"));
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/doc/ref_cpp/examples/ex_query_typed_sum.cpp b/doc/ref_cpp/examples/ex_query_typed_sum.cpp
index c639c667373..b7bea00c313 100644
--- a/doc/ref_cpp/examples/ex_query_typed_sum.cpp
+++ b/doc/ref_cpp/examples/ex_query_typed_sum.cpp
@@ -25,4 +25,4 @@ int main()
assert(weight == 75);
}
// @@EndFold@@
-// @@EndExample@@
\ No newline at end of file
+// @@EndExample@@
diff --git a/src/tightdb/Makefile b/src/tightdb/Makefile
index 00541d07b79..32d3ba2779d 100644
--- a/src/tightdb/Makefile
+++ b/src/tightdb/Makefile
@@ -4,10 +4,10 @@ GENERATED_SOURCES = $(TABLE_MACROS_HPP)
INST_HEADERS = config.h meta.hpp assert.hpp exceptions.hpp terminate.hpp type_list.hpp tuple.hpp \
safe_int_ops.hpp unique_ptr.hpp bind_ptr.hpp string_buffer.hpp file.hpp pthread_helpers.hpp \
-utf8.hpp utilities.hpp alloc.hpp alloc_slab.hpp array.hpp array_string.hpp column_type.hpp \
-column_fwd.hpp column.hpp column_tpl.hpp spec.hpp date.hpp binary_data.hpp mixed.hpp table.hpp \
-table_ref.hpp table_basic_fwd.hpp table_accessors.hpp table_basic.hpp table_view.hpp \
-table_view_basic.hpp $(TABLE_MACROS_HPP) group.hpp group_shared.hpp query.hpp \
+utf8.hpp utilities.hpp alloc.hpp alloc_slab.hpp array.hpp array_string.hpp data_type.hpp \
+column_type.hpp column_fwd.hpp column.hpp column_tpl.hpp spec.hpp date.hpp binary_data.hpp \
+mixed.hpp table.hpp table_ref.hpp table_basic_fwd.hpp table_accessors.hpp table_basic.hpp \
+table_view.hpp table_view_basic.hpp $(TABLE_MACROS_HPP) group.hpp group_shared.hpp query.hpp \
query_conditions.hpp lang_bind_helper.hpp tightdb_nmmintrin.h replication.hpp
lib_LIBRARIES = libtightdb.a
diff --git a/src/tightdb/column_mixed.cpp b/src/tightdb/column_mixed.cpp
index 815aaf180c0..344f54496e4 100644
--- a/src/tightdb/column_mixed.cpp
+++ b/src/tightdb/column_mixed.cpp
@@ -142,18 +142,18 @@ void ColumnMixed::Clear()
{
m_types->Clear();
m_refs->Clear();
- if (m_data)
+ if (m_data)
m_data->Clear();
}
-ColumnType ColumnMixed::GetType(size_t ndx) const TIGHTDB_NOEXCEPT
+DataType ColumnMixed::get_type(size_t ndx) const TIGHTDB_NOEXCEPT
{
TIGHTDB_ASSERT(ndx < m_types->Size());
MixedColType coltype = static_cast(m_types->Get(ndx));
switch (coltype) {
- case MIXED_COL_INT_NEG: return COLUMN_TYPE_INT;
- case MIXED_COL_DOUBLE_NEG: return COLUMN_TYPE_DOUBLE;
- default: return static_cast(coltype); // all others must be in sync with ColumnType
+ case MIXED_COL_INT_NEG: return type_Int;
+ case MIXED_COL_DOUBLE_NEG: return type_Double;
+ default: return static_cast(coltype); // all others must be in sync with ColumnType
}
}
@@ -168,7 +168,7 @@ void ColumnMixed::fill(size_t count)
m_types->Insert(i, MIXED_COL_INT);
}
for (size_t i = 0; i < count; ++i) {
- m_refs->Insert(i, 1); // 1 is zero shifted one and low bit set;
+ m_refs->Insert(i, 1); // 1 is zero shifted one and low bit set;
}
#ifdef TIGHTDB_DEBUG
@@ -247,50 +247,51 @@ void ColumnMixed::set_binary(size_t ndx, const char* value, size_t len)
bool ColumnMixed::Compare(const ColumnMixed& c) const
{
const size_t n = Size();
- if (c.Size() != n)
+ if (c.Size() != n)
return false;
-
+
for (size_t i=0; iget_table_ref();
ConstTableRef t2 = c.get_subtable_ptr(i)->get_table_ref();
- if (*t1 != *t2)
+ if (*t1 != *t2)
return false;
}
break;
- default:
+ case type_Mixed:
TIGHTDB_ASSERT(false);
+ break;
}
}
return true;
diff --git a/src/tightdb/column_mixed.hpp b/src/tightdb/column_mixed.hpp
index b066793a015..c2efd956c3c 100644
--- a/src/tightdb/column_mixed.hpp
+++ b/src/tightdb/column_mixed.hpp
@@ -72,7 +72,7 @@ class ColumnMixed : public ColumnBase {
void SetParent(ArrayParent* parent, size_t pndx);
void UpdateFromParent();
- ColumnType GetType(size_t ndx) const TIGHTDB_NOEXCEPT;
+ DataType get_type(size_t ndx) const TIGHTDB_NOEXCEPT;
size_t Size() const TIGHTDB_NOEXCEPT TIGHTDB_OVERRIDE { return m_types->Size(); }
bool is_empty() const TIGHTDB_NOEXCEPT { return m_types->is_empty(); }
@@ -119,7 +119,7 @@ class ColumnMixed : public ColumnBase {
// Indexing
bool HasIndex() const {return false;}
- void BuildIndex(Index& index) {(void)index;}
+ void BuildIndex(Index& index) { static_cast(index); }
void ClearIndex() {}
size_t GetRef() const {return m_array->GetRef();}
@@ -163,7 +163,7 @@ class ColumnMixed : public ColumnBase {
};
void clear_value(size_t ndx, MixedColType newtype);
-
+
// Get/set/insert 64-bit values in m_refs/m_types
int64_t get_value(size_t ndx) const;
void set_value(size_t ndx, int64_t value, MixedColType coltype);
@@ -179,10 +179,10 @@ class ColumnMixed : public ColumnBase {
// (By having a type for both positive numbers, and another type for negative numbers)
Column* m_types;
- // Bit 0 is used to indicate if it's a reference.
+ // Bit 0 is used to indicate if it's a reference.
// If not, the data value is stored (shifted 1 bit left). And the sign bit is stored in m_types.
- RefsColumn* m_refs;
-
+ RefsColumn* m_refs;
+
// m_data holds any Binary/String data - if needed.
ColumnBinary* m_data;
};
diff --git a/src/tightdb/column_mixed_tpl.hpp b/src/tightdb/column_mixed_tpl.hpp
index 63ee15800a1..1056e270842 100644
--- a/src/tightdb/column_mixed_tpl.hpp
+++ b/src/tightdb/column_mixed_tpl.hpp
@@ -44,7 +44,7 @@ inline size_t ColumnMixed::get_subtable_size(size_t row_idx) const TIGHTDB_NOEXC
// size from it. Maybe it is faster in general to check for the
// the presence of the cached object and use it when available.
TIGHTDB_ASSERT(row_idx < m_types->Size());
- if (m_types->Get(row_idx) != COLUMN_TYPE_TABLE) return 0;
+ if (m_types->Get(row_idx) != type_Table) return 0;
const size_t top_ref = m_refs->GetAsRef(row_idx);
const size_t columns_ref = Array(top_ref, 0, 0, m_refs->GetAllocator()).GetAsRef(1);
const Array columns(columns_ref, 0, 0, m_refs->GetAllocator());
@@ -56,7 +56,7 @@ inline size_t ColumnMixed::get_subtable_size(size_t row_idx) const TIGHTDB_NOEXC
inline Table* ColumnMixed::get_subtable_ptr(size_t row_idx) const
{
TIGHTDB_ASSERT(row_idx < m_types->Size());
- if (m_types->Get(row_idx) != COLUMN_TYPE_TABLE)
+ if (m_types->Get(row_idx) != type_Table)
return 0;
return m_refs->get_subtable_ptr(row_idx);
}
diff --git a/src/tightdb/column_type.hpp b/src/tightdb/column_type.hpp
index ace9d409c39..dde73aaeb5f 100644
--- a/src/tightdb/column_type.hpp
+++ b/src/tightdb/column_type.hpp
@@ -22,41 +22,27 @@
namespace tightdb {
-// Note: tightdb_objc/Deliv/ColumnType.h must be kept in sync with his file.
-// Note: tightdb_java2/src/main/java/ColumnType.java must be kept in sync with his file.
-
-// FIXME: The namespace of all-upper-case names must be considered
-// reserved for macros. Consider renaming 'COLUMN_TYPE_INT' to
-// 'type_Int', COLUMN_TYPE_STRING_ENUM to 'type_StringEnum', and so
-// forth. That is, a qualifying prefix followed by the enumeration
-// name in CamelCase. This is a reasonably common naming scheme for
-// enumeration values. Note that I am also suggesting that we drop
-// 'column' from the names, since these types a used much more
-// generally than as just 'column types'.
-//
-// Note: must be kept in sync with his file.
-// Note: must be kept in sync with his file.
-// Note: "com/tightdb/ColumnType.java" must be kept in sync with his file.
+// Note: Value assignments must be kept in sync with
enum ColumnType {
// Column types
- COLUMN_TYPE_INT = 0,
- COLUMN_TYPE_BOOL = 1,
- COLUMN_TYPE_STRING = 2,
- COLUMN_TYPE_STRING_ENUM = 3, // double refs
- COLUMN_TYPE_BINARY = 4,
- COLUMN_TYPE_TABLE = 5,
- COLUMN_TYPE_MIXED = 6,
- COLUMN_TYPE_DATE = 7,
- COLUMN_TYPE_RESERVED1 = 8, // DateTime
- COLUMN_TYPE_FLOAT = 9, // Float
- COLUMN_TYPE_DOUBLE = 10, // Double
- COLUMN_TYPE_RESERVED4 = 11, // Decimal
+ col_type_Int = 0,
+ col_type_Bool = 1,
+ col_type_String = 2,
+ col_type_StringEnum = 3, // double refs
+ col_type_Binary = 4,
+ col_type_Table = 5,
+ col_type_Mixed = 6,
+ col_type_Date = 7,
+ col_type_Reserved1 = 8, // DateTime
+ col_type_Float = 9,
+ col_type_Double = 10,
+ col_type_Reserved4 = 11, // Decimal
// Attributes
- COLUMN_ATTR_INDEXED = 100,
- COLUMN_ATTR_UNIQUE = 101,
- COLUMN_ATTR_SORTED = 102,
- COLUMN_ATTR_NONE = 103
+ col_attr_Indexed = 100,
+ col_attr_Unique = 101,
+ col_attr_Sorted = 102,
+ col_attr_None = 103
};
diff --git a/src/tightdb/data_type.hpp b/src/tightdb/data_type.hpp
new file mode 100644
index 00000000000..fe2bd730873
--- /dev/null
+++ b/src/tightdb/data_type.hpp
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * TIGHTDB CONFIDENTIAL
+ * __________________
+ *
+ * [2011] - [2012] TightDB Inc
+ * All Rights Reserved.
+ *
+ * NOTICE: All information contained herein is, and remains
+ * the property of TightDB Incorporated and its suppliers,
+ * if any. The intellectual and technical concepts contained
+ * herein are proprietary to TightDB Incorporated
+ * and its suppliers and may be covered by U.S. and Foreign Patents,
+ * patents in process, and are protected by trade secret or copyright law.
+ * Dissemination of this information or reproduction of this material
+ * is strictly forbidden unless prior written permission is obtained
+ * from TightDB Incorporated.
+ *
+ **************************************************************************/
+#ifndef TIGHTDB_DATA_TYPE_HPP
+#define TIGHTDB_DATA_TYPE_HPP
+
+namespace tightdb {
+
+// Note: Value assignments must be kept in sync with
+// Note: Value assignments must be kept in sync with
+// Note: Value assignments must be kept in sync with
+// Note: Value assignments must be kept in sync with "com/tightdb/ColumnType.java"
+enum DataType {
+ type_Int = 0,
+ type_Bool = 1,
+ type_Date = 7,
+ type_Float = 9,
+ type_Double = 10,
+ type_String = 2,
+ type_Binary = 4,
+ type_Table = 5,
+ type_Mixed = 6
+};
+
+
+} // namespace tightdb
+
+#endif // TIGHTDB_DATA_TYPE_HPP
diff --git a/src/tightdb/mixed.hpp b/src/tightdb/mixed.hpp
index 0edef683f75..f0459c37726 100644
--- a/src/tightdb/mixed.hpp
+++ b/src/tightdb/mixed.hpp
@@ -27,7 +27,7 @@
#include
#include
-#include
+#include
#include
#include
@@ -47,9 +47,9 @@ class Mixed {
Mixed(Date) TIGHTDB_NOEXCEPT;
struct subtable_tag {};
- Mixed(subtable_tag) TIGHTDB_NOEXCEPT: m_type(COLUMN_TYPE_TABLE) {}
+ Mixed(subtable_tag) TIGHTDB_NOEXCEPT: m_type(type_Table) {}
- ColumnType get_type() const TIGHTDB_NOEXCEPT { return m_type; }
+ DataType get_type() const TIGHTDB_NOEXCEPT { return m_type; }
bool get_bool() const TIGHTDB_NOEXCEPT;
int64_t get_int() const TIGHTDB_NOEXCEPT;
@@ -72,7 +72,7 @@ class Mixed {
friend std::basic_ostream& operator<<(std::basic_ostream&, const Mixed&);
private:
- ColumnType m_type;
+ DataType m_type;
union {
int64_t m_int;
bool m_bool;
@@ -85,7 +85,7 @@ class Mixed {
};
// Note: We cannot compare two mixed values, since when the type of
-// both is COLUMN_TYPE_TABLE, we would have to compare the two tables,
+// both is type_Table, we would have to compare the two tables,
// but the mixed values do not provide access to those tables.
// Note: The mixed values are specified as Wrap. If they were
@@ -146,122 +146,122 @@ bool operator!=(Date, Wrap) TIGHTDB_NOEXCEPT;
inline Mixed::Mixed() TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_INT;
+ m_type = type_Int;
m_int = 0;
}
inline Mixed::Mixed(bool v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_BOOL;
+ m_type = type_Bool;
m_bool = v;
}
inline Mixed::Mixed(int64_t v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_INT;
+ m_type = type_Int;
m_int = v;
}
inline Mixed::Mixed(float v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_FLOAT;
+ m_type = type_Float;
m_float = v;
}
inline Mixed::Mixed(double v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_DOUBLE;
+ m_type = type_Double;
m_double = v;
}
inline Mixed::Mixed(const char* v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_STRING;
+ m_type = type_String;
m_str = v;
}
inline Mixed::Mixed(BinaryData v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_BINARY;
+ m_type = type_Binary;
m_str = v.pointer;
m_len = v.len;
}
inline Mixed::Mixed(Date v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_DATE;
+ m_type = type_Date;
m_date = v.get_date();
}
inline bool Mixed::get_bool() const TIGHTDB_NOEXCEPT
{
- TIGHTDB_ASSERT(m_type == COLUMN_TYPE_BOOL);
+ TIGHTDB_ASSERT(m_type == type_Bool);
return m_bool;
}
inline int64_t Mixed::get_int() const TIGHTDB_NOEXCEPT
{
- TIGHTDB_ASSERT(m_type == COLUMN_TYPE_INT);
+ TIGHTDB_ASSERT(m_type == type_Int);
return m_int;
}
inline float Mixed::get_float() const TIGHTDB_NOEXCEPT
{
- TIGHTDB_ASSERT(m_type == COLUMN_TYPE_FLOAT);
+ TIGHTDB_ASSERT(m_type == type_Float);
return m_float;
}
inline double Mixed::get_double() const TIGHTDB_NOEXCEPT
{
- TIGHTDB_ASSERT(m_type == COLUMN_TYPE_DOUBLE);
+ TIGHTDB_ASSERT(m_type == type_Double);
return m_double;
}
inline const char* Mixed::get_string() const TIGHTDB_NOEXCEPT
{
- TIGHTDB_ASSERT(m_type == COLUMN_TYPE_STRING);
+ TIGHTDB_ASSERT(m_type == type_String);
return m_str;
}
inline BinaryData Mixed::get_binary() const TIGHTDB_NOEXCEPT
{
- TIGHTDB_ASSERT(m_type == COLUMN_TYPE_BINARY);
+ TIGHTDB_ASSERT(m_type == type_Binary);
return BinaryData(m_str, m_len);
}
inline std::time_t Mixed::get_date() const TIGHTDB_NOEXCEPT
{
- TIGHTDB_ASSERT(m_type == COLUMN_TYPE_DATE);
+ TIGHTDB_ASSERT(m_type == type_Date);
return m_date;
}
inline void Mixed::set_bool(bool v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_BOOL;
+ m_type = type_Bool;
m_bool = v;
}
inline void Mixed::set_int(int64_t v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_INT;
+ m_type = type_Int;
m_int = v;
}
inline void Mixed::set_float(float v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_FLOAT;
+ m_type = type_Float;
m_float = v;
}
inline void Mixed::set_double(double v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_DOUBLE;
+ m_type = type_Double;
m_double = v;
}
inline void Mixed::set_string(const char* v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_STRING;
+ m_type = type_String;
m_str = v;
}
@@ -272,14 +272,14 @@ inline void Mixed::set_binary(BinaryData v) TIGHTDB_NOEXCEPT
inline void Mixed::set_binary(const char* data, std::size_t size) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_BINARY;
+ m_type = type_Binary;
m_str = data;
m_len = size;
}
inline void Mixed::set_date(std::time_t v) TIGHTDB_NOEXCEPT
{
- m_type = COLUMN_TYPE_DATE;
+ m_type = type_Date;
m_date = v;
}
@@ -289,41 +289,41 @@ inline std::basic_ostream& operator<<(std::basic_ostream& out, c
{
out << "Mixed(";
switch (m.m_type) {
- case COLUMN_TYPE_BOOL: out << m.m_bool; break;
- case COLUMN_TYPE_INT: out << m.m_int; break;
- case COLUMN_TYPE_STRING: out << m.m_str; break;
- case COLUMN_TYPE_FLOAT: out << m.m_float; break;
- case COLUMN_TYPE_DOUBLE: out << m.m_double; break;
- case COLUMN_TYPE_BINARY: out << BinaryData(m.m_str, m.m_len); break;
- case COLUMN_TYPE_DATE: out << Date(m.m_date); break;
- case COLUMN_TYPE_TABLE: out << "subtable"; break;
- default: TIGHTDB_ASSERT(false); break;
+ case type_Bool: out << m.m_bool; break;
+ case type_Int: out << m.m_int; break;
+ case type_String: out << m.m_str; break;
+ case type_Float: out << m.m_float; break;
+ case type_Double: out << m.m_double; break;
+ case type_Binary: out << BinaryData(m.m_str, m.m_len); break;
+ case type_Date: out << Date(m.m_date); break;
+ case type_Table: out << "subtable"; break;
+ default: TIGHTDB_ASSERT(false); break; // FIXME: Remove
}
out << ")";
return out;
-}
-
+}
+
// Compare mixed with boolean
inline bool operator==(Wrap a, bool b) TIGHTDB_NOEXCEPT
{
- return Mixed(a).get_type() == COLUMN_TYPE_BOOL && Mixed(a).get_bool() == b;
+ return Mixed(a).get_type() == type_Bool && Mixed(a).get_bool() == b;
}
inline bool operator!=(Wrap a, bool b) TIGHTDB_NOEXCEPT
{
- return Mixed(a).get_type() == COLUMN_TYPE_BOOL && Mixed(a).get_bool() != b;
+ return Mixed(a).get_type() == type_Bool && Mixed(a).get_bool() != b;
}
inline bool operator==(bool a, Wrap b) TIGHTDB_NOEXCEPT
{
- return Mixed(b).get_type() == COLUMN_TYPE_BOOL && a == Mixed(b).get_bool();
+ return Mixed(b).get_type() == type_Bool && a == Mixed(b).get_bool();
}
inline bool operator!=(bool a, Wrap b) TIGHTDB_NOEXCEPT
{
- return Mixed(b).get_type() == COLUMN_TYPE_BOOL && a != Mixed(b).get_bool();
+ return Mixed(b).get_type() == type_Bool && a != Mixed(b).get_bool();
}
@@ -331,22 +331,22 @@ inline bool operator!=(bool a, Wrap b) TIGHTDB_NOEXCEPT
template inline bool operator==(Wrap a, const T& b) TIGHTDB_NOEXCEPT
{
- return Mixed(a).get_type() == COLUMN_TYPE_INT && Mixed(a).get_int() == b;
+ return Mixed(a).get_type() == type_Int && Mixed(a).get_int() == b;
}
template inline bool operator!=(Wrap a, const T& b) TIGHTDB_NOEXCEPT
{
- return Mixed(a).get_type() == COLUMN_TYPE_INT && Mixed(a).get_int() != b;
+ return Mixed(a).get_type() == type_Int && Mixed(a).get_int() != b;
}
template inline bool operator==(const T& a, Wrap b) TIGHTDB_NOEXCEPT
{
- return Mixed(b).get_type() == COLUMN_TYPE_INT && a == Mixed(b).get_int();
+ return Mixed(b).get_type() == type_Int && a == Mixed(b).get_int();
}
template inline bool operator!=(const T& a, Wrap b) TIGHTDB_NOEXCEPT
{
- return Mixed(b).get_type() == COLUMN_TYPE_INT && a != Mixed(b).get_int();
+ return Mixed(b).get_type() == type_Int && a != Mixed(b).get_int();
}
@@ -354,22 +354,22 @@ template inline bool operator!=(const T& a, Wrap b) TIGHTDB_NOEX
inline bool operator==(Wrap a, float b)
{
- return Mixed(a).get_type() == COLUMN_TYPE_FLOAT && Mixed(a).get_float() == b;
+ return Mixed(a).get_type() == type_Float && Mixed(a).get_float() == b;
}
inline bool operator!=(Wrap a, float b)
{
- return Mixed(a).get_type() == COLUMN_TYPE_FLOAT && Mixed(a).get_float() != b;
+ return Mixed(a).get_type() == type_Float && Mixed(a).get_float() != b;
}
inline bool operator==(float a, Wrap b)
{
- return Mixed(b).get_type() == COLUMN_TYPE_FLOAT && a == Mixed(b).get_float();
+ return Mixed(b).get_type() == type_Float && a == Mixed(b).get_float();
}
inline bool operator!=(float a, Wrap b)
{
- return Mixed(b).get_type() == COLUMN_TYPE_FLOAT && a != Mixed(b).get_float();
+ return Mixed(b).get_type() == type_Float && a != Mixed(b).get_float();
}
@@ -377,22 +377,22 @@ inline bool operator!=(float a, Wrap b)
inline bool operator==(Wrap a, double b)
{
- return Mixed(a).get_type() == COLUMN_TYPE_DOUBLE && Mixed(a).get_double() == b;
+ return Mixed(a).get_type() == type_Double && Mixed(a).get_double() == b;
}
inline bool operator!=(Wrap a, double b)
{
- return Mixed(a).get_type() == COLUMN_TYPE_DOUBLE && Mixed(a).get_double() != b;
+ return Mixed(a).get_type() == type_Double && Mixed(a).get_double() != b;
}
inline bool operator==(double a, Wrap b)
{
- return Mixed(b).get_type() == COLUMN_TYPE_DOUBLE && a == Mixed(b).get_double();
+ return Mixed(b).get_type() == type_Double && a == Mixed(b).get_double();
}
inline bool operator!=(double a, Wrap b)
{
- return Mixed(b).get_type() == COLUMN_TYPE_DOUBLE && a != Mixed(b).get_double();
+ return Mixed(b).get_type() == type_Double && a != Mixed(b).get_double();
}
@@ -400,42 +400,42 @@ inline bool operator!=(double a, Wrap b)
inline bool operator==(Wrap a, const char* b) TIGHTDB_NOEXCEPT
{
- return Mixed(a).get_type() == COLUMN_TYPE_STRING && std::strcmp(Mixed(a).get_string(), b) == 0;
+ return Mixed(a).get_type() == type_String && std::strcmp(Mixed(a).get_string(), b) == 0;
}
inline bool operator!=(Wrap a, const char* b) TIGHTDB_NOEXCEPT
{
- return Mixed(a).get_type() == COLUMN_TYPE_STRING && std::strcmp(Mixed(a).get_string(), b) != 0;
+ return Mixed(a).get_type() == type_String && std::strcmp(Mixed(a).get_string(), b) != 0;
}
inline bool operator==(const char* a, Wrap b) TIGHTDB_NOEXCEPT
{
- return Mixed(b).get_type() == COLUMN_TYPE_STRING && std::strcmp(a, Mixed(b).get_string()) == 0;
+ return Mixed(b).get_type() == type_String && std::strcmp(a, Mixed(b).get_string()) == 0;
}
inline bool operator!=(const char* a, Wrap b) TIGHTDB_NOEXCEPT
{
- return Mixed(b).get_type() == COLUMN_TYPE_STRING && std::strcmp(a, Mixed(b).get_string()) != 0;
+ return Mixed(b).get_type() == type_String && std::strcmp(a, Mixed(b).get_string()) != 0;
}
inline bool operator==(Wrap a, char* b) TIGHTDB_NOEXCEPT
{
- return Mixed(a).get_type() == COLUMN_TYPE_STRING && std::strcmp(Mixed(a).get_string(), b) == 0;
+ return Mixed(a).get_type() == type_String && std::strcmp(Mixed(a).get_string(), b) == 0;
}
inline bool operator!=(Wrap a, char* b) TIGHTDB_NOEXCEPT
{
- return Mixed(a).get_type() == COLUMN_TYPE_STRING && std::strcmp(Mixed(a).get_string(), b) != 0;
+ return Mixed(a).get_type() == type_String && std::strcmp(Mixed(a).get_string(), b) != 0;
}
inline bool operator==(char* a, Wrap b) TIGHTDB_NOEXCEPT
{
- return Mixed(b).get_type() == COLUMN_TYPE_STRING && std::strcmp(a, Mixed(b).get_string()) == 0;
+ return Mixed(b).get_type() == type_String && std::strcmp(a, Mixed(b).get_string()) == 0;
}
inline bool operator!=(char* a, Wrap b) TIGHTDB_NOEXCEPT
{
- return Mixed(b).get_type() == COLUMN_TYPE_STRING && std::strcmp(a, Mixed(b).get_string()) != 0;
+ return Mixed(b).get_type() == type_String && std::strcmp(a, Mixed(b).get_string()) != 0;
}
@@ -443,22 +443,22 @@ inline bool operator!=(char* a, Wrap b) TIGHTDB_NOEXCEPT
inline bool operator==(Wrap a, BinaryData b) TIGHTDB_NOEXCEPT
{
- return Mixed(a).get_type() == COLUMN_TYPE_BINARY && Mixed(a).get_binary().compare_payload(b);
+ return Mixed(a).get_type() == type_Binary && Mixed(a).get_binary().compare_payload(b);
}
inline bool operator!=(Wrap a, BinaryData b) TIGHTDB_NOEXCEPT
{
- return Mixed(a).get_type() == COLUMN_TYPE_BINARY && !Mixed(a).get_binary().compare_payload(b);
+ return Mixed(a).get_type() == type_Binary && !Mixed(a).get_binary().compare_payload(b);
}
inline bool operator==(BinaryData a, Wrap b) TIGHTDB_NOEXCEPT
{
- return Mixed(b).get_type() == COLUMN_TYPE_BINARY && a.compare_payload(Mixed(b).get_binary());
+ return Mixed(b).get_type() == type_Binary && a.compare_payload(Mixed(b).get_binary());
}
inline bool operator!=(BinaryData a, Wrap b) TIGHTDB_NOEXCEPT
{
- return Mixed(b).get_type() == COLUMN_TYPE_BINARY && !a.compare_payload(Mixed(b).get_binary());
+ return Mixed(b).get_type() == type_Binary && !a.compare_payload(Mixed(b).get_binary());
}
@@ -466,22 +466,22 @@ inline bool operator!=(BinaryData a, Wrap b) TIGHTDB_NOEXCEPT
inline bool operator==(Wrap a, Date b) TIGHTDB_NOEXCEPT
{
- return Mixed(a).get_type() == COLUMN_TYPE_DATE && Date(Mixed(a).get_date()) == b;
+ return Mixed(a).get_type() == type_Date && Date(Mixed(a).get_date()) == b;
}
inline bool operator!=(Wrap a, Date b) TIGHTDB_NOEXCEPT
{
- return Mixed(a).get_type() == COLUMN_TYPE_DATE && Date(Mixed(a).get_date()) != b;
+ return Mixed(a).get_type() == type_Date && Date(Mixed(a).get_date()) != b;
}
inline bool operator==(Date a, Wrap b) TIGHTDB_NOEXCEPT
{
- return Mixed(b).get_type() == COLUMN_TYPE_DATE && a == Date(Mixed(b).get_date());
+ return Mixed(b).get_type() == type_Date && a == Date(Mixed(b).get_date());
}
inline bool operator!=(Date a, Wrap b) TIGHTDB_NOEXCEPT
{
- return Mixed(b).get_type() == COLUMN_TYPE_DATE && a != Date(Mixed(b).get_date());
+ return Mixed(b).get_type() == type_Date && a != Date(Mixed(b).get_date());
}
diff --git a/src/tightdb/query.cpp b/src/tightdb/query.cpp
index d6bc1121820..9c484fec813 100644
--- a/src/tightdb/query.cpp
+++ b/src/tightdb/query.cpp
@@ -271,13 +271,14 @@ Query& Query::not_equal(size_t column_ndx, const char* value, bool caseSensitive
// Aggregates =================================================================================
template
-R Query::aggregate(R (ColType::*aggregateMethod)(size_t start, size_t end) const,
+R Query::aggregate(R (ColType::*aggregateMethod)(size_t start, size_t end) const,
size_t column_ndx, size_t* resultcount, size_t start, size_t end, size_t limit) const
{
if (end == size_t(-1))
end = m_table->size();
- const ColType& column = m_table->GetColumn::id>(column_ndx);
+ const ColType& column =
+ m_table->GetColumn::id)>(column_ndx);
if (first.size() == 0 || first[0] == 0) {
// User created query with no criteria; aggregate range
diff --git a/src/tightdb/query_engine.hpp b/src/tightdb/query_engine.hpp
index 5db9d20bb41..a96cbf3aba7 100644
--- a/src/tightdb/query_engine.hpp
+++ b/src/tightdb/query_engine.hpp
@@ -32,7 +32,7 @@ The construction of all this takes part in query.cpp. Each node has two importan
aggregate_local(start, end)
The aggregate() function executes the aggregate of a query. You can call the method on any of the nodes
-(except children nodes of OrNode and SubtableNode) - it has the same behaviour. The function contains
+(except children nodes of OrNode and SubtableNode) - it has the same behaviour. The function contains
scheduling that calls aggregate_local(start, end) on different nodes with different start/end ranges,
depending on what it finds is most optimal.
@@ -52,8 +52,8 @@ aggregate(0, 10)
node1->find_first_local(7, 8)
node2->find_first_local(7, 8)
-find_first_local(n, n + 1) is a function that can be used to test a single row of another condition. Note that
-this is very simplified. There are other statistical arguments to the methods, and also, find_first_local() can be
+find_first_local(n, n + 1) is a function that can be used to test a single row of another condition. Note that
+this is very simplified. There are other statistical arguments to the methods, and also, find_first_local() can be
called from a callback function called by an integer Array.
@@ -66,10 +66,10 @@ TConditionValue: Type of values in condition column. That is, int64_t, float,
TAction: What to do with each search result, from the enums TDB_RETURN_FIRST, TDB_COUNT, TDB_SUM, etc
-TResult: Type of result of actions - float, double, int64_t, etc. Special notes: For TDB_COUNT it's
+TResult: Type of result of actions - float, double, int64_t, etc. Special notes: For TDB_COUNT it's
int64_t, for TDB_FIND_ALL it's int64_t which points at destination array.
-TSourceColumn: Type of source column used in actions, or *ignored* if no source column is used (like for
+TSourceColumn: Type of source column used in actions, or *ignored* if no source column is used (like for
TDB_COUNT, TDB_RETURN_FIRST)
@@ -78,7 +78,7 @@ There are two important classes used in queries:
SequentialGetter Column iterator used to get successive values with leaf caching. Used both for condition columns
and aggregate source column
-AggregateState State of the aggregate - contains a state variable that stores intermediate sum, max, min,
+AggregateState State of the aggregate - contains a state variable that stores intermediate sum, max, min,
etc, etc.
*/
@@ -107,17 +107,17 @@ namespace tightdb {
// Number of matches to find in best condition loop before breaking out to probe other conditions. Too low value gives too many
// constant time overheads everywhere in the query engine. Too high value makes it adapt less rapidly to changes in match
// frequencies.
-const size_t findlocals = 64;
+const size_t findlocals = 64;
// Average match distance in linear searches where further increase in distance no longer increases query speed (because time
// spent on handling each match becomes insignificant compared to time spent on the search).
const size_t bestdist = 512;
-// Minimum number of matches required in a certain condition before it can be used to compute statistics. Too high value can spent
+// Minimum number of matches required in a certain condition before it can be used to compute statistics. Too high value can spent
// too much time in a bad node (with high match frequency). Too low value gives inaccurate statistics.
const size_t probe_matches = 4;
-const size_t bitwidth_time_unit = 64;
+const size_t bitwidth_time_unit = 64;
typedef bool (*CallbackDummy)(int64_t);
@@ -127,25 +127,25 @@ template<> struct ColumnTypeTraits {
typedef Column column_type;
typedef Array array_type;
typedef int64_t sum_type;
- static const ColumnType id = COLUMN_TYPE_INT;
+ static const DataType id = type_Int;
};
template<> struct ColumnTypeTraits {
typedef Column column_type;
typedef Array array_type;
typedef int64_t sum_type;
- static const ColumnType id = COLUMN_TYPE_BOOL;
+ static const DataType id = type_Bool;
};
template<> struct ColumnTypeTraits {
typedef ColumnFloat column_type;
typedef ArrayFloat array_type;
typedef double sum_type;
- static const ColumnType id = COLUMN_TYPE_FLOAT;
+ static const DataType id = type_Float;
};
template<> struct ColumnTypeTraits {
typedef ColumnDouble column_type;
typedef ArrayDouble array_type;
typedef double sum_type;
- static const ColumnType id = COLUMN_TYPE_DOUBLE;
+ static const DataType id = type_Double;
};
// Only purpose is to return 'double' if and only if source column (T) is float and you're doing a sum (A)
@@ -168,14 +168,14 @@ templateclass SequentialGetter : public SequentialGetterBase {
typedef typename ColumnTypeTraits::column_type ColType;
typedef typename ColumnTypeTraits::array_type ArrayType;
- // We must destroy m_array immediately after its instantiation to avoid leak of what it preallocates. We cannot
+ // We must destroy m_array immediately after its instantiation to avoid leak of what it preallocates. We cannot
// wait until a SequentialGetter destructor because GetBlock() maps it to data that we don't have ownership of.
- SequentialGetter()
- {
- m_array.Destroy();
+ SequentialGetter()
+ {
+ m_array.Destroy();
}
- SequentialGetter(const Table& table, size_t column_ndx)
+ SequentialGetter(const Table& table, size_t column_ndx)
{
m_array.Destroy();
if (column_ndx != not_found)
@@ -183,7 +183,7 @@ templateclass SequentialGetter : public SequentialGetterBase {
m_leaf_end = 0;
}
- SequentialGetter(ColType* column)
+ SequentialGetter(ColType* column)
{
m_array.Destroy();
m_column = column;
@@ -228,7 +228,8 @@ class ParentNode {
ParentNode() : m_is_integer_node(false), m_table(NULL) {}
// Note: Changed to avoid a lot of copying of the vector. Lasse, plese review.
- void gather_children(std::vector& v) {
+ void gather_children(std::vector& v)
+ {
m_children.clear();
ParentNode* p = this;
size_t i = v.size();
@@ -242,11 +243,10 @@ class ParentNode {
m_children.erase(m_children.begin() + i);
m_children.insert(m_children.begin(), this);
- m_conds = m_children.size();
+ m_conds = m_children.size();
}
- struct score_compare
- {
+ struct score_compare {
bool operator ()(ParentNode const* a, ParentNode const* b) const { return (a->cost() < b->cost()); }
};
@@ -282,25 +282,25 @@ class ParentNode {
virtual ~ParentNode() {}
-
- virtual void Init(const Table& table)
+
+ virtual void Init(const Table& table)
{
- m_table = &table;
- if (m_child)
+ m_table = &table;
+ if (m_child)
m_child->Init(table);
}
-
+
virtual size_t find_first_local(size_t start, size_t end) = 0;
-
+
virtual ParentNode* child_criteria(void)
{
return m_child;
}
// Only purpose is to make all IntegerNode classes have this function (overloaded only in IntegerNode)
- virtual size_t aggregate_call_specialized(ACTION /*TAction*/, ColumnType /*TResult*/,
- QueryStateBase* /*st*/,
- size_t /*start*/, size_t /*end*/, size_t /*local_limit*/,
+ virtual size_t aggregate_call_specialized(ACTION /*TAction*/, DataType /*TResult*/,
+ QueryStateBase* /*st*/,
+ size_t /*start*/, size_t /*end*/, size_t /*local_limit*/,
SequentialGetterBase* /*source_column*/, size_t* /*matchcount*/)
{
TIGHTDB_ASSERT(false);
@@ -308,11 +308,11 @@ class ParentNode {
}
template
- size_t aggregate_local_selector(ParentNode* node, QueryState* st, size_t start, size_t end, size_t local_limit,
+ size_t aggregate_local_selector(ParentNode* node, QueryState* st, size_t start, size_t end, size_t local_limit,
SequentialGetter* source_column, size_t* matchcount)
{
size_t r;
-
+
if (node->m_is_integer_node)
// call method in IntegerNode
r = node->aggregate_call_specialized(TAction, ColumnTypeTraits::id,(QueryStateBase*)st,
@@ -325,13 +325,13 @@ class ParentNode {
template
- TResult aggregate(QueryState* st, size_t start, size_t end, size_t agg_col, size_t* matchcount)
+ TResult aggregate(QueryState* st, size_t start, size_t end, size_t agg_col, size_t* matchcount)
{
- if (end == size_t(-1))
+ if (end == size_t(-1))
end = m_table->size();
SequentialGetter* source_column = NULL;
-
+
if (agg_col != not_found)
source_column = new SequentialGetter(*m_table, agg_col);
@@ -371,30 +371,30 @@ class ParentNode {
}
template
- size_t aggregate_local(QueryStateBase* st, size_t start, size_t end, size_t local_limit,
- SequentialGetterBase* source_column, size_t* matchcount)
+ size_t aggregate_local(QueryStateBase* st, size_t start, size_t end, size_t local_limit,
+ SequentialGetterBase* source_column, size_t* matchcount)
{
// aggregate called on non-integer column type. Speed of this function is not as critical as speed of the
// integer version, because find_first_local() is relatively slower here (because it's non-integers).
//
// Todo: Two speedups are possible. Simple: Initially test if there are no sub criterias and run find_first_local()
- // in a tight loop if so (instead of testing if there are sub criterias after each match). Harder: Specialize
+ // in a tight loop if so (instead of testing if there are sub criterias after each match). Harder: Specialize
// data type array to make array call match() directly on each match, like for integers.
-
+
(void)matchcount;
size_t local_matches = 0;
size_t r = start - 1;
for (;;) {
- if (local_matches == local_limit) {
- m_dD = double(r - start) / local_matches;
+ if (local_matches == local_limit) {
+ m_dD = double(r - start) / local_matches;
return r + 1;
}
// Find first match in this condition node
r = find_first_local(r + 1, end);
- if (r == end) {
- m_dD = double(r - start) / local_matches;
+ if (r == end) {
+ m_dD = double(r - start) / local_matches;
return end;
}
@@ -417,7 +417,7 @@ class ParentNode {
if (source_column != NULL)
av = static_cast*>(source_column)->GetNext(r); // todo, avoid GetNext if value not needed (if !uses_val)
((QueryState*)st)->template match(r, 0, TResult(av), CallbackDummy());
- }
+ }
}
}
@@ -500,17 +500,17 @@ class SubtableNode: public ParentNode {
m_matches = 0;
m_table = &table;
-
+
if (m_child) {
m_child->Init(table);
std::vector v;
m_child->gather_children(v);
}
- if (m_child2)
+ if (m_child2)
m_child2->Init(table);
}
-
+
size_t find_first_local(size_t start, size_t end)
{
TIGHTDB_ASSERT(m_table);
@@ -524,12 +524,13 @@ class SubtableNode: public ParentNode {
const size_t sub = m_child->find_first(0, subsize);
if (sub != subsize)
- return s;
+ return s;
}
return end;
}
- ParentNode* child_criteria(void) {
+ ParentNode* child_criteria(void)
+ {
return m_child2;
}
@@ -544,7 +545,8 @@ template class IntegerNode: pu
// NOTE: Be careful to call Array(no_prealloc_tag) constructors on m_array in the initializer list, otherwise
// their default constructors are called which are slow
- IntegerNode(TConditionValue v, size_t column) : m_value(v), m_array(Array::no_prealloc_tag()) {
+ IntegerNode(TConditionValue v, size_t column) : m_value(v), m_array(Array::no_prealloc_tag())
+ {
m_is_integer_node = true;
m_condition_column_idx = column;
m_child = 0;
@@ -557,8 +559,9 @@ template class IntegerNode: pu
// Only purpose of this function is to let you quickly create a IntegerNode object and call aggregate_local() on it to aggregate
// on a single stand-alone column, with 1 or 0 search criterias, without involving any tables, etc. Todo, could
// be merged with Init somehow to simplify
- void QuickInit(Column *column, int64_t value) {
- m_condition_column = column;
+ void QuickInit(Column *column, int64_t value)
+ {
+ m_condition_column = column;
m_leaf_end = 0;
m_value = value;
m_conds = 0;
@@ -576,7 +579,8 @@ template class IntegerNode: pu
// This function is called from Array::find() for each search result if TAction == TDB_CALLBACK_IDX
// in the IntegerNode::aggregate_local() call. Used if aggregate source column is different from search criteria column
- template bool match_callback(int64_t v) {
+ template bool match_callback(int64_t v)
+ {
size_t i = to_size_t(v);
m_last_local_match = i;
m_local_matches++;
@@ -594,12 +598,12 @@ template class IntegerNode: pu
}
bool b;
- if (state->template uses_val()) { // Compiler cannot see that Column::Get has no side effect and result is discarded
+ if (state->template uses_val()) { // Compiler cannot see that Column::Get has no side effect and result is discarded
TSourceColumn av = source_column->GetNext(i);
- b = state->template match(i, 0, av, CallbackDummy());
+ b = state->template match(i, 0, av, CallbackDummy());
}
else {
- b = state->template match(i, 0, TSourceColumn(0), CallbackDummy());
+ b = state->template match(i, 0, TSourceColumn(0), CallbackDummy());
}
if (m_local_matches == m_local_limit)
@@ -608,38 +612,38 @@ template class IntegerNode: pu
return b;
}
- size_t aggregate_call_specialized(ACTION TAction, ColumnType col_id, QueryStateBase* st,
- size_t start, size_t end, size_t local_limit,
- SequentialGetterBase* source_column, size_t* matchcount)
+ size_t aggregate_call_specialized(ACTION TAction, DataType col_id, QueryStateBase* st,
+ size_t start, size_t end, size_t local_limit,
+ SequentialGetterBase* source_column, size_t* matchcount)
{
size_t ret;
if (TAction == TDB_RETURN_FIRST)
- ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
+ ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
else if (TAction == TDB_COUNT)
ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
- else if (TAction == TDB_SUM && col_id == COLUMN_TYPE_INT)
+ else if (TAction == TDB_SUM && col_id == type_Int)
ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
- else if (TAction == TDB_SUM && col_id == COLUMN_TYPE_FLOAT)
- // todo, fixme, see if we must let sum return a double even when summing a float coltype
+ else if (TAction == TDB_SUM && col_id == type_Float)
+ // todo, fixme, see if we must let sum return a double even when summing a float coltype
ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
- else if (TAction == TDB_SUM && col_id == COLUMN_TYPE_DOUBLE)
+ else if (TAction == TDB_SUM && col_id == type_Double)
ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
- else if (TAction == TDB_MAX && col_id == COLUMN_TYPE_INT)
+ else if (TAction == TDB_MAX && col_id == type_Int)
ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
- else if (TAction == TDB_MAX && col_id == COLUMN_TYPE_FLOAT)
+ else if (TAction == TDB_MAX && col_id == type_Float)
ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
- else if (TAction == TDB_MAX && col_id == COLUMN_TYPE_DOUBLE)
+ else if (TAction == TDB_MAX && col_id == type_Double)
ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
- else if (TAction == TDB_MIN && col_id == COLUMN_TYPE_INT)
+ else if (TAction == TDB_MIN && col_id == type_Int)
ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
- else if (TAction == TDB_MIN && col_id == COLUMN_TYPE_FLOAT)
+ else if (TAction == TDB_MIN && col_id == type_Float)
ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
- else if (TAction == TDB_MIN && col_id == COLUMN_TYPE_DOUBLE)
+ else if (TAction == TDB_MIN && col_id == type_Double)
ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
else if (TAction == TDB_FINDALL)
@@ -648,7 +652,7 @@ template class IntegerNode: pu
else if (TAction == TDB_CALLBACK_IDX)
ret = aggregate_local(st, start, end, local_limit, source_column, matchcount);
- else {
+ else {
TIGHTDB_ASSERT(false);
return 0;
}
@@ -657,8 +661,8 @@ template class IntegerNode: pu
// source_column: column number in m_table which must act as source for aggreate TAction
- template
- size_t aggregate_local(QueryStateBase* st, size_t start, size_t end, size_t local_limit,
+ template
+ size_t aggregate_local(QueryStateBase* st, size_t start, size_t end, size_t local_limit,
SequentialGetterBase* source_column, size_t* matchcount)
{
typedef typename ColumnTypeTraitsSum::sum_type QueryStateType;
@@ -672,10 +676,10 @@ template class IntegerNode: pu
m_last_local_match = start - 1;
m_state = st;
- for (size_t s = start; s < end; ) {
+ for (size_t s = start; s < end; ) {
// Cache internal leafs
- if (s >= m_leaf_end) {
- m_condition_column->GetBlock(s, m_array, m_leaf_start);
+ if (s >= m_leaf_end) {
+ m_condition_column->GetBlock(s, m_array, m_leaf_start);
m_leaf_end = m_leaf_start + m_array.Size();
size_t w = m_array.GetBitWidth();
m_dT = (w == 0 ? 1.0 / MAX_LIST_SIZE : w / float(bitwidth_time_unit));
@@ -687,18 +691,18 @@ template class IntegerNode: pu
else
end2 = end - m_leaf_start;
- if (m_conds <= 1 && (source_column == NULL ||
- (SameType::value
- && static_cast*>(source_column)->m_column == m_condition_column))) {
+ if (m_conds <= 1 && (source_column == NULL ||
+ (SameType::value
+ && static_cast*>(source_column)->m_column == m_condition_column))) {
m_array.find(c, TAction, m_value, s - m_leaf_start, end2, m_leaf_start, (QueryState*)st);
}
else {
QueryState jumpstate; // todo optimize by moving outside for loop
- m_source_column = source_column;
- m_array.find(m_value, s - m_leaf_start, end2, m_leaf_start, &jumpstate,
+ m_source_column = source_column;
+ m_array.find(m_value, s - m_leaf_start, end2, m_leaf_start, &jumpstate,
std::bind1st(std::mem_fun(&IntegerNode::match_callback), this));
}
-
+
if (m_local_matches == m_local_limit)
break;
@@ -732,7 +736,7 @@ template class IntegerNode: pu
m_condition_column->GetBlock(start, m_array, m_leaf_start);
m_leaf_end = m_leaf_start + m_array.Size();
}
-
+
// Do search directly on cached leaf array
if (start + 1 == end) {
if (condition(m_array.Get(start - m_leaf_start), m_value))
@@ -755,7 +759,7 @@ template class IntegerNode: pu
}
else
return s + m_leaf_start;
- }
+ }
return end;
}
@@ -767,14 +771,14 @@ template class IntegerNode: pu
size_t m_last_local_match;
ColType* m_condition_column; // Column on which search criteria is applied
// const Array* m_criteria_arr;
- Array m_array;
+ Array m_array;
size_t m_leaf_start;
size_t m_leaf_end;
size_t m_local_end;
size_t m_local_matches;
size_t m_local_limit;
-
+
QueryStateBase* m_state;
SequentialGetterBase* m_source_column; // Column of values used in aggregate (TDB_FINDALL, TDB_RETURN_FIRST, TDB_SUM, etc)
};
@@ -806,7 +810,9 @@ template class StringNode: public ParentNode {
if (!b1 || !b2)
error_code = "Malformed UTF-8: " + std::string(m_value);
}
- ~StringNode() {
+
+ ~StringNode()
+ {
delete[] m_value; delete[] m_ucase; delete[] m_lcase;
}
@@ -818,7 +824,7 @@ template class StringNode: public ParentNode {
m_table = &table;
m_condition_column = &table.GetColumnBase(m_condition_column_idx);
- m_column_type = table.GetRealColumnType(m_condition_column_idx);
+ m_column_type = table.get_real_column_type(m_condition_column_idx);
if (m_child) m_child->Init(table);
}
@@ -831,11 +837,11 @@ template class StringNode: public ParentNode {
const char* t;
// todo, can be optimized by placing outside loop
- if (m_column_type == COLUMN_TYPE_STRING)
- t = ((const AdaptiveStringColumn*)m_condition_column)->Get(s);
+ if (m_column_type == col_type_String)
+ t = static_cast(m_condition_column)->Get(s);
else {
//TODO: First check if string is in key list
- t = ((const ColumnStringEnum*)m_condition_column)->Get(s);
+ t = static_cast(m_condition_column)->Get(s);
}
if (cond(m_value, m_ucase, m_lcase, t))
@@ -857,7 +863,7 @@ template class StringNode: public ParentNode {
template class BASICNODE: public ParentNode {
public:
typedef typename ColumnTypeTraits::column_type ColType;
-
+
BASICNODE(TConditionValue v, size_t column_ndx) : m_value(v)
{
m_condition_column_idx = column_ndx;
@@ -868,7 +874,8 @@ template class BASICNODE: publ
// Only purpose of this function is to let you quickly create a IntegerNode object and call aggregate_local() on it to aggregate
// on a single stand-alone column, with 1 or 0 search criterias, without involving any tables, etc. Todo, could
// be merged with Init somehow to simplify
- void QuickInit(BasicColumn *column, TConditionValue value) {
+ void QuickInit(BasicColumn *column, TConditionValue value)
+ {
m_condition_column.m_column = (ColType*)column;
m_condition_column.m_leaf_end = 0;
m_value = value;
@@ -882,14 +889,15 @@ template class BASICNODE: publ
m_condition_column.m_column = (ColType*)(&table.GetColumnBase(m_condition_column_idx));
m_condition_column.m_leaf_end = 0;
- if (m_child)
+ if (m_child)
m_child->Init(table);
}
-
- size_t find_first_local(size_t start, size_t end) {
+
+ size_t find_first_local(size_t start, size_t end)
+ {
TConditionFunction cond;
- for (size_t s = start; s < end; ++s) {
+ for (size_t s = start; s < end; ++s) {
TConditionValue v = m_condition_column.GetNext(s);
if (cond(v, m_value))
return s;
@@ -916,7 +924,9 @@ template class BinaryNode: public ParentNode {
m_value = (char *)malloc(len);
memcpy(m_value, v, len);
}
- ~BinaryNode() {
+
+ ~BinaryNode()
+ {
free((void*)m_value);
}
@@ -925,16 +935,17 @@ template class BinaryNode: public ParentNode {
m_dD = 100.0;
m_table = &table;
m_condition_column = (const ColumnBinary*)&table.GetColumnBase(m_condition_column_idx);
- m_column_type = table.GetRealColumnType(m_condition_column_idx);
+ m_column_type = table.get_real_column_type(m_condition_column_idx);
- if (m_child)
+ if (m_child)
m_child->Init(table);
}
- size_t find_first_local(size_t start, size_t end) {
+ size_t find_first_local(size_t start, size_t end)
+ {
TConditionFunction condition;
- for (size_t s = start; s < end; ++s) {
+ for (size_t s = start; s < end; ++s) {
const char* value = m_condition_column->Get(s).pointer;
size_t len = m_condition_column->Get(s).len;
@@ -954,10 +965,10 @@ template class BinaryNode: public ParentNode {
template <> class StringNode: public ParentNode {
public:
- template
- int64_t find_all(Array*, size_t, size_t, size_t, size_t)
+ template
+ int64_t find_all(Array*, size_t, size_t, size_t, size_t)
{
- TIGHTDB_ASSERT(false);
+ TIGHTDB_ASSERT(false);
return 0;
}
@@ -975,12 +986,12 @@ template <> class StringNode: public ParentNode {
void Init(const Table& table)
{
m_dD = 10.0;
-
+
m_table = &table;
m_condition_column = &table.GetColumnBase(m_condition_column_idx);
- m_column_type = table.GetRealColumnType(m_condition_column_idx);
+ m_column_type = table.get_real_column_type(m_condition_column_idx);
- if (m_column_type == COLUMN_TYPE_STRING_ENUM) {
+ if (m_column_type == col_type_StringEnum) {
m_dT = 1.0;
m_key_ndx = ((const ColumnStringEnum*)m_condition_column)->GetKeyNdx(m_value);
}
@@ -989,7 +1000,7 @@ template <> class StringNode: public ParentNode {
}
if (m_condition_column->HasIndex()) {
- if (m_column_type == COLUMN_TYPE_STRING_ENUM)
+ if (m_column_type == col_type_StringEnum)
((ColumnStringEnum*)m_condition_column)->find_all(m_index, m_value);
else {
((AdaptiveStringColumn*)m_condition_column)->find_all(m_index, m_value);
@@ -997,7 +1008,7 @@ template <> class StringNode: public ParentNode {
last_indexed = 0;
}
- if (m_child)
+ if (m_child)
m_child->Init(table);
}
@@ -1016,10 +1027,10 @@ template <> class StringNode: public ParentNode {
}
else {
// todo, can be optimized by placing outside loop
- if (m_column_type == COLUMN_TYPE_STRING)
+ if (m_column_type == col_type_String)
s = ((const AdaptiveStringColumn*)m_condition_column)->find_first(m_value, s, end);
else {
- if (m_key_ndx == size_t(-1))
+ if (m_key_ndx == size_t(-1))
s = end; // not in key set
else {
const ColumnStringEnum* const cse = (const ColumnStringEnum*)m_condition_column;
diff --git a/src/tightdb/replication.cpp b/src/tightdb/replication.cpp
index 4c7058b10fb..779031106b1 100644
--- a/src/tightdb/replication.cpp
+++ b/src/tightdb/replication.cpp
@@ -779,13 +779,13 @@ struct Replication::TransactLogApplier {
bool is_valid_column_type(int type)
{
switch (type) {
- case COLUMN_TYPE_INT:
- case COLUMN_TYPE_BOOL:
- case COLUMN_TYPE_DATE:
- case COLUMN_TYPE_STRING:
- case COLUMN_TYPE_BINARY:
- case COLUMN_TYPE_TABLE:
- case COLUMN_TYPE_MIXED: return true;
+ case type_Int:
+ case type_Bool:
+ case type_Date:
+ case type_String:
+ case type_Binary:
+ case type_Table:
+ case type_Mixed: return true;
default: break;
}
return false;
@@ -872,7 +872,7 @@ template
void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx)
{
switch (m_table->get_column_type(column_ndx)) {
- case COLUMN_TYPE_INT:
+ case type_Int:
{
int64_t value = read_int(); // Throws
if (insert) m_table->insert_int(column_ndx, ndx, value); // FIXME: Memory allocation failure!!!
@@ -885,7 +885,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx)
#endif
}
break;
- case COLUMN_TYPE_BOOL:
+ case type_Bool:
{
bool value = read_int(); // Throws
if (insert) m_table->insert_bool(column_ndx, ndx, value); // FIXME: Memory allocation failure!!!
@@ -898,7 +898,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx)
#endif
}
break;
- case COLUMN_TYPE_DATE:
+ case type_Date:
{
time_t value = read_int(); // Throws
if (insert) m_table->insert_date(column_ndx, ndx, value); // FIXME: Memory allocation failure!!!
@@ -911,7 +911,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx)
#endif
}
break;
- case COLUMN_TYPE_STRING:
+ case type_String:
{
read_string(m_string_buffer); // Throws
const char* const value = m_string_buffer.c_str();
@@ -925,7 +925,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx)
#endif
}
break;
- case COLUMN_TYPE_BINARY:
+ case type_Binary:
{
read_string(m_string_buffer); // Throws
if (insert) m_table->insert_binary(column_ndx, ndx, m_string_buffer.data(),
@@ -940,7 +940,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx)
#endif
}
break;
- case COLUMN_TYPE_TABLE:
+ case type_Table:
if (insert) m_table->insert_subtable(column_ndx, ndx); // FIXME: Memory allocation failure!!!
else m_table->clear_subtable(column_ndx, ndx); // FIXME: Memory allocation failure!!!
#ifdef TIGHTDB_DEBUG
@@ -950,11 +950,11 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx)
}
#endif
break;
- case COLUMN_TYPE_MIXED:
+ case type_Mixed:
{
int type = read_int(); // Throws
switch (type) {
- case COLUMN_TYPE_INT:
+ case type_Int:
{
int64_t value = read_int(); // Throws
if (insert) m_table->insert_mixed(column_ndx, ndx, value); // FIXME: Memory allocation failure!!!
@@ -967,7 +967,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx)
#endif
}
break;
- case COLUMN_TYPE_BOOL:
+ case type_Bool:
{
bool value = read_int(); // Throws
if (insert) m_table->insert_mixed(column_ndx, ndx, value); // FIXME: Memory allocation failure!!!
@@ -980,7 +980,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx)
#endif
}
break;
- case COLUMN_TYPE_DATE:
+ case type_Date:
{
time_t value = read_int(); // Throws
if (insert) m_table->insert_mixed(column_ndx, ndx, Date(value)); // FIXME: Memory allocation failure!!!
@@ -993,7 +993,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx)
#endif
}
break;
- case COLUMN_TYPE_STRING:
+ case type_String:
{
read_string(m_string_buffer); // Throws
const char* const value = m_string_buffer.c_str();
@@ -1007,7 +1007,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx)
#endif
}
break;
- case COLUMN_TYPE_BINARY:
+ case type_Binary:
{
read_string(m_string_buffer); // Throws
const BinaryData value(m_string_buffer.data(), m_string_buffer.size());
@@ -1021,7 +1021,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx)
#endif
}
break;
- case COLUMN_TYPE_TABLE:
+ case type_Table:
if (insert) m_table->insert_mixed(column_ndx, ndx, Mixed::subtable_tag()); // FIXME: Memory allocation failure!!!
else m_table->set_mixed(column_ndx, ndx, Mixed::subtable_tag()); // FIXME: Memory allocation failure!!!
#ifdef TIGHTDB_DEBUG
@@ -1144,10 +1144,10 @@ void Replication::TransactLogApplier::apply()
goto bad_transact_log;
if (m_table->size() <= ndx) goto bad_transact_log;
switch (m_table->get_column_type(column_ndx)) {
- case COLUMN_TYPE_TABLE:
+ case type_Table:
m_table = m_table->get_subtable(column_ndx, ndx);
break;
- case COLUMN_TYPE_MIXED:
+ case type_Mixed:
m_table = m_table->get_subtable(column_ndx, ndx);
if (!m_table) goto bad_transact_log;
break;
diff --git a/src/tightdb/replication.hpp b/src/tightdb/replication.hpp
index 6657c5603e0..904498bdd9b 100644
--- a/src/tightdb/replication.hpp
+++ b/src/tightdb/replication.hpp
@@ -472,29 +472,29 @@ inline void Replication::mixed_cmd(char cmd, std::size_t column_ndx,
buf = encode_int(buf, ndx);
buf = encode_int(buf, int(value.get_type()));
switch (value.get_type()) {
- case COLUMN_TYPE_INT:
+ case type_Int:
buf = encode_int(buf, value.get_int());
transact_log_advance(buf);
break;
- case COLUMN_TYPE_BOOL:
+ case type_Bool:
buf = encode_int(buf, int(value.get_bool()));
transact_log_advance(buf);
break;
- case COLUMN_TYPE_FLOAT:
+ case type_Float:
TIGHTDB_ASSERT(false); // FIXME: IMPLEMENT
//buf = encode_float(buf, value.get_float()));
transact_log_advance(buf);
break;
- case COLUMN_TYPE_DOUBLE:
+ case type_Double:
TIGHTDB_ASSERT(false); // FIXME: IMPLEMENT
//buf = encode_double(buf, value.get_double()));
transact_log_advance(buf);
break;
- case COLUMN_TYPE_DATE:
+ case type_Date:
buf = encode_int(buf, value.get_date());
transact_log_advance(buf);
break;
- case COLUMN_TYPE_STRING:
+ case type_String:
{
const char* data = value.get_string();
std::size_t size = std::strlen(data);
@@ -503,7 +503,7 @@ inline void Replication::mixed_cmd(char cmd, std::size_t column_ndx,
transact_log_append(data, size); // Throws
}
break;
- case COLUMN_TYPE_BINARY:
+ case type_Binary:
{
BinaryData data = value.get_binary();
buf = encode_int(buf, data.len);
@@ -511,7 +511,7 @@ inline void Replication::mixed_cmd(char cmd, std::size_t column_ndx,
transact_log_append(data.pointer, data.len); // Throws
}
break;
- case COLUMN_TYPE_TABLE:
+ case type_Table:
transact_log_advance(buf);
break;
default:
diff --git a/src/tightdb/spec.cpp b/src/tightdb/spec.cpp
index aa6a96c32d4..17c94d68843 100644
--- a/src/tightdb/spec.cpp
+++ b/src/tightdb/spec.cpp
@@ -67,7 +67,7 @@ bool Spec::update_from_parent()
else return false;
}
-size_t Spec::add_column(ColumnType type, const char* name, ColumnType attr)
+size_t Spec::add_column(DataType type, const char* name, ColumnType attr)
{
TIGHTDB_ASSERT(name);
@@ -76,12 +76,12 @@ size_t Spec::add_column(ColumnType type, const char* name, ColumnType attr)
// We can set column attribute on creation
// TODO: add to replication log
- if (attr != COLUMN_ATTR_NONE) {
+ if (attr != col_attr_None) {
const size_t column_ndx = m_names.Size()-1;
set_column_attr(column_ndx, attr);
}
- if (type == COLUMN_TYPE_TABLE) {
+ if (type == type_Table) {
// SubSpecs array is only there when there are subtables
if (m_specSet.Size() == 2) {
m_subSpecs.SetType(COLUMN_HASREFS);
@@ -113,13 +113,13 @@ size_t Spec::add_column(ColumnType type, const char* name, ColumnType attr)
return (m_names.Size()-1); // column_ndx
}
-size_t Spec::add_subcolumn(const vector& column_path, ColumnType type, const char* name)
+size_t Spec::add_subcolumn(const vector& column_path, DataType type, const char* name)
{
TIGHTDB_ASSERT(!column_path.empty());
return do_add_subcolumn(column_path, 0, type, name);
}
-size_t Spec::do_add_subcolumn(const vector& column_ids, size_t pos, ColumnType type, const char* name)
+size_t Spec::do_add_subcolumn(const vector& column_ids, size_t pos, DataType type, const char* name)
{
const size_t column_ndx = column_ids[pos];
Spec subspec = get_subtable_spec(column_ndx);
@@ -135,7 +135,7 @@ size_t Spec::do_add_subcolumn(const vector& column_ids, size_t pos, Colu
Spec Spec::add_subtable_column(const char* name)
{
const size_t column_ndx = m_names.Size();
- add_column(COLUMN_TYPE_TABLE, name);
+ add_column(type_Table, name);
return get_subtable_spec(column_ndx);
}
@@ -174,8 +174,8 @@ void Spec::remove_column(size_t column_ndx)
// If the column is a subtable column, we have to delete
// the subspec(s) as well
- const ColumnType type = (ColumnType)m_spec.Get(type_ndx);
- if (type == COLUMN_TYPE_TABLE) {
+ const ColumnType type = ColumnType(m_spec.Get(type_ndx));
+ if (type == col_type_Table) {
const size_t subspec_ndx = get_subspec_ndx(column_ndx);
const size_t subspec_ref = m_subSpecs.GetAsRef(subspec_ndx);
@@ -190,8 +190,8 @@ void Spec::remove_column(size_t column_ndx)
// If there are an attribute, we have to delete that as well
if (type_ndx > 0) {
- const ColumnType type_prefix = (ColumnType)m_spec.Get(type_ndx-1);
- if (type_prefix >= COLUMN_ATTR_INDEXED)
+ const ColumnType type_prefix = ColumnType(m_spec.Get(type_ndx-1));
+ if (type_prefix >= col_attr_Indexed)
m_spec.Delete(type_ndx-1);
}
}
@@ -216,7 +216,7 @@ void Spec::do_remove_column(const vector& column_ids, size_t pos)
Spec Spec::get_subtable_spec(size_t column_ndx)
{
TIGHTDB_ASSERT(column_ndx < get_column_count());
- TIGHTDB_ASSERT(get_column_type(column_ndx) == COLUMN_TYPE_TABLE);
+ TIGHTDB_ASSERT(get_column_type(column_ndx) == type_Table);
const size_t subspec_ndx = get_subspec_ndx(column_ndx);
@@ -229,7 +229,7 @@ Spec Spec::get_subtable_spec(size_t column_ndx)
const Spec Spec::get_subtable_spec(size_t column_ndx) const
{
TIGHTDB_ASSERT(column_ndx < get_column_count());
- TIGHTDB_ASSERT(get_column_type(column_ndx) == COLUMN_TYPE_TABLE);
+ TIGHTDB_ASSERT(get_column_type(column_ndx) == type_Table);
const size_t subspec_ndx = get_subspec_ndx(column_ndx);
@@ -247,7 +247,7 @@ size_t Spec::get_subspec_ndx(size_t column_ndx) const
// so we need to count up to it's position
size_t pos = 0;
for (size_t i = 0; i < type_ndx; ++i) {
- if ((ColumnType)m_spec.Get(i) == COLUMN_TYPE_TABLE) ++pos;
+ if (ColumnType(m_spec.Get(i)) == col_type_Table) ++pos;
}
return pos;
}
@@ -287,7 +287,7 @@ size_t Spec::get_column_type_pos(size_t column_ndx) const TIGHTDB_NOEXCEPT
size_t type_ndx = 0;
for (; type_ndx < column_ndx; ++i) {
const ColumnType type = ColumnType(m_spec.Get(i));
- if (type >= COLUMN_ATTR_INDEXED) continue; // ignore attributes
+ if (type >= col_attr_Indexed) continue; // ignore attributes
++type_ndx;
}
return i;
@@ -301,22 +301,23 @@ ColumnType Spec::get_real_column_type(size_t ndx) const TIGHTDB_NOEXCEPT
size_t column_ndx = 0;
for (size_t i = 0; column_ndx <= ndx; ++i) {
type = ColumnType(m_spec.Get(i));
- if (type >= COLUMN_ATTR_INDEXED) continue; // ignore attributes
+ if (type >= col_attr_Indexed) continue; // ignore attributes
++column_ndx;
}
return type;
}
-ColumnType Spec::get_column_type(size_t ndx) const TIGHTDB_NOEXCEPT
+DataType Spec::get_column_type(size_t ndx) const TIGHTDB_NOEXCEPT
{
TIGHTDB_ASSERT(ndx < get_column_count());
const ColumnType type = get_real_column_type(ndx);
// Hide internal types
- if (type == COLUMN_TYPE_STRING_ENUM) return COLUMN_TYPE_STRING;
- else return type;
+ if (type == col_type_StringEnum) return type_String;
+
+ return DataType(type);
}
void Spec::set_column_type(std::size_t column_ndx, ColumnType type)
@@ -328,15 +329,15 @@ void Spec::set_column_type(std::size_t column_ndx, ColumnType type)
const size_t count = m_spec.Size();
for (;type_ndx < count; ++type_ndx) {
- const size_t t = (ColumnType)m_spec.Get(type_ndx);
- if (t >= COLUMN_ATTR_INDEXED) continue; // ignore attributes
+ const ColumnType t = ColumnType(m_spec.Get(type_ndx));
+ if (t >= col_attr_Indexed) continue; // ignore attributes
if (column_count == column_ndx) break;
++column_count;
}
// At this point we only support upgrading to string enum
- TIGHTDB_ASSERT((ColumnType)m_spec.Get(type_ndx) == COLUMN_TYPE_STRING);
- TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM);
+ TIGHTDB_ASSERT(ColumnType(m_spec.Get(type_ndx)) == col_type_String);
+ TIGHTDB_ASSERT(type == col_type_StringEnum);
m_spec.Set(type_ndx, type);
}
@@ -350,28 +351,28 @@ ColumnType Spec::get_column_attr(size_t ndx) const
// The attribute is an optional prefix for the type
for (size_t i = 0; column_ndx <= ndx; ++i) {
const ColumnType type = (ColumnType)m_spec.Get(i);
- if (type >= COLUMN_ATTR_INDEXED) {
+ if (type >= col_attr_Indexed) {
if (column_ndx == ndx) return type;
}
else ++column_ndx;
}
- return COLUMN_ATTR_NONE;
+ return col_attr_None;
}
void Spec::set_column_attr(size_t ndx, ColumnType attr)
{
TIGHTDB_ASSERT(ndx < get_column_count());
- TIGHTDB_ASSERT(attr >= COLUMN_ATTR_INDEXED);
+ TIGHTDB_ASSERT(attr >= col_attr_Indexed);
size_t column_ndx = 0;
for (size_t i = 0; column_ndx <= ndx; ++i) {
const ColumnType type = (ColumnType)m_spec.Get(i);
- if (type >= COLUMN_ATTR_INDEXED) {
+ if (type >= col_attr_Indexed) {
if (column_ndx == ndx) {
// if column already has an attr, we replace it
- if (attr == COLUMN_ATTR_NONE) m_spec.Delete(i);
+ if (attr == col_attr_None) m_spec.Delete(i);
else m_spec.Set(i, attr);
return;
}
diff --git a/src/tightdb/spec.hpp b/src/tightdb/spec.hpp
index a447e212914..bc9d9d8d8d1 100644
--- a/src/tightdb/spec.hpp
+++ b/src/tightdb/spec.hpp
@@ -22,6 +22,7 @@
#include
#include
+#include
#include
namespace tightdb {
@@ -36,8 +37,8 @@ class Spec {
Spec(const Spec& s);
~Spec();
- size_t add_column(ColumnType type, const char* name, ColumnType attr=COLUMN_ATTR_NONE);
- size_t add_subcolumn(const vector& column_path, ColumnType type, const char* name);
+ size_t add_column(DataType type, const char* name, ColumnType attr=col_attr_None);
+ size_t add_subcolumn(const vector& column_path, DataType type, const char* name);
Spec add_subtable_column(const char* name);
void rename_column(size_t column_ndx, const char* newname);
@@ -60,7 +61,7 @@ class Spec {
// Column info
size_t get_column_count() const TIGHTDB_NOEXCEPT;
- ColumnType get_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT;
+ DataType get_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT;
ColumnType get_real_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT;
const char* get_column_name(size_t column_ndx) const TIGHTDB_NOEXCEPT;
@@ -97,12 +98,6 @@ class Spec {
bool update_from_parent();
void set_parent(ArrayParent* parent, size_t pndx);
- // FIXME: This one was made private because it is called
- // internally from Table::optimize(), and it is not called from
- // any test case. If it must be public, it must also be made to
- // emit a transaction log instruction, but the internal call must
- // then call a different version that does not emit such an
- // instruction.
void set_column_type(size_t column_ndx, ColumnType type);
void set_column_attr(size_t column_ndx, ColumnType attr);
@@ -119,7 +114,7 @@ class Spec {
/// underlying memory.
static size_t create_empty_spec(Allocator&);
- size_t do_add_subcolumn(const vector& column_ids, size_t pos, ColumnType type, const char* name);
+ size_t do_add_subcolumn(const vector& column_ids, size_t pos, DataType type, const char* name);
void do_remove_column(const vector& column_ids, size_t pos);
void do_rename_column(const vector& column_ids, size_t pos, const char* name);
diff --git a/src/tightdb/table.cpp b/src/tightdb/table.cpp
index 6e0706f0234..d07710c8c96 100644
--- a/src/tightdb/table.cpp
+++ b/src/tightdb/table.cpp
@@ -70,7 +70,7 @@ void Table::CreateColumns()
}
size_t subtable_count = 0;
- ColumnType attr = COLUMN_ATTR_NONE;
+ ColumnType attr = col_attr_None;
Allocator& alloc = m_columns.GetAllocator();
const size_t count = m_spec_set.get_type_attr_count();
@@ -81,9 +81,9 @@ void Table::CreateColumns()
ColumnBase* new_col = 0;
switch (type) {
- case COLUMN_TYPE_INT:
- case COLUMN_TYPE_BOOL:
- case COLUMN_TYPE_DATE:
+ case type_Int:
+ case type_Bool:
+ case type_Date:
{
Column* c = new Column(COLUMN_NORMAL, alloc);
m_columns.add(c->GetRef());
@@ -91,7 +91,7 @@ void Table::CreateColumns()
new_col = c;
}
break;
- case COLUMN_TYPE_FLOAT:
+ case type_Float:
{
ColumnFloat* c = new ColumnFloat(alloc);
m_columns.add(c->GetRef());
@@ -99,7 +99,7 @@ void Table::CreateColumns()
new_col = c;
}
break;
- case COLUMN_TYPE_DOUBLE:
+ case type_Double:
{
ColumnDouble* c = new ColumnDouble(alloc);
m_columns.add(c->GetRef());
@@ -107,7 +107,7 @@ void Table::CreateColumns()
new_col = c;
}
break;
- case COLUMN_TYPE_STRING:
+ case type_String:
{
AdaptiveStringColumn* c = new AdaptiveStringColumn(alloc);
m_columns.add(c->GetRef());
@@ -115,7 +115,7 @@ void Table::CreateColumns()
new_col = c;
}
break;
- case COLUMN_TYPE_BINARY:
+ case type_Binary:
{
ColumnBinary* c = new ColumnBinary(alloc);
m_columns.add(c->GetRef());
@@ -123,7 +123,7 @@ void Table::CreateColumns()
new_col = c;
}
break;
- case COLUMN_TYPE_TABLE:
+ case type_Table:
{
const size_t column_ndx = m_cols.Size();
const size_t subspec_ref = m_spec_set.get_subspec_ref(subtable_count);
@@ -134,7 +134,7 @@ void Table::CreateColumns()
++subtable_count;
}
break;
- case COLUMN_TYPE_MIXED:
+ case type_Mixed:
{
const size_t column_ndx = m_cols.Size();
ColumnMixed* c = new ColumnMixed(alloc, this, column_ndx);
@@ -145,8 +145,8 @@ void Table::CreateColumns()
break;
// Attributes
- case COLUMN_ATTR_INDEXED:
- case COLUMN_ATTR_UNIQUE:
+ case col_attr_Indexed:
+ case col_attr_Unique:
attr = type;
continue; // attr prefix column types)
@@ -158,11 +158,11 @@ void Table::CreateColumns()
m_cols.add(reinterpret_cast(new_col)); // FIXME: intptr_t is not guaranteed to exists, not even in C++11
// Atributes on columns may define that they come with an index
- if (attr != COLUMN_ATTR_NONE) {
+ if (attr != col_attr_None) {
const size_t column_ndx = m_cols.Size()-1;
set_index(column_ndx, false);
- attr = COLUMN_ATTR_NONE;
+ attr = col_attr_None;
}
}
}
@@ -200,7 +200,7 @@ void Table::invalidate()
void Table::InstantiateBeforeChange()
{
// Empty (zero-ref'ed) tables need to be instantiated before first modification
- if (!m_columns.IsValid())
+ if (!m_columns.IsValid())
CreateColumns();
}
@@ -209,7 +209,7 @@ void Table::CacheColumns()
TIGHTDB_ASSERT(m_cols.is_empty()); // only done on creation
Allocator& alloc = m_columns.GetAllocator();
- ColumnType attr = COLUMN_ATTR_NONE;
+ ColumnType attr = col_attr_None;
size_t size = size_t(-1);
size_t ndx_in_parent = 0;
const size_t count = m_spec_set.get_type_attr_count();
@@ -223,30 +223,30 @@ void Table::CacheColumns()
ColumnBase* new_col = 0;
size_t colsize = size_t(-1);
switch (type) {
- case COLUMN_TYPE_INT:
- case COLUMN_TYPE_BOOL:
- case COLUMN_TYPE_DATE:
+ case type_Int:
+ case type_Bool:
+ case type_Date:
{
Column* c = new Column(ref, &m_columns, ndx_in_parent, alloc);
colsize = c->Size();
new_col = c;
}
break;
- case COLUMN_TYPE_FLOAT:
+ case type_Float:
{
ColumnFloat* c = new ColumnFloat(ref, &m_columns, ndx_in_parent, alloc);
colsize = c->Size();
new_col = c;
}
break;
- case COLUMN_TYPE_DOUBLE:
+ case type_Double:
{
ColumnDouble* c = new ColumnDouble(ref, &m_columns, ndx_in_parent, alloc);
colsize = c->Size();
new_col = c;
}
break;
- case COLUMN_TYPE_STRING:
+ case type_String:
{
AdaptiveStringColumn* c =
new AdaptiveStringColumn(ref, &m_columns, ndx_in_parent, alloc);
@@ -254,14 +254,14 @@ void Table::CacheColumns()
new_col = c;
}
break;
- case COLUMN_TYPE_BINARY:
+ case type_Binary:
{
ColumnBinary* c = new ColumnBinary(ref, &m_columns, ndx_in_parent, alloc);
colsize = c->Size();
new_col = c;
}
break;
- case COLUMN_TYPE_STRING_ENUM:
+ case col_type_StringEnum:
{
const size_t values_ref = m_columns.GetAsRef(ndx_in_parent+1);
ColumnStringEnum* c =
@@ -271,7 +271,7 @@ void Table::CacheColumns()
++ndx_in_parent; // advance one matchcount pos to account for keys/values pair
}
break;
- case COLUMN_TYPE_TABLE:
+ case type_Table:
{
const size_t column_ndx = m_cols.Size();
const size_t spec_ref = m_spec_set.get_subspec_ref(subtable_count);
@@ -282,7 +282,7 @@ void Table::CacheColumns()
++subtable_count;
}
break;
- case COLUMN_TYPE_MIXED:
+ case type_Mixed:
{
const size_t column_ndx = m_cols.Size();
ColumnMixed* c =
@@ -293,8 +293,8 @@ void Table::CacheColumns()
break;
// Attributes (prefixing column types)
- case COLUMN_ATTR_INDEXED:
- case COLUMN_ATTR_UNIQUE:
+ case col_attr_Indexed:
+ case col_attr_Unique:
attr = type;
continue;
@@ -305,17 +305,17 @@ void Table::CacheColumns()
m_cols.add(reinterpret_cast(new_col)); // FIXME: intptr_t is not guaranteed to exists, even in C++11
// Atributes on columns may define that they come with an index
- if (attr != COLUMN_ATTR_NONE) {
- TIGHTDB_ASSERT(attr == COLUMN_ATTR_INDEXED); // only attribute supported for now
- TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING ||
- type == COLUMN_TYPE_STRING_ENUM); // index only for strings
+ if (attr != col_attr_None) {
+ TIGHTDB_ASSERT(attr == col_attr_Indexed); // only attribute supported for now
+ TIGHTDB_ASSERT(type == col_type_String ||
+ type == col_type_StringEnum); // index only for strings
const size_t pndx = ndx_in_parent+1;
const size_t index_ref = m_columns.GetAsRef(pndx);
new_col->SetIndexRef(index_ref, &m_columns, pndx);
++ndx_in_parent; // advance one matchcount pos to account for index
- attr = COLUMN_ATTR_NONE;
+ attr = col_attr_None;
}
// Set table size
@@ -391,36 +391,6 @@ Table::~Table()
m_top.Destroy();
}
-size_t Table::get_column_count() const TIGHTDB_NOEXCEPT
-{
- return m_spec_set.get_column_count();
-}
-
-const char* Table::get_column_name(size_t ndx) const TIGHTDB_NOEXCEPT
-{
- TIGHTDB_ASSERT(ndx < get_column_count());
- return m_spec_set.get_column_name(ndx);
-}
-
-size_t Table::get_column_index(const char* name) const
-{
- return m_spec_set.get_column_index(name);
-}
-
-ColumnType Table::GetRealColumnType(size_t ndx) const TIGHTDB_NOEXCEPT
-{
- TIGHTDB_ASSERT(ndx < get_column_count());
- return m_spec_set.get_real_column_type(ndx);
-}
-
-ColumnType Table::get_column_type(size_t ndx) const TIGHTDB_NOEXCEPT
-{
- TIGHTDB_ASSERT(ndx < get_column_count());
-
- // Hides internal types like COLUM_STRING_ENUM
- return m_spec_set.get_column_type(ndx);
-}
-
size_t Table::GetColumnRefPos(size_t column_ndx) const
{
size_t pos = 0;
@@ -433,9 +403,9 @@ size_t Table::GetColumnRefPos(size_t column_ndx) const
++pos;
const ColumnType type = (ColumnType)m_spec_set.get_type_attr(i);
- if (type >= COLUMN_ATTR_INDEXED)
+ if (type >= col_attr_Indexed)
continue; // ignore attributes
- if (type == COLUMN_TYPE_STRING_ENUM)
+ if (type == col_type_StringEnum)
++pos; // string enums take up two places in m_columns
++current_column;
@@ -445,7 +415,7 @@ size_t Table::GetColumnRefPos(size_t column_ndx) const
return (size_t)-1;
}
-size_t Table::add_subcolumn(const vector& column_path, ColumnType type, const char* name)
+size_t Table::add_subcolumn(const vector& column_path, DataType type, const char* name)
{
TIGHTDB_ASSERT(!column_path.empty());
@@ -465,14 +435,14 @@ size_t Table::add_subcolumn(const vector& column_path, ColumnType type,
return column_ndx;
}
-void Table::do_add_subcolumn(const vector& column_path, size_t pos, ColumnType type)
+void Table::do_add_subcolumn(const vector& column_path, size_t pos, DataType type)
{
const size_t column_ndx = column_path[pos];
const bool is_last = (pos == column_path.size()-1);
#ifdef TIGHTDB_DEBUG
- const ColumnType stype = GetRealColumnType(column_ndx);
- TIGHTDB_ASSERT(stype == COLUMN_TYPE_TABLE);
+ const ColumnType stype = get_real_column_type(column_ndx);
+ TIGHTDB_ASSERT(stype == col_type_Table);
#endif // TIGHTDB_DEBUG
const size_t row_count = size();
@@ -489,7 +459,7 @@ void Table::do_add_subcolumn(const vector& column_path, size_t pos, Colu
}
}
-size_t Table::add_column(ColumnType type, const char* name)
+size_t Table::add_column(DataType type, const char* name)
{
// Create column and add cached instance
const size_t column_ndx = do_add_column(type);
@@ -498,7 +468,7 @@ size_t Table::add_column(ColumnType type, const char* name)
m_spec_set.add_column(type, name);
// Since subspec was not set at creation time we have to set it now
- if (type == COLUMN_TYPE_TABLE) {
+ if (type == type_Table) {
const size_t subspec_ref = m_spec_set.get_subspec_ref(m_spec_set.get_num_subspecs()-1);
ColumnTable& c = GetColumnTable(column_ndx);
c.set_specref(subspec_ref);
@@ -511,7 +481,7 @@ size_t Table::add_column(ColumnType type, const char* name)
return column_ndx;
}
-size_t Table::do_add_column(ColumnType type)
+size_t Table::do_add_column(DataType type)
{
const size_t count = size();
const size_t column_ndx = m_cols.Size();
@@ -520,9 +490,9 @@ size_t Table::do_add_column(ColumnType type)
Allocator& alloc = m_columns.GetAllocator();
switch (type) {
- case COLUMN_TYPE_INT:
- case COLUMN_TYPE_BOOL:
- case COLUMN_TYPE_DATE:
+ case type_Int:
+ case type_Bool:
+ case type_Date:
{
Column* c = new Column(COLUMN_NORMAL, alloc);
m_columns.add(c->GetRef());
@@ -531,7 +501,7 @@ size_t Table::do_add_column(ColumnType type)
c->fill(count);
}
break;
- case COLUMN_TYPE_FLOAT:
+ case type_Float:
{
ColumnFloat* c = new ColumnFloat(alloc);
m_columns.add(c->GetRef());
@@ -540,7 +510,7 @@ size_t Table::do_add_column(ColumnType type)
c->fill(count);
}
break;
- case COLUMN_TYPE_DOUBLE:
+ case type_Double:
{
ColumnDouble* c = new ColumnDouble(alloc);
m_columns.add(c->GetRef());
@@ -549,7 +519,7 @@ size_t Table::do_add_column(ColumnType type)
c->fill(count);
}
break;
- case COLUMN_TYPE_STRING:
+ case type_String:
{
AdaptiveStringColumn* c = new AdaptiveStringColumn(alloc);
m_columns.add(c->GetRef());
@@ -558,7 +528,7 @@ size_t Table::do_add_column(ColumnType type)
c->fill(count);
}
break;
- case COLUMN_TYPE_BINARY:
+ case type_Binary:
{
ColumnBinary* c = new ColumnBinary(alloc);
m_columns.add(c->GetRef());
@@ -568,7 +538,7 @@ size_t Table::do_add_column(ColumnType type)
}
break;
- case COLUMN_TYPE_TABLE:
+ case type_Table:
{
ColumnTable* c = new ColumnTable(alloc, this, column_ndx, -1); // subspec ref will be filled in later
m_columns.add(c->GetRef());
@@ -578,7 +548,7 @@ size_t Table::do_add_column(ColumnType type)
}
break;
- case COLUMN_TYPE_MIXED:
+ case type_Mixed:
{
ColumnMixed* c = new ColumnMixed(alloc, this, column_ndx);
m_columns.add(c->GetRef());
@@ -587,8 +557,6 @@ size_t Table::do_add_column(ColumnType type)
c->fill(count);
}
break;
- default:
- TIGHTDB_ASSERT(false);
}
m_cols.add(reinterpret_cast(new_col)); // FIXME: intptr_t is not guaranteed to exists, even in C++11
@@ -655,8 +623,8 @@ void Table::do_remove_column(const vector& column_path, size_t pos)
}
else {
#ifdef TIGHTDB_DEBUG
- const ColumnType type = GetRealColumnType(column_ndx);
- TIGHTDB_ASSERT(type == COLUMN_TYPE_TABLE);
+ const ColumnType type = get_real_column_type(column_ndx);
+ TIGHTDB_ASSERT(type == col_type_Table);
#endif // TIGHTDB_DEBUG
const size_t row_count = size();
@@ -693,11 +661,11 @@ void Table::set_index(size_t column_ndx, bool update_spec)
TIGHTDB_ASSERT(column_ndx < get_column_count());
if (has_index(column_ndx)) return;
- const ColumnType ct = GetRealColumnType(column_ndx);
+ const ColumnType ct = get_real_column_type(column_ndx);
const size_t column_pos = GetColumnRefPos(column_ndx);
size_t ndx_ref = -1;
- if (ct == COLUMN_TYPE_STRING) {
+ if (ct == col_type_String) {
AdaptiveStringColumn& col = GetColumnString(column_ndx);
// Create the index
@@ -705,7 +673,7 @@ void Table::set_index(size_t column_ndx, bool update_spec)
ndx.SetParent(&m_columns, column_pos+1);
ndx_ref = ndx.GetRef();
}
- else if (ct == COLUMN_TYPE_STRING_ENUM) {
+ else if (ct == col_type_StringEnum) {
ColumnStringEnum& col = GetColumnStringEnum(column_ndx);
// Create the index
@@ -724,7 +692,7 @@ void Table::set_index(size_t column_ndx, bool update_spec)
// Update spec
if (update_spec)
- m_spec_set.set_column_attr(column_ndx, COLUMN_ATTR_INDEXED);
+ m_spec_set.set_column_attr(column_ndx, col_attr_Indexed);
#ifdef TIGHTDB_ENABLE_REPLICATION
transact_log().add_index_to_column(column_ndx); // Throws
@@ -751,41 +719,42 @@ const ColumnBase& Table::GetColumnBase(size_t ndx) const TIGHTDB_NOEXCEPT
void Table::validate_column_type(const ColumnBase& column, ColumnType coltype, size_t ndx) const
{
- if (coltype == COLUMN_TYPE_INT || coltype == COLUMN_TYPE_DATE || coltype == COLUMN_TYPE_BOOL) {
+ if (coltype == col_type_Int || coltype == col_type_Date || coltype == col_type_Bool) {
TIGHTDB_ASSERT(column.IsIntColumn());
- } else {
- TIGHTDB_ASSERT(coltype == GetRealColumnType(ndx));
}
- (void)column;
- (void)ndx;
+ else {
+ TIGHTDB_ASSERT(coltype == get_real_column_type(ndx));
+ }
+ static_cast(column);
+ static_cast(ndx);
}
// TODO: get rid of the Column* template parameter
-Column& Table::GetColumn(size_t ndx) { return GetColumn(ndx); }
-const Column& Table::GetColumn(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
+Column& Table::GetColumn(size_t ndx) { return GetColumn(ndx); }
+const Column& Table::GetColumn(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
-AdaptiveStringColumn& Table::GetColumnString(size_t ndx) { return GetColumn(ndx); }
-const AdaptiveStringColumn& Table::GetColumnString(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
+AdaptiveStringColumn& Table::GetColumnString(size_t ndx) { return GetColumn(ndx); }
+const AdaptiveStringColumn& Table::GetColumnString(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
-ColumnStringEnum& Table::GetColumnStringEnum(size_t ndx) { return GetColumn(ndx); }
-const ColumnStringEnum& Table::GetColumnStringEnum(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
+ColumnStringEnum& Table::GetColumnStringEnum(size_t ndx) { return GetColumn(ndx); }
+const ColumnStringEnum& Table::GetColumnStringEnum(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
-ColumnFloat& Table::GetColumnFloat(size_t ndx) { return GetColumn(ndx); }
-const ColumnFloat& Table::GetColumnFloat(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
+ColumnFloat& Table::GetColumnFloat(size_t ndx) { return GetColumn(ndx); }
+const ColumnFloat& Table::GetColumnFloat(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
-ColumnDouble& Table::GetColumnDouble(size_t ndx) { return GetColumn(ndx); }
-const ColumnDouble& Table::GetColumnDouble(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
+ColumnDouble& Table::GetColumnDouble(size_t ndx) { return GetColumn(ndx); }
+const ColumnDouble& Table::GetColumnDouble(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
-ColumnBinary& Table::GetColumnBinary(size_t ndx) { return GetColumn(ndx); }
-const ColumnBinary& Table::GetColumnBinary(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
+ColumnBinary& Table::GetColumnBinary(size_t ndx) { return GetColumn(ndx); }
+const ColumnBinary& Table::GetColumnBinary(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
-ColumnTable &Table::GetColumnTable(size_t ndx) { return GetColumn(ndx); }
-const ColumnTable &Table::GetColumnTable(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
+ColumnTable &Table::GetColumnTable(size_t ndx) { return GetColumn(ndx); }
+const ColumnTable &Table::GetColumnTable(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
-ColumnMixed& Table::GetColumnMixed(size_t ndx) { return GetColumn(ndx); }
-const ColumnMixed& Table::GetColumnMixed(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
+ColumnMixed& Table::GetColumnMixed(size_t ndx) { return GetColumn(ndx); }
+const ColumnMixed& Table::GetColumnMixed(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); }
@@ -863,7 +832,7 @@ void Table::remove(size_t ndx)
void Table::insert_subtable(size_t column_ndx, size_t ndx)
{
TIGHTDB_ASSERT(column_ndx < get_column_count());
- TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_TABLE);
+ TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Table);
TIGHTDB_ASSERT(ndx <= m_size);
ColumnTable& subtables = GetColumnTable(column_ndx);
@@ -880,12 +849,12 @@ Table* Table::get_subtable_ptr(size_t col_idx, size_t row_idx)
TIGHTDB_ASSERT(col_idx < get_column_count());
TIGHTDB_ASSERT(row_idx < m_size);
- const ColumnType type = GetRealColumnType(col_idx);
- if (type == COLUMN_TYPE_TABLE) {
+ const ColumnType type = get_real_column_type(col_idx);
+ if (type == col_type_Table) {
ColumnTable& subtables = GetColumnTable(col_idx);
return subtables.get_subtable_ptr(row_idx);
}
- if (type == COLUMN_TYPE_MIXED) {
+ if (type == col_type_Mixed) {
ColumnMixed& subtables = GetColumnMixed(col_idx);
return subtables.get_subtable_ptr(row_idx);
}
@@ -898,12 +867,12 @@ const Table* Table::get_subtable_ptr(size_t col_idx, size_t row_idx) const
TIGHTDB_ASSERT(col_idx < get_column_count());
TIGHTDB_ASSERT(row_idx < m_size);
- const ColumnType type = GetRealColumnType(col_idx);
- if (type == COLUMN_TYPE_TABLE) {
+ const ColumnType type = get_real_column_type(col_idx);
+ if (type == col_type_Table) {
const ColumnTable& subtables = GetColumnTable(col_idx);
return subtables.get_subtable_ptr(row_idx);
}
- if (type == COLUMN_TYPE_MIXED) {
+ if (type == col_type_Mixed) {
const ColumnMixed& subtables = GetColumnMixed(col_idx);
return subtables.get_subtable_ptr(row_idx);
}
@@ -916,12 +885,12 @@ size_t Table::get_subtable_size(size_t col_idx, size_t row_idx) const TIGHTDB_NO
TIGHTDB_ASSERT(col_idx < get_column_count());
TIGHTDB_ASSERT(row_idx < m_size);
- const ColumnType type = GetRealColumnType(col_idx);
- if (type == COLUMN_TYPE_TABLE) {
+ const ColumnType type = get_real_column_type(col_idx);
+ if (type == col_type_Table) {
const ColumnTable& subtables = GetColumnTable(col_idx);
return subtables.get_subtable_size(row_idx);
}
- if (type == COLUMN_TYPE_MIXED) {
+ if (type == col_type_Mixed) {
const ColumnMixed& subtables = GetColumnMixed(col_idx);
return subtables.get_subtable_size(row_idx);
}
@@ -934,8 +903,8 @@ void Table::clear_subtable(size_t col_idx, size_t row_idx)
TIGHTDB_ASSERT(col_idx < get_column_count());
TIGHTDB_ASSERT(row_idx <= m_size);
- const ColumnType type = GetRealColumnType(col_idx);
- if (type == COLUMN_TYPE_TABLE) {
+ const ColumnType type = get_real_column_type(col_idx);
+ if (type == col_type_Table) {
ColumnTable& subtables = GetColumnTable(col_idx);
subtables.ClearTable(row_idx);
subtables.invalidate_subtables();
@@ -944,7 +913,7 @@ void Table::clear_subtable(size_t col_idx, size_t row_idx)
transact_log().set_value(col_idx, row_idx, Replication::subtable_tag()); // Throws
#endif
}
- else if (type == COLUMN_TYPE_MIXED) {
+ else if (type == col_type_Mixed) {
ColumnMixed& subtables = GetColumnMixed(col_idx);
subtables.set_subtable(row_idx);
subtables.invalidate_subtables();
@@ -984,7 +953,7 @@ void Table::set_int(size_t column_ndx, size_t ndx, int64_t value)
void Table::add_int(size_t column_ndx, int64_t value)
{
TIGHTDB_ASSERT(column_ndx < get_column_count());
- TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_INT);
+ TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Int);
GetColumn(column_ndx).Increment64(value);
#ifdef TIGHTDB_ENABLE_REPLICATION
@@ -996,7 +965,7 @@ void Table::add_int(size_t column_ndx, int64_t value)
bool Table::get_bool(size_t column_ndx, size_t ndx) const TIGHTDB_NOEXCEPT
{
TIGHTDB_ASSERT(column_ndx < get_column_count());
- TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_BOOL);
+ TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Bool);
TIGHTDB_ASSERT(ndx < m_size);
const Column& column = GetColumn(column_ndx);
@@ -1006,7 +975,7 @@ bool Table::get_bool(size_t column_ndx, size_t ndx) const TIGHTDB_NOEXCEPT
void Table::set_bool(size_t column_ndx, size_t ndx, bool value)
{
TIGHTDB_ASSERT(column_ndx < get_column_count());
- TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_BOOL);
+ TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Bool);
TIGHTDB_ASSERT(ndx < m_size);
Column& column = GetColumn(column_ndx);
@@ -1020,21 +989,21 @@ void Table::set_bool(size_t column_ndx, size_t ndx, bool value)
time_t Table::get_date(size_t column_ndx, size_t ndx) const TIGHTDB_NOEXCEPT
{
TIGHTDB_ASSERT(column_ndx < get_column_count());
- TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_DATE);
+ TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Date);
TIGHTDB_ASSERT(ndx < m_size);
const Column& column = GetColumn(column_ndx);
- return (time_t)column.Get(ndx);
+ return time_t(column.Get(ndx));
}
void Table::set_date(size_t column_ndx, size_t ndx, time_t value)
{
TIGHTDB_ASSERT(column_ndx < get_column_count());
- TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_DATE);
+ TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Date);
TIGHTDB_ASSERT(ndx < m_size);
Column& column = GetColumn(column_ndx);
- column.Set(ndx, (int64_t)value);
+ column.Set(ndx, int64_t(value));
#ifdef TIGHTDB_ENABLE_REPLICATION
transact_log().set_value(column_ndx, ndx, value); // Throws
@@ -1136,14 +1105,14 @@ const char* Table::get_string(size_t column_ndx, size_t ndx) const TIGHTDB_NOEXC
TIGHTDB_ASSERT(column_ndx < m_columns.Size());
TIGHTDB_ASSERT(ndx < m_size);
- const ColumnType type = GetRealColumnType(column_ndx);
+ const ColumnType type = get_real_column_type(column_ndx);
- if (type == COLUMN_TYPE_STRING) {
+ if (type == col_type_String) {
const AdaptiveStringColumn& column = GetColumnString(column_ndx);
return column.Get(ndx);
}
else {
- TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM);
+ TIGHTDB_ASSERT(type == col_type_StringEnum);
const ColumnStringEnum& column = GetColumnStringEnum(column_ndx);
return column.Get(ndx);
}
@@ -1160,14 +1129,14 @@ void Table::set_string(size_t column_ndx, size_t ndx, const char* value)
TIGHTDB_ASSERT(column_ndx < get_column_count());
TIGHTDB_ASSERT(ndx < m_size);
- const ColumnType type = GetRealColumnType(column_ndx);
+ const ColumnType type = get_real_column_type(column_ndx);
- if (type == COLUMN_TYPE_STRING) {
+ if (type == col_type_String) {
AdaptiveStringColumn& column = GetColumnString(column_ndx);
column.Set(ndx, value);
}
else {
- TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM);
+ TIGHTDB_ASSERT(type == col_type_StringEnum);
ColumnStringEnum& column = GetColumnStringEnum(column_ndx);
column.Set(ndx, value);
}
@@ -1182,14 +1151,14 @@ void Table::insert_string(size_t column_ndx, size_t ndx, const char* value)
TIGHTDB_ASSERT(column_ndx < get_column_count());
TIGHTDB_ASSERT(ndx <= m_size);
- const ColumnType type = GetRealColumnType(column_ndx);
+ const ColumnType type = get_real_column_type(column_ndx);
- if (type == COLUMN_TYPE_STRING) {
+ if (type == col_type_String) {
AdaptiveStringColumn& column = GetColumnString(column_ndx);
column.Insert(ndx, value);
}
else {
- TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM);
+ TIGHTDB_ASSERT(type == col_type_StringEnum);
ColumnStringEnum& column = GetColumnStringEnum(column_ndx);
column.Insert(ndx, value);
}
@@ -1242,38 +1211,39 @@ Mixed Table::get_mixed(size_t column_ndx, size_t ndx) const
TIGHTDB_ASSERT(ndx < m_size);
const ColumnMixed& column = GetColumnMixed(column_ndx);
- const ColumnType type = column.GetType(ndx);
+ const DataType type = column.get_type(ndx);
switch (type) {
- case COLUMN_TYPE_INT:
+ case type_Int:
return Mixed(column.get_int(ndx));
- case COLUMN_TYPE_BOOL:
+ case type_Bool:
return Mixed(column.get_bool(ndx));
- case COLUMN_TYPE_DATE:
+ case type_Date:
return Mixed(Date(column.get_date(ndx)));
- case COLUMN_TYPE_FLOAT:
+ case type_Float:
return Mixed(column.get_float(ndx));
- case COLUMN_TYPE_DOUBLE:
+ case type_Double:
return Mixed(column.get_double(ndx));
- case COLUMN_TYPE_STRING:
+ case type_String:
return Mixed(column.get_string(ndx)); // Throws
- case COLUMN_TYPE_BINARY:
+ case type_Binary:
return Mixed(column.get_binary(ndx)); // Throws
- case COLUMN_TYPE_TABLE:
+ case type_Table:
return Mixed::subtable_tag();
- default:
- TIGHTDB_ASSERT(false);
- return Mixed((int64_t)0);
+ case type_Mixed:
+ break;
}
+ TIGHTDB_ASSERT(false);
+ return Mixed((int64_t)0);
}
-ColumnType Table::get_mixed_type(size_t column_ndx, size_t ndx) const TIGHTDB_NOEXCEPT
+DataType Table::get_mixed_type(size_t column_ndx, size_t ndx) const TIGHTDB_NOEXCEPT
{
TIGHTDB_ASSERT(column_ndx < m_columns.Size());
TIGHTDB_ASSERT(ndx < m_size);
const ColumnMixed& column = GetColumnMixed(column_ndx);
- return column.GetType(ndx);
+ return column.get_type(ndx);
}
void Table::set_mixed(size_t column_ndx, size_t ndx, Mixed value)
@@ -1282,38 +1252,38 @@ void Table::set_mixed(size_t column_ndx, size_t ndx, Mixed value)
TIGHTDB_ASSERT(ndx < m_size);
ColumnMixed& column = GetColumnMixed(column_ndx);
- const ColumnType type = value.get_type();
+ const DataType type = value.get_type();
switch (type) {
- case COLUMN_TYPE_INT:
+ case type_Int:
column.set_int(ndx, value.get_int());
break;
- case COLUMN_TYPE_BOOL:
+ case type_Bool:
column.set_bool(ndx, value.get_bool());
break;
- case COLUMN_TYPE_DATE:
+ case type_Date:
column.set_date(ndx, value.get_date());
break;
- case COLUMN_TYPE_FLOAT:
+ case type_Float:
column.set_float(ndx, value.get_float());
break;
- case COLUMN_TYPE_DOUBLE:
+ case type_Double:
column.set_double(ndx, value.get_double());
break;
- case COLUMN_TYPE_STRING:
+ case type_String:
column.set_string(ndx, value.get_string());
break;
- case COLUMN_TYPE_BINARY:
- {
+ case type_Binary: {
const BinaryData b = value.get_binary();
- column.set_binary(ndx, (const char*)b.pointer, b.len);
+ column.set_binary(ndx, b.pointer, b.len);
break;
}
- case COLUMN_TYPE_TABLE:
+ case type_Table:
column.set_subtable(ndx);
break;
- default:
+ case type_Mixed:
TIGHTDB_ASSERT(false);
+ break;
}
column.invalidate_subtables();
@@ -1328,38 +1298,38 @@ void Table::insert_mixed(size_t column_ndx, size_t ndx, Mixed value) {
TIGHTDB_ASSERT(ndx <= m_size);
ColumnMixed& column = GetColumnMixed(column_ndx);
- const ColumnType type = value.get_type();
+ const DataType type = value.get_type();
switch (type) {
- case COLUMN_TYPE_INT:
+ case type_Int:
column.insert_int(ndx, value.get_int());
break;
- case COLUMN_TYPE_BOOL:
+ case type_Bool:
column.insert_bool(ndx, value.get_bool());
break;
- case COLUMN_TYPE_DATE:
+ case type_Date:
column.insert_date(ndx, value.get_date());
break;
- case COLUMN_TYPE_FLOAT:
+ case type_Float:
column.insert_float(ndx, value.get_float());
break;
- case COLUMN_TYPE_DOUBLE:
+ case type_Double:
column.insert_double(ndx, value.get_double());
break;
- case COLUMN_TYPE_STRING:
+ case type_String:
column.insert_string(ndx, value.get_string());
break;
- case COLUMN_TYPE_BINARY:
- {
+ case type_Binary: {
const BinaryData b = value.get_binary();
- column.insert_binary(ndx, (const char*)b.pointer, b.len);
+ column.insert_binary(ndx, b.pointer, b.len);
break;
}
- case COLUMN_TYPE_TABLE:
+ case type_Table:
column.insert_subtable(ndx);
break;
- default:
+ case type_Mixed:
TIGHTDB_ASSERT(false);
+ break;
}
column.invalidate_subtables();
@@ -1387,17 +1357,17 @@ void Table::insert_done()
size_t Table::count_int(size_t column_ndx, int64_t target) const
{
- const Column& column = GetColumn(column_ndx);
+ const Column& column = GetColumn(column_ndx);
return column.count(target);
}
size_t Table::count_float(size_t column_ndx, float target) const
{
- const ColumnFloat& column = GetColumn(column_ndx);
+ const ColumnFloat& column = GetColumn(column_ndx);
return column.count(target);
}
size_t Table::count_double(size_t column_ndx, double target) const
{
- const ColumnDouble& column = GetColumn(column_ndx);
+ const ColumnDouble& column = GetColumn(column_ndx);
return column.count(target);
}
size_t Table::count_string(size_t column_ndx, const char* value) const
@@ -1405,14 +1375,14 @@ size_t Table::count_string(size_t column_ndx, const char* value) const
TIGHTDB_ASSERT(column_ndx < get_column_count());
TIGHTDB_ASSERT(value);
- const ColumnType type = GetRealColumnType(column_ndx);
+ const ColumnType type = get_real_column_type(column_ndx);
- if (type == COLUMN_TYPE_STRING) {
+ if (type == col_type_String) {
const AdaptiveStringColumn& column = GetColumnString(column_ndx);
return column.count(value);
}
else {
- TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM);
+ TIGHTDB_ASSERT(type == col_type_StringEnum);
const ColumnStringEnum& column = GetColumnStringEnum(column_ndx);
return column.count(value);
}
@@ -1422,17 +1392,17 @@ size_t Table::count_string(size_t column_ndx, const char* value) const
int64_t Table::sum(size_t column_ndx) const
{
- const Column& column = GetColumn(column_ndx);
+ const Column& column = GetColumn(column_ndx);
return column.sum();
}
double Table::sum_float(size_t column_ndx) const
{
- const ColumnFloat& column = GetColumn(column_ndx);
+ const ColumnFloat& column = GetColumn(column_ndx);
return column.sum();
}
double Table::sum_double(size_t column_ndx) const
{
- const ColumnDouble& column = GetColumn(column_ndx);
+ const ColumnDouble& column = GetColumn(column_ndx);
return column.sum();
}
@@ -1440,17 +1410,17 @@ double Table::sum_double(size_t column_ndx) const
double Table::average(size_t column_ndx) const
{
- const Column& column = GetColumn(column_ndx);
+ const Column& column = GetColumn(column_ndx);
return column.average();
}
double Table::average_float(size_t column_ndx) const
{
- const ColumnFloat& column = GetColumn(column_ndx);
+ const ColumnFloat& column = GetColumn(column_ndx);
return column.average();
}
double Table::average_double(size_t column_ndx) const
{
- const ColumnDouble& column = GetColumn(column_ndx);
+ const ColumnDouble& column = GetColumn(column_ndx);
return column.average();
}
@@ -1461,10 +1431,10 @@ double Table::average_double(size_t column_ndx) const
int64_t Table::minimum(size_t column_ndx) const
{
#if USE_COLUMN_AGGREGATE
- const Column& column = GetColumn(column_ndx);
+ const Column& column = GetColumn(column_ndx);
return column.minimum();
#else
- if (is_empty())
+ if (is_empty())
return 0;
int64_t mv = get_int(column_ndx, 0);
@@ -1480,12 +1450,12 @@ int64_t Table::minimum(size_t column_ndx) const
float Table::minimum_float(size_t column_ndx) const
{
- const ColumnFloat& column = GetColumn(column_ndx);
+ const ColumnFloat& column = GetColumn(column_ndx);
return column.minimum();
}
double Table::minimum_double(size_t column_ndx) const
{
- const ColumnDouble& column = GetColumn(column_ndx);
+ const ColumnDouble& column = GetColumn(column_ndx);
return column.minimum();
}
@@ -1494,7 +1464,7 @@ double Table::minimum_double(size_t column_ndx) const
int64_t Table::maximum(size_t column_ndx) const
{
#if USE_COLUMN_AGGREGATE
- const Column& column = GetColumn(column_ndx);
+ const Column& column = GetColumn