Skip to content

Commit 7b159b9

Browse files
release300.1.0
1 parent 27db2e9 commit 7b159b9

File tree

208 files changed

+23809
-49326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+23809
-49326
lines changed

include/ConstantFactory.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ class ConstantFactory{
169169
case DT_LONG : return new LongSet(keyType, capacity);
170170
case DT_FLOAT : return new FloatSet(capacity);
171171
case DT_DOUBLE : return new DoubleSet(capacity);
172-
case DT_STRING : return new StringSet(capacity);
172+
case DT_SYMBOL : return new StringSet(capacity, false, true);
173+
case DT_STRING : return new StringSet(capacity, false);
173174
case DT_INT128 : return new Int128Set(keyType, capacity);
175+
case DT_BLOB: return new StringSet(capacity, true);
174176
default : return NULL;
175177
}
176178
}

include/ConstantImp.h

Lines changed: 55 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ class AbstractFastVector: public Vector{
205205
IO_ERR deserialize(DataInputStream* in, INDEX indexStart, INDEX targetNumElement, INDEX& numElement){
206206
IO_ERR ret=OK;
207207
INDEX end = indexStart + targetNumElement;
208-
if(end > capacity_ && !checkCapacity(end - size_))
209-
return NOSPACE;
208+
checkCapacity(end - size_);
209+
210210
INDEX i=indexStart;
211211
size_t unitLength = sizeof(T);
212212
if(!in->isIntegerReversed()){
@@ -693,11 +693,6 @@ class AbstractFastVector: public Vector{
693693
return appendData<long long>(buf, len, type, LLONG_MIN);
694694
}
695695

696-
virtual bool appendInt128(wide_integer::int128* buf, int len){
697-
DATA_TYPE type = getRawType()== DT_DECIMAL128 ? getType() : DT_DECIMAL128;
698-
return appendData<wide_integer::int128>(buf, len, type, std::numeric_limits<wide_integer::int128>::min());
699-
}
700-
701696
virtual bool appendIndex(INDEX* buf, int len){
702697
DATA_TYPE type = getRawType()== DT_INDEX ? getType() : DT_INDEX;
703698
return appendData<INDEX>(buf, len, type, INDEX_MIN);
@@ -950,8 +945,7 @@ class AbstractFastVector: public Vector{
950945

951946
template<typename Y>
952947
inline bool appendData(Y* buf, int len, DATA_TYPE sourceType, Y sourceNullVal){
953-
if(!checkCapacity(len))
954-
return false;
948+
checkCapacity(len);
955949
if(getType() == sourceType)
956950
memcpy(data_+size_, buf, sizeof(Y) * len);
957951
else
@@ -961,7 +955,7 @@ class AbstractFastVector: public Vector{
961955
return true;
962956
}
963957

964-
bool checkCapacity(int appendSize){
958+
void checkCapacity(int appendSize){
965959
if(size_+appendSize>capacity_){
966960
INDEX newCapacity= static_cast<INDEX>((size_ + appendSize) * 1.2);
967961
T* newData = new T[newCapacity];
@@ -970,7 +964,6 @@ class AbstractFastVector: public Vector{
970964
capacity_=newCapacity;
971965
data_=newData;
972966
}
973-
return true;
974967
}
975968

976969
T* getDataArray(const Vector* indexVector, bool& haveNull) const {
@@ -1060,14 +1053,27 @@ class AbstractFastVector: public Vector{
10601053
}
10611054

10621055
void getDataArray(INDEX start, INDEX length, T* buf) const {
1063-
if(length>0)
1064-
memcpy(buf,data_+start,length*sizeof(T));
1056+
if(length>0){
1057+
if(start >= 0 && start + length <= size_){
1058+
memcpy(buf,data_ + start,length * sizeof(T));
1059+
}
1060+
else{
1061+
for(INDEX i = 0; i < length; ++i){
1062+
buf[i] = (start + i >= 0 && start + i < size_) ? data_[start + i] : getNullValue<T>();
1063+
}
1064+
}
1065+
}
10651066
else{
10661067
T* src=data_+start;
10671068
T* dest=buf;
10681069
length=std::abs(length);
10691070
while(length>0){
1070-
*dest=*src;
1071+
if(src >= data_ && src < data_ + size_){
1072+
*dest = *src;
1073+
}
1074+
else{
1075+
*dest = getNullValue<T>();
1076+
}
10711077
++dest;
10721078
--src;
10731079
--length;
@@ -1091,27 +1097,6 @@ class AbstractFastVector: public Vector{
10911097
DATA_TYPE dataType_;
10921098
};
10931099

1094-
template<>
1095-
template<typename Y>
1096-
inline bool AbstractFastVector<wide_integer::int128>::setData(int start, int len, DATA_TYPE sourceType, Y sourceNullVal, const Y* buf){
1097-
(void)sourceType;
1098-
for(int i = 0; i < len; ++i)
1099-
data_[start + i] = (buf[i] == sourceNullVal) ? nullVal_ : static_cast<wide_integer::int128>(buf[i]);
1100-
return true;
1101-
}
1102-
1103-
template<>
1104-
template<typename Y>
1105-
inline bool AbstractFastVector<wide_integer::int128>::appendData(Y* buf, int len, DATA_TYPE sourceType, Y sourceNullVal){
1106-
(void)sourceType;
1107-
if(!checkCapacity(len))
1108-
return false;
1109-
for(int i = 0; i < len; ++i)
1110-
data_[size_ + i]=(buf[i] == sourceNullVal)? nullVal_ : static_cast<wide_integer::int128>(buf[i]);
1111-
size_ += len;
1112-
return true;
1113-
}
1114-
11151100
class FastVoidVector:public AbstractFastVector<char>{
11161101
public:
11171102
FastVoidVector(int sz, int capacity, char* srcData, bool containNull):AbstractFastVector(sz,capacity,srcData,CHAR_MIN, containNull){
@@ -1754,16 +1739,6 @@ class FastNanoTimestampVector:public FastLongVector{
17541739
virtual ConstantSP castTemporal(DATA_TYPE expectType);
17551740
};
17561741

1757-
class FastCompressedVector : public FastCharVector {
1758-
public:
1759-
FastCompressedVector(int sz, int capacity, char* srcData)
1760-
:FastCharVector(sz, capacity, srcData, false){}
1761-
virtual ~FastCompressedVector(){}
1762-
virtual DATA_TYPE getType() const {return DT_COMPRESS;}
1763-
virtual INDEX uncompressedRows() const;
1764-
virtual int asof(const ConstantSP& value) const {throw RuntimeException("asof not supported.");}
1765-
};
1766-
17671742
class FastBoolMatrix:public Matrix, public FastBoolVector{
17681743
public:
17691744
FastBoolMatrix(int colNum, int rowNum, int colCapacity, char* data, bool containNull):Matrix(colNum,rowNum),FastBoolVector(colNum*rowNum,colCapacity*rowNum,data,containNull){setForm(DF_MATRIX);}
@@ -2423,9 +2398,18 @@ class StringVector: public AbstractStringVector{
24232398
virtual bool getString(INDEX start, int len, char** buf) const;
24242399
virtual std::string** getStringConst(INDEX start, int len, std::string** buf) const;
24252400
virtual char** getStringConst(INDEX start, int len, char** buf) const;
2426-
virtual void setString(const std::string& val){data_[0]=val;}
2427-
virtual void setString(INDEX index, const std::string& val){data_[index]=val;}
2401+
virtual void setString(const std::string& val){
2402+
checkString(val);
2403+
data_[0]=val;
2404+
}
2405+
virtual void setString(INDEX index, const std::string& val){
2406+
checkString(val);
2407+
data_[index]=val;
2408+
}
24282409
virtual bool setString(INDEX start, int len, const std::string* buf){
2410+
for(int i = 0; i < len; ++i){
2411+
checkString(*(buf+i));
2412+
}
24292413
copy(buf,buf+len,data_.begin()+start);
24302414
return true;
24312415
}
@@ -2471,6 +2455,9 @@ class StringVector: public AbstractStringVector{
24712455
return end;
24722456
}
24732457

2458+
private:
2459+
void checkString(const std::string& val);
2460+
24742461
private:
24752462
mutable std::vector<std::string> data_;
24762463
bool blob_;
@@ -2538,7 +2525,7 @@ class FastFixedLengthVector : public Vector {
25382525
virtual void neg(){throw IncompatibleTypeException(DT_DOUBLE,type_);}
25392526

25402527
protected:
2541-
bool checkCapacity(int appendSize);
2528+
void checkCapacity(int appendSize);
25422529
ConstantSP retrieve(Vector* index) const;
25432530
unsigned char* getDataArray(const Vector* indexVector, bool& hasNull) const;
25442531
unsigned char** getSegmentDataArray(const Vector* indexVector, bool& hasNull) const;
@@ -2660,8 +2647,7 @@ class FastInt128Vector : public FastRecordVector<Guid, GuidHash> {
26602647
setBinary(index, fixedLength_, buf);
26612648
}
26622649
virtual bool appendString(std::string* strarray, int len) {
2663-
if (!checkCapacity(len))
2664-
return false;
2650+
checkCapacity(len);
26652651
bool haveNull = false;
26662652
unsigned char *pdata = data_ + size_ * fixedLength_;
26672653
for (int i = 0; i < len; i++, strarray++, pdata += fixedLength_) {
@@ -2680,8 +2666,7 @@ class FastInt128Vector : public FastRecordVector<Guid, GuidHash> {
26802666
return true;
26812667
}
26822668
virtual bool appendString(char** buf, int len) {
2683-
if (!checkCapacity(len))
2684-
return false;
2669+
checkCapacity(len);
26852670
bool haveNull = false;
26862671
unsigned char *pdata = data_ + size_ * fixedLength_;
26872672
for (int i = 0; i < len; i++, pdata += fixedLength_) {
@@ -2721,8 +2706,7 @@ class FastUuidVector : public FastInt128Vector {
27212706
setBinary(index, fixedLength_, buf);
27222707
}
27232708
virtual bool appendString(std::string* strarray, int len) {
2724-
if (!checkCapacity(len))
2725-
return false;
2709+
checkCapacity(len);
27262710
bool haveNull = false;
27272711
unsigned char *pdata = data_ + size_ * fixedLength_;
27282712
for (int i = 0; i < len; i++, strarray++, pdata += fixedLength_) {
@@ -2741,8 +2725,7 @@ class FastUuidVector : public FastInt128Vector {
27412725
return true;
27422726
}
27432727
virtual bool appendString(char** buf, int len) {
2744-
if (!checkCapacity(len))
2745-
return false;
2728+
checkCapacity(len);
27462729
bool haveNull = false;
27472730
unsigned char *pdata = data_ + size_ * fixedLength_;
27482731
for (int i = 0; i < len; i++, pdata += fixedLength_) {
@@ -2776,8 +2759,7 @@ class FastIPAddrVector : public FastInt128Vector {
27762759
setBinary(index, fixedLength_, buf);
27772760
}
27782761
virtual bool appendString(std::string* strarray, int len) {
2779-
if (!checkCapacity(len))
2780-
return false;
2762+
checkCapacity(len);
27812763
bool haveNull = false;
27822764
unsigned char *pdata = data_ + size_ * fixedLength_;
27832765
for (int i = 0; i < len; i++, strarray++, pdata += fixedLength_) {
@@ -2796,8 +2778,7 @@ class FastIPAddrVector : public FastInt128Vector {
27962778
return true;
27972779
}
27982780
virtual bool appendString(char** buf, int len) {
2799-
if (!checkCapacity(len))
2800-
return false;
2781+
checkCapacity(len);
28012782
bool haveNull = false;
28022783
unsigned char *pdata = data_ + size_ * fixedLength_;
28032784
for (int i = 0; i < len; i++, pdata += fixedLength_) {
@@ -2868,8 +2849,7 @@ class FastSymbolVector : public AbstractFastVector<int> {
28682849
return ConstantSP(new FastSymbolVector(base_, size_, capacity, data, false));
28692850
}
28702851
virtual bool append(const ConstantSP& value, INDEX appendSize){
2871-
if(!checkCapacity(appendSize))
2872-
return false;
2852+
checkCapacity(appendSize);
28732853

28742854
if(appendSize==1)
28752855
data_[size_] = base_->findAndInsert(value->getString(0));
@@ -2887,16 +2867,14 @@ class FastSymbolVector : public AbstractFastVector<int> {
28872867
return true;
28882868
}
28892869
virtual bool appendString(std::string* buf, int len){
2890-
if(!checkCapacity(len))
2891-
return false;
2870+
checkCapacity(len);
28922871
for(int i=0;i<len;++i)
28932872
data_[size_+i] = base_->findAndInsert(buf[i]);
28942873
size_+=len;
28952874
return true;
28962875
}
28972876
virtual bool appendString(char** buf, int len){
2898-
if(!checkCapacity(len))
2899-
return false;
2877+
checkCapacity(len);
29002878
for(int i=0;i<len;++i)
29012879
data_[size_+i] = base_->findAndInsert(std::string(buf[i]));
29022880
size_+=len;
@@ -3942,10 +3920,7 @@ class FastDecimalVector : public AbstractFastVector<T> {
39423920
return append(value, 0, count);
39433921
}
39443922
bool append(const ConstantSP value, INDEX start, INDEX appendSize) override {
3945-
if (!this->checkCapacity(appendSize)) {
3946-
return false;
3947-
}
3948-
3923+
this->checkCapacity(appendSize);
39493924
// fast path 1: append one element
39503925
if (appendSize == 1 || value->isScalar())
39513926
{
@@ -3990,9 +3965,7 @@ class FastDecimalVector : public AbstractFastVector<T> {
39903965
}
39913966

39923967
bool appendString(std::string *buf, int len) override {
3993-
if (!this->checkCapacity(len)) {
3994-
return false;
3995-
}
3968+
this->checkCapacity(len);
39963969

39973970
std::string errMsg;
39983971
for (int i = 0; i < len; ++i) {
@@ -4009,9 +3982,7 @@ class FastDecimalVector : public AbstractFastVector<T> {
40093982
return true;
40103983
}
40113984
bool appendString(char **buf, int len) override {
4012-
if (!this->checkCapacity(len)) {
4013-
return false;
4014-
}
3985+
this->checkCapacity(len);
40153986

40163987
std::string errMsg;
40173988
for (int i = 0; i < len; ++i) {
@@ -4029,9 +4000,7 @@ class FastDecimalVector : public AbstractFastVector<T> {
40294000
}
40304001
bool appendBool (char* buf, int len) override
40314002
{
4032-
if (!this->checkCapacity(len)) {
4033-
return false;
4034-
}
4003+
this->checkCapacity(len);
40354004
for (int i = 0; i < len; ++i) {
40364005
decimal_util::valueToDecimalraw(buf[i], scale_, data_ + size_ + i);
40374006
if (!containNull_ && buf[i] == CHAR_MIN) {
@@ -4043,9 +4012,7 @@ class FastDecimalVector : public AbstractFastVector<T> {
40434012
}
40444013
bool appendChar (char* buf, int len) override
40454014
{
4046-
if (!this->checkCapacity(len)) {
4047-
return false;
4048-
}
4015+
this->checkCapacity(len);
40494016
for (int i = 0; i < len; ++i) {
40504017
decimal_util::valueToDecimalraw(buf[i], scale_, data_ + size_ + i);
40514018
if (!containNull_ && buf[i] == CHAR_MIN) {
@@ -4057,9 +4024,7 @@ class FastDecimalVector : public AbstractFastVector<T> {
40574024
}
40584025
bool appendDouble (double* buf, int len) override
40594026
{
4060-
if (!this->checkCapacity(len)) {
4061-
return false;
4062-
}
4027+
this->checkCapacity(len);
40634028
for (int i = 0; i < len; ++i) {
40644029
decimal_util::valueToDecimalraw(buf[i], scale_, data_ + size_ + i);
40654030
if (!containNull_ && buf[i] == DBL_NMIN) {
@@ -4071,9 +4036,7 @@ class FastDecimalVector : public AbstractFastVector<T> {
40714036
}
40724037
bool appendFloat (float* buf, int len) override
40734038
{
4074-
if (!this->checkCapacity(len)) {
4075-
return false;
4076-
}
4039+
this->checkCapacity(len);
40774040
for (int i = 0; i < len; ++i) {
40784041
decimal_util::valueToDecimalraw(buf[i], scale_, data_ + size_ + i);
40794042
if (!containNull_ && buf[i] == FLT_NMIN) {
@@ -4085,9 +4048,7 @@ class FastDecimalVector : public AbstractFastVector<T> {
40854048
}
40864049
bool appendInt (int* buf, int len) override
40874050
{
4088-
if (!this->checkCapacity(len)) {
4089-
return false;
4090-
}
4051+
this->checkCapacity(len);
40914052
for (int i = 0; i < len; ++i) {
40924053
decimal_util::valueToDecimalraw(buf[i], scale_, data_ + size_ + i);
40934054
if (!containNull_ && buf[i] == INT_MIN) {
@@ -4099,9 +4060,7 @@ class FastDecimalVector : public AbstractFastVector<T> {
40994060
}
41004061
bool appendLong (long long* buf, int len) override
41014062
{
4102-
if (!this->checkCapacity(len)) {
4103-
return false;
4104-
}
4063+
this->checkCapacity(len);
41054064
for (int i = 0; i < len; ++i) {
41064065
decimal_util::valueToDecimalraw(buf[i], scale_, data_ + size_ + i);
41074066
if (!containNull_ && buf[i] == LLONG_MIN) {
@@ -4113,9 +4072,7 @@ class FastDecimalVector : public AbstractFastVector<T> {
41134072
}
41144073
bool appendShort (short* buf, int len) override
41154074
{
4116-
if (!this->checkCapacity(len)) {
4117-
return false;
4118-
}
4075+
this->checkCapacity(len);
41194076
for (int i = 0; i < len; ++i) {
41204077
decimal_util::valueToDecimalraw(buf[i], scale_, data_ + size_ + i);
41214078
if (!containNull_ && buf[i] == SHRT_MIN) {
@@ -4298,9 +4255,7 @@ class FastDecimalVector : public AbstractFastVector<T> {
42984255
IO_ERR deserialize(DataInputStream *in, INDEX indexStart, INDEX targetNumElement,INDEX &numElement) override {
42994256
IO_ERR ret=OK;
43004257
INDEX end = indexStart + targetNumElement;
4301-
if (end > capacity_ && !this->checkCapacity(end - size_)) {
4302-
return NOSPACE;
4303-
}
4258+
this->checkCapacity(end - size_);
43044259

43054260
INDEX i = indexStart;
43064261
size_t unitLength = sizeof(T);

include/Matrix.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class EXPORT_DECL Matrix{
2020
virtual ConstantSP getColumn(INDEX index) const = 0;
2121
virtual bool setColumn(INDEX index, const ConstantSP& value)=0;
2222
virtual int asof(const ConstantSP& value) const {throw RuntimeException("asof not supported.");}
23+
24+
protected:
25+
void calculateInvalidLength(INDEX colStart, int colLength,INDEX rowStart, int rowLength, int& invalidLenBeginning, int& invalidLenEnding) const;
26+
2327
protected:
2428
int cols_;
2529
int rows_;

0 commit comments

Comments
 (0)