aboutsummaryrefslogtreecommitdiff
path: root/contrib/native/client/src/include
diff options
context:
space:
mode:
authorParth Chandra <pchandra@maprtech.com>2014-12-12 13:50:38 -0800
committerParth Chandra <pchandra@maprtech.com>2014-12-17 22:27:28 -0800
commit33a40e666279c545c83cdcd7f23ee965a03ad873 (patch)
treee4bfbf4aa89e1a16d39b995283c241097b13dc11 /contrib/native/client/src/include
parent709e976d2c583a62cc314df061d21c2b537b76a1 (diff)
DRILL-1869: CPP client - Handle nullable varchar columns with all nulls (fixed slicedByteBuf to handle zero length buffers). Also handle case where server sends a record batch where vector value counts are zero.
Diffstat (limited to 'contrib/native/client/src/include')
-rw-r--r--contrib/native/client/src/include/drill/recordBatch.hpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/contrib/native/client/src/include/drill/recordBatch.hpp b/contrib/native/client/src/include/drill/recordBatch.hpp
index 28377cb18..4abc2de63 100644
--- a/contrib/native/client/src/include/drill/recordBatch.hpp
+++ b/contrib/native/client/src/include/drill/recordBatch.hpp
@@ -72,19 +72,19 @@ class SlicedByteBuf{
public:
//TODO: check the size and offset parameters. What is the largest they can be?
SlicedByteBuf(const ByteBuf_t b, size_t offset, size_t length){
- assert(length>0);
+ assert(length>=0);
this->m_buffer=b;
this->m_start=offset;
- this->m_end=offset+length-1;
+ this->m_end=length>0?offset+length-1:offset;
this->m_length=length;
}
// Carve a sliced buffer out of another sliced buffer
SlicedByteBuf(const SlicedByteBuf& sb, size_t offset, size_t length){
- assert(length>0);
+ assert(length>=0);
this->m_buffer=sb.m_buffer;
this->m_start=sb.m_start+offset;
- this->m_end=sb.m_start+offset+length-1;
+ this->m_end=length>0?sb.m_start+offset+length-1:sb.m_start+offset;
this->m_length=length;
}
@@ -217,9 +217,27 @@ class DECLSPEC_DRILL_CLIENT ValueVectorUnimplemented:public ValueVectorBase{
virtual uint32_t getSize(size_t index) const{ return 0;};
- protected:
- SlicedByteBuf* m_pBuffer;
- size_t m_rowCount;
+};
+
+// Represents a value vector that has all values NULL
+class DECLSPEC_DRILL_CLIENT ValueVectorNull:public ValueVectorBase{
+ public:
+ ValueVectorNull(SlicedByteBuf *b, size_t rowCount):ValueVectorBase(b,rowCount){
+ }
+
+ virtual ~ValueVectorNull(){
+ }
+
+ virtual void getValueAt(size_t index, char* buf, size_t nChars) const{
+ *buf=0; return;
+ }
+
+ virtual uint32_t getSize(size_t index) const{ return 0;};
+
+ virtual bool isNull(size_t index) const {
+ return true;
+ }
+
};
class DECLSPEC_DRILL_CLIENT ValueVectorFixedWidth:public ValueVectorBase{
@@ -821,6 +839,7 @@ class FieldBatch{
// Loads the data into a Value Vector ofappropriate type
ret_t load();
+ ret_t loadNull(size_t nRecords);
const ValueVectorBase * getVector(){
return m_pValueVector;