Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions include/ParameterSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,20 @@ class ParameterSet {
return *this;
}

/**
* Add a bool value for the current parameter
* @throws ParamMismatchException Supplied parameter is the wrong type for this position or too many have been set
* @return Reference to this parameter set to allow invocation chaining.
*/
ParameterSet& addBool(const bool &val) throw (voltdb::ParamMismatchException) {
validateType(WIRE_TYPE_BOOL, false);
m_buffer.ensureRemaining(2);
m_buffer.putInt8(WIRE_TYPE_BOOL);
m_buffer.putInt8(val ? 1 : 0);
m_currentParam++;
return *this;
}

/**
* Add an array of date values for the current parameter
* @throws ParamMismatchException Supplied parameter is the wrong type for this position or too many have been set
Expand Down
24 changes: 24 additions & 0 deletions include/Row.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ class Row {
return decodeDate(encodedDate);
}

/*
* Retrieve the value at the specified column index as a bool. The type of the column
* must be bool.
* @throws InvalidColumnException The index of the column was invalid or the type of the column does
* not match the type of the get method.
* @return bool te value at the specified column
*/
bool getBool(int32_t column) throw(voltdb::InvalidColumnException) {
validateType(WIRE_TYPE_BOOL, column);
int8_t retval = m_data.getInt8(getOffset(column));
if (retval == INT8_MIN) {
m_wasNull = true;
}
return retval == 1;
}

/*
* Retrieve the value at the specified column index as an int64_t/BIGINT. The type of the column
* must be BIGINT, INTEGER, SMALLINT, or TINYINT.
Expand Down Expand Up @@ -289,6 +305,8 @@ class Row {
getTimestamp(column); break;
case WIRE_TYPE_DATE:
getDate(column); break;
case WIRE_TYPE_BOOL:
getBool(column); break;
case WIRE_TYPE_BIGINT:
getInt64(column); break;
case WIRE_TYPE_INTEGER:
Expand Down Expand Up @@ -505,6 +523,8 @@ class Row {
ostream << getTimestamp(ii); break;
case WIRE_TYPE_DATE:
ostream << getDate(ii); break;
case WIRE_TYPE_BOOL:
ostream << getBool(ii); break;
case WIRE_TYPE_DECIMAL:
ostream << getDecimal(ii).toString(); break;
case WIRE_TYPE_VARBINARY:
Expand Down Expand Up @@ -558,6 +578,7 @@ class Row {
break;
case WIRE_TYPE_TIMESTAMP:
case WIRE_TYPE_DATE:
case WIRE_TYPE_BOOL:
case WIRE_TYPE_BIGINT:
case WIRE_TYPE_FLOAT:
case WIRE_TYPE_STRING:
Expand Down Expand Up @@ -631,6 +652,9 @@ class Row {
case WIRE_TYPE_DATE:
length = 4;
break;
case WIRE_TYPE_BOOL:
length = 1;
break;
case WIRE_TYPE_SMALLINT:
length = 2;
break;
Expand Down
11 changes: 11 additions & 0 deletions include/RowBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ friend class TableTest;
case WIRE_TYPE_TINYINT:
addInt8(INT8_MIN);
break;
case WIRE_TYPE_BOOL:
addInt8(INT8_MIN);
break;
case WIRE_TYPE_SMALLINT:
addInt16(INT16_MIN);
break;
Expand Down Expand Up @@ -208,6 +211,14 @@ friend class TableTest;
return *this;
}

RowBuilder& addBool(const bool &value) throw (InvalidColumnException, RowCreationException) {
validateType(WIRE_TYPE_BOOL);
m_buffer.ensureRemaining(1);
m_buffer.putInt8(value ? 1 : 0);
m_currentColumnIndex++;
return *this;
}

RowBuilder& addDecimal(const Decimal& value) {
validateType(WIRE_TYPE_DECIMAL);
m_buffer.ensureRemaining(2 * sizeof (int64_t));
Expand Down
1 change: 1 addition & 0 deletions include/WireType.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum WireType {
WIRE_TYPE_DATE = 12,
WIRE_TYPE_VOLTTABLE = 21,
WIRE_TYPE_DECIMAL = 22,
WIRE_TYPE_BOOL = 23,
WIRE_TYPE_VARBINARY = 25,
WIRE_TYPE_GEOGRAPHY_POINT = 26,
WIRE_TYPE_GEOGRAPHY = 27,
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ifeq ($(PLATFORM),Linux)
$(THIRD_PARTY_DIR)/libssl.a \
$(THIRD_PARTY_DIR)/libcrypto.a \
-ldl
SYSTEM_LIBS := -L $(BOOST_LIBS) -lc -lpthread -lrt -lboost_system -lboost_thread -lboost_date_time
SYSTEM_LIBS := -L $(BOOST_LIBS) -lc -lpthread -lrt -lboost_system-mt -lboost_thread-mt -lboost_date_time-mt
endif

.PHONEY: all clean test kit
Expand Down
2 changes: 2 additions & 0 deletions src/WireType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ std::string wireTypeToString(WireType type) {
return std::string("TIMESTAMP");
case WIRE_TYPE_DATE:
return std::string("DATE");
case WIRE_TYPE_BOOL:
return std::string("BOOL");
case WIRE_TYPE_DECIMAL:
return std::string("DECIMAL");
case WIRE_TYPE_VARBINARY:
Expand Down
1 change: 1 addition & 0 deletions test_src/SerializationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ static bool compareParameter(ByteBuffer &original, std::string originalName,
}
break;
case WIRE_TYPE_TINYINT:
case WIRE_TYPE_BOOL:
{
int8_t g = generated.getInt8();
int8_t o = original.getInt8();
Expand Down
23 changes: 21 additions & 2 deletions test_src/TableTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

namespace voltdb {

voltdb::WireType allTypes[12] = {
voltdb::WireType allTypes[13] = {
WIRE_TYPE_TINYINT,
WIRE_TYPE_SMALLINT,
WIRE_TYPE_INTEGER,
Expand All @@ -42,6 +42,7 @@ voltdb::WireType allTypes[12] = {
WIRE_TYPE_TIMESTAMP,
WIRE_TYPE_DATE,
WIRE_TYPE_DECIMAL,
WIRE_TYPE_BOOL,
WIRE_TYPE_VARBINARY,
WIRE_TYPE_GEOGRAPHY_POINT,
WIRE_TYPE_GEOGRAPHY,
Expand Down Expand Up @@ -84,7 +85,8 @@ class TableTest : public CppUnit::TestFixture {
<< GeographyPoint(15.3333, 0)
<< GeographyPoint(15.999, 15.666)
<< GeographyPoint(0, 14.1)
<< GeographyPoint(0, 0);;
<< GeographyPoint(0, 0);
m_bool = true;
}

void someMaxValues() {
Expand Down Expand Up @@ -127,6 +129,7 @@ class TableTest : public CppUnit::TestFixture {
uint8_t m_binData[1024];
GeographyPoint m_ptValue;
Geography m_polyValue;
bool m_bool;

int32_t populateRow(RowBuilder &row, bool nullValue) {
int32_t rowSize = 0;
Expand All @@ -142,6 +145,9 @@ class TableTest : public CppUnit::TestFixture {
case WIRE_TYPE_TINYINT:
length = 1;
break;
case WIRE_TYPE_BOOL:
length = 1;
break;
case WIRE_TYPE_SMALLINT:
length = 2;
break;
Expand Down Expand Up @@ -210,6 +216,9 @@ class TableTest : public CppUnit::TestFixture {
case WIRE_TYPE_DATE:
row.addDate(m_dateValue);
return 4;
case WIRE_TYPE_BOOL:
row.addBool(m_bool);
return 1;
case WIRE_TYPE_DECIMAL: {
row.addDecimal(m_decValue);
return 2*sizeof(int64_t);
Expand Down Expand Up @@ -279,6 +288,11 @@ class TableTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(value == m_dateValue);
break;
}
case WIRE_TYPE_BOOL: {
bool value = row.getBool(i);
CPPUNIT_ASSERT(value == m_bool);
break;
}
case WIRE_TYPE_DECIMAL: {
Decimal value = row.getDecimal(i);
CPPUNIT_ASSERT(value == m_decValue);
Expand Down Expand Up @@ -358,6 +372,11 @@ class TableTest : public CppUnit::TestFixture {
break;
}

case WIRE_TYPE_BOOL: {
row.getBool(i);
break;
}

case WIRE_TYPE_DECIMAL: {
row.getDecimal(i);
break;
Expand Down