-
Notifications
You must be signed in to change notification settings - Fork 34
/
CoreConcept.h
3975 lines (3746 loc) · 186 KB
/
CoreConcept.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* CoreConcept.h
*
* Created on: Apr 20, 2017
* Author: dzhou
*/
#ifndef CORECONCEPT_H_
#define CORECONCEPT_H_
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <deque>
#include <algorithm>
#include <chrono>
#include <functional>
#include <atomic>
#include "Types.h"
#include "SmartPointer.h"
#include "Exceptions.h"
#include "Concurrent.h"
#include "LocklessContainer.h"
#include "FlatHashmap.h"
#include "SysIO.h"
#include "DolphinString.h"
#if defined(__GNUC__) && __GNUC__ >= 4
#define LIKELY(x) (__builtin_expect((x), 1))
#define UNLIKELY(x) (__builtin_expect((x), 0))
#else
#define LIKELY(x) (x)
#define UNLIKELY(x) (x)
#endif
#define TRANSIENT(x) x->isTransient() ? x->getValue() : x
using std::string;
using std::vector;
using std::unordered_map;
using std::unordered_set;
using std::set;
using std::deque;
using std::pair;
class AuthenticatedUser;
class BinaryOperator;
class ByteArrayCodeBuffer;
class Heap;
class Object;
class Operator;
class Statement;
class Param;
class FunctionDef;
class Constant;
class Vector;
class Matrix;
class Table;
class Set;
class Dictionary;
class DFSChunkMeta;
class SQLTransaction;
class SQLContext;
class ColumnRef;
class SymbolBase;
class SymbolBaseManager;
class Output;
class Console;
class Session;
class ConstantMarshal;
class ConstantUnmarshal;
class DebugContext;
class DomainSite;
class DomainSitePool;
class ClusterNodes;
class DomainPartition;
class Domain;
class PartitionGuard;
class Function;
struct TableUpdate;
struct TableUpdateSizer;
struct TableUpdateUrgency;
struct LocalTableUpdate;
struct TopicSubscribe;
class SessionThreadCallGuard;
class ReducerContainer;
class DistributedCall;
class JobProperty;
class IoTransaction;
class Decoder;
class VolumeMapper;
class SystemHandle;
typedef SmartPointer<VolumeMapper> VolumeMapperSP;
typedef SmartPointer<Decoder> DecoderSP;
struct JITCfgNode;
struct InferredType;
struct FunctionSignature;
class WindowJoinFunction;
class ColumnContext;
class Transaction;
class Parser;
typedef SmartPointer<AuthenticatedUser> AuthenticatedUserSP;
typedef SmartPointer<ByteArrayCodeBuffer> ByteArrayCodeBufferSP;
typedef SmartPointer<Constant> ConstantSP;
typedef SmartPointer<Vector> VectorSP;
typedef SmartPointer<Matrix> MatrixSP;
typedef SmartPointer<Object> ObjectSP;
typedef SmartPointer<Operator> OperatorSP;
typedef SmartPointer<Statement> StatementSP;
typedef SmartPointer<Param> ParamSP;
typedef SmartPointer<FunctionDef> FunctionDefSP;
typedef SmartPointer<Heap> HeapSP;
typedef SmartPointer<Table> TableSP;
typedef SmartPointer<Set> SetSP;
typedef SmartPointer<Dictionary> DictionarySP;
typedef SmartPointer<DFSChunkMeta> DFSChunkMetaSP;
typedef SmartPointer<SQLTransaction> SQLTransactionSP;
typedef SmartPointer<SQLContext> SQLContextSP;
typedef SmartPointer<ColumnRef> ColumnRefSP;
typedef SmartPointer<SymbolBase> SymbolBaseSP;
typedef SmartPointer<SymbolBaseManager> SymbolBaseManagerSP;
typedef SmartPointer<Output> OutputSP;
typedef SmartPointer<Console> ConsoleSP;
typedef SmartPointer<Session> SessionSP;
typedef SmartPointer<ConstantMarshal> ConstantMarshalSP;
typedef SmartPointer<ConstantUnmarshal> ConstantUnmarshalSP;
typedef SmartPointer<DebugContext> DebugContextSP;
typedef SmartPointer<DomainSite> DomainSiteSP;
typedef SmartPointer<DomainSitePool> DomainSitePoolSP;
typedef SmartPointer<ClusterNodes> ClusterNodesSP;
typedef SmartPointer<DomainPartition> DomainPartitionSP;
typedef SmartPointer<Domain> DomainSP;
typedef SmartPointer<PartitionGuard> PartitionGuardSP;
typedef SmartPointer<TableUpdate> TableUpdateSP;
typedef SmartPointer<GenericBoundedQueue<TableUpdate, TableUpdateSizer, TableUpdateUrgency> > TableUpdateQueueSP;
typedef SmartPointer<TopicSubscribe> TopicSubscribeSP;
typedef SmartPointer<SessionThreadCallGuard> SessionThreadCallGuardSP;
typedef SmartPointer<ReducerContainer> ReducerContainerSP;
typedef SmartPointer<DistributedCall> DistributedCallSP;
typedef SmartPointer<JobProperty> JobPropertySP;
typedef SmartPointer<JITCfgNode> JITCfgNodeSP;
typedef SmartPointer<InferredType> InferredTypeSP;
typedef SmartPointer<FunctionSignature> FunctionSignatureSP;
typedef SmartPointer<WindowJoinFunction> WindowJoinFunctionSP;
typedef SmartPointer<ColumnContext> ColumnContextSP;
typedef SmartPointer<Transaction> TransactionSP;
typedef SmartPointer<Parser> ParserSP;
typedef ConstantSP(*OptrFunc)(const ConstantSP&, const ConstantSP&);
typedef ConstantSP(*OptrFunc2)(Heap* heap, const ConstantSP&, const ConstantSP&);
typedef ConstantSP(*SysFunc)(Heap* heap, vector<ConstantSP>& arguments);
typedef INDEX(*FastFunc)(vector<ConstantSP>& arguments, const ConstantSP& result, INDEX outputStart, bool validate, INDEX inputStart, INDEX inputLen);
typedef ConstantSP(*TemplateOptr)(const ConstantSP&,const ConstantSP&,const string&, OptrFunc, FastFunc, bool);
typedef ConstantSP(*TemplateUserOptr)(Heap* heap, const ConstantSP&,const ConstantSP&, const FunctionDefSP&, bool);
typedef void (*SysProc)(Heap* heap,vector<ConstantSP>& arguments);
typedef std::function<void (StatementSP)> CFGTraversalFunc;
typedef bool (*JitOptimizedFunc)(ConstantSP &ret, Heap* heap, std::vector<ConstantSP> &arguments);
class AuthenticatedUser{
public:
AuthenticatedUser(const string& userId, long long time, int priority, int parallelism, bool isAdmin, bool isGuest, bool execScript, bool unitTest,
bool globalRead, const set<string>& readTables, const set<string>& deniedReadTables,
bool globalInsert, const set<string>& insertTables,const set<string>& deniedInsertTables,
bool globalUpdate, const set<string>& updateTables,const set<string>& deniedUpdateTables,
bool globalDelete, const set<string>& deleteTables,const set<string>& deniedDeleteTables,
bool viewRead, const set<string>& views, const set<string>& deniedViews,
bool dbobjCreate, const set<string>& createDBs, const set<string>& deniedCreateDBs, bool dbobjDelete,
const set<string>& deleteDBs, const set<string>& deniedDeleteDBs, bool dbOwner,
const set<string>& dbOwnerPattern, bool dbManage, const set<string>& allowDbManage, const set<string>& deniedDbManage,
long long queryResultMemLimit, long long taskGroupMemLimit, bool isViewOwner);
AuthenticatedUser(const ConstantSP& userObj);
ConstantSP toTuple() const ;
void setLoginNanoTimeStamp(long long t){loginNanoTimestamp_ = t;}
string getUserId() const {return userId_;}
long long getLoginNanoTimeStamp() const {return loginNanoTimestamp_;}
int getMaxJobPriority() const { return priority_;}
int getMaxJobParallelism() const {return parallelism_;}
inline bool isAdmin() const {return permissionFlag_ & 1;}
inline bool isGuest() const { return permissionFlag_ & 2;}
inline bool canExecScript() const {return permissionFlag_ & 4;}
inline bool canUnitTest() const {return permissionFlag_ & 8;}
inline bool canManageDatabase(const string& name) const { return accessObjectRule((permissionFlag_ & 16), "DM_", "DDM_", name); }
inline bool canReadTable() const { return permissionFlag_ & 32;}
inline bool canWriteTable() const { return canInsertTable() && canUpdateTable() && canDeleteTable(); }
inline bool canInsertTable() const { return permissionFlag_ & (1 << 11);}
inline bool canUpdateTable() const { return permissionFlag_ & (1 << 12);}
inline bool canDeleteTable() const { return permissionFlag_ & (1 << 13);}
inline bool canUseView() const { return permissionFlag_ & 128;}
inline bool canCreateDBObject() const { return permissionFlag_ & 256;}
inline bool canDeleteDBObject() const { return permissionFlag_ & 512;}
inline bool isDBOwner() const { return (permissionFlag_ & 1024) || !dbOwnerPatterns_.empty(); }
bool isViewOwner() const { return permissionFlag_ & (1 << 14); }
bool matchViewOwner(const string& owner) const { return isViewOwner() && getUserId() == owner; }
bool matchDBOwner(const string& obj) const { return matchPattern(permissionFlag_ & 1024, dbOwnerPatterns_, obj); }
bool canReadTable(const string& name) const { return accessTableRule(canReadTable(), "RT_", "DRT_", name); }
bool canWriteTable(const string& name) const { return canInsertTable(name) && canUpdateTable(name) && canDeleteTable(name); }
bool canInsertTable(const string& name) const { return accessTableRule(canInsertTable(), "IT_", "DIT_", name); }
bool canUpdateTable(const string& name) const { return accessTableRule(canUpdateTable(), "UT_", "DUT_", name); }
bool canDeleteTable(const string& name) const { return accessTableRule(canDeleteTable(), "DT_", "DDT_", name); }
bool canReadView(const string& viewName) const { return accessViewRule(canUseView(), viewName); }
bool canCreateDBObject(const string& name) const { return accessObjectRule(canCreateDBObject(), "CD_", "DCD_", name, ""); }
bool canDeleteDBObject(const string& name) const { return accessObjectRule(canDeleteDBObject(), "DD_", "DDD_", name, ""); }
// return 0 if no limit
long long queryResultMemLimit() { return queryResultMemLimit_; }
long long taskGroupMemLimit() { return taskGroupMemLimit_; }
bool isExpired() const {return expired_;}
void expire();
static AuthenticatedUserSP createAdminUser();
static AuthenticatedUserSP createGuestUser();
private:
bool accessObjectRule(bool global, const char* prefix, const char* denyPrefix, const string& objName, const char* objPrefix = "$DB$") const;
bool accessTableRule(bool global, const char* prefix, const char* denyPrefix, const string& tableName, const char* objPrefix = "$DB$") const;
bool accessViewRule(bool global, const string& viewName) const;
bool matchPattern(bool global, const unordered_set<string>& patterns, const string& name) const;
string userId_;
long long loginNanoTimestamp_;
int priority_;
int parallelism_;
/**
* bit0: isAdmin
* bit1: isGuest
* bit2: execute script
* bit3: unit test
* bit4: create or delete databases
* bit5: global read
* bit6: global write(deprecated)
* bit7: use view functions
* bit8: create objects in databases
* bit9: delete objects in databases
* bit10: dbOwner
* bit11: global insert
* bit12: global update
* bit13: global delete
* bit14: view owner
*/
uint32_t permissionFlag_;
std::atomic<bool> expired_;
unordered_set<string> permissions_;
unordered_set<string> dbOwnerPatterns_;
long long queryResultMemLimit_;
long long taskGroupMemLimit_;
};
template<class T>
class Array{
public:
Array(int capacity) : data_(new T[capacity]), size_(0), capacity_(capacity){}
Array(T* data, int size, int capacity): data_(data), size_(size), capacity_(capacity){}
Array(const Array<T>& copy) : size_(copy.size_), capacity_(copy.capacity_){
data_ = new T[size_];
memcpy(data_, copy.data_, sizeof(T) * size_);
}
~Array(){delete[] data_;}
Array<T>* copy(){
T* data = new T[size_];
memcpy(data, data_, sizeof(T) * size_);
return new Array(data, size_, capacity_);
}
Array<T>& operator =(const Array<T>& sp){
size_ = sp.size_;
if(capacity_ >= sp.capacity_){
memcpy(data_, sp.data_, sizeof(T) * size_);
}
else{
delete[] data_;
capacity_ = sp.capacity_;
data_ = new T[capacity_];
memcpy(data_, sp.data_, sizeof(T) * size_);
}
return *this;
}
const T& at(int index) const { return data_[index];}
const T& operator [](int index) const {return data_[index];}
T& operator [](int index) {return data_[index];}
const T* getDataReference() const { return data_;}
bool append(const T& val){
if(size_ >= capacity_)
return false;
data_[size_++] = val;
return true;
}
int size() const {return size_;}
int capacity() const {return capacity_;}
void clear(){ size_ = 0;}
private:
T* data_;
int size_;
int capacity_;
};
template<class T>
class DynamicArray{
public:
DynamicArray(int segmentSizeInBit, int segmentCapacity): dataSegment_(new T*[segmentCapacity]), segmentSize_(1<<segmentSizeInBit),
segmentSizeInBit_(segmentSizeInBit), segmentMask_((1<<segmentSizeInBit) - 1), segmentCapacity_(segmentCapacity),
size_(0), sizeInSegment_(0){}
~DynamicArray(){
for(int i=0; i<sizeInSegment_; ++i)
delete[] dataSegment_[i];
delete[] dataSegment_;
}
const T& at(int index) const { return dataSegment_[index >> segmentSizeInBit_][index & segmentMask_];}
const T& operator [](int index) const { return dataSegment_[index >> segmentSizeInBit_][index & segmentMask_];}
bool push_back(const T& val){
if((size_ >> segmentSizeInBit_) + 1 > sizeInSegment_){
if(sizeInSegment_ >= segmentCapacity_)
return false;
else{
dataSegment_[sizeInSegment_++] = new T[segmentSize_];
}
}
dataSegment_[size_ >> segmentSizeInBit_][size_ & segmentMask_] = val;
++size_;
return true;
}
int size() const {return size_;}
int capacity() const {return segmentSize_ * segmentCapacity_;}
void clear(){
size_ = 0;
sizeInSegment_ = 0;
}
void get(vector<T>& copy, int size){
int start =0;
int s = 0;
while(start < size){
int count = std::min(segmentSize_, size - start);
T* data = dataSegment_[s++];
for(int i=0; i<count; ++i)
copy.push_back(data[i]);
start += count;
}
}
private:
T** dataSegment_;
int segmentSize_; // the number of elements in one segment. it must be the power of 2, e.g. 2, 4, 8, 16...
int segmentSizeInBit_;
int segmentMask_; // 1<<segmentSizeInBit - 1
int segmentCapacity_; // total number of segments available
int size_; // the number of elements
int sizeInSegment_;
};
class ByteArrayCodeBuffer{
public:
ByteArrayCodeBuffer(size_t capacity) : buf_(new char[capacity]), capacity_(capacity), size_(0), constantMap_(0), constants_(0){}
ByteArrayCodeBuffer() : buf_(new char[2048]), capacity_(2048), size_(0), constantMap_(0), constants_(0){}
~ByteArrayCodeBuffer();
IO_ERR write(const char* buffer, int length, int& actualLength);
IO_ERR write(const char* buffer, int length);
IO_ERR write(const ConstantSP& obj);
inline IO_ERR write(const string& buffer){ return write(buffer.c_str(), buffer.length() + 1);}
inline IO_ERR write(const DolphinString& buffer){ return write(buffer.c_str(), buffer.length() + 1);}
inline IO_ERR write(bool val){ return write((const char*)&val, 1);}
inline IO_ERR write(char val){ return write(&val, 1);}
inline IO_ERR write(short val){ return write((const char*)&val, 2);}
inline IO_ERR write(unsigned short val){ return write((const char*)&val, 2);}
inline IO_ERR write(int val){ return write((const char*)&val, 4);}
inline IO_ERR write(long long val){ return write((const char*)&val, 8);}
inline IO_ERR write(float val){ return write((const char*)&val, 4);}
inline IO_ERR write(double val){ return write((const char*)&val, 8);}
size_t size() const { return size_;}
size_t capacity() const { return capacity_;}
const char * getBuffer() const { return buf_;}
void clear();
int getConstantCount() const {return constants_ == 0 ? 0 :constants_->size();}
const ConstantSP& getConstant(int index) const { return constants_->at(index);}
private:
char* buf_;
size_t capacity_;
size_t size_;
unordered_map<long long, int>* constantMap_;
vector<ConstantSP>* constants_;
};
class SymbolBase{
public:
SymbolBase(bool supportOrder = false);
SymbolBase(const vector<DolphinString>& symbols, bool supportOrder = false);
SymbolBase(const string& symbolFile, bool snapshot = false, bool supportOrder=false, bool readOnly = false);
SymbolBase(const string& symbolFile, const DataInputStreamSP& in, bool snapshot = false, bool readOnly = false);
SymbolBase* copy();
bool saveSymbolBase(string& errMsg, bool sync = false);
IO_ERR serialize(int offset, int length, Buffer& buf);
inline bool lastSaveSynchronized() const { return lastSaveSynchronized_;}
inline int find(const DolphinString& symbol){
#ifndef LOCKFREE_SYMBASE
LockGuard<Mutex> guard(&keyMutex_);
#endif
int index = -1;
keyMap_.find(symbol, index);
return index;
}
void find(const char** symbols, int size, int* indices);
int findAndInsert(const DolphinString& symbol);
/**
* This function will acquire the lock and compare the size with the input argument sizeBeforeInsert.
* returns 0 if the size doesn't equal to sizeBeforeInsert.
* returns -1 if some of the input symbols are already existed.
* returns new symbol size after if everything is OK.
*/
int atomicInsert(vector<DolphinString>& symbols, int sizeBeforeInsert);
void getOrdinalCandidate(const DolphinString& symbol, int& ordinal, SmartPointer<Array<int> >& ordinalBase);
void getOrdinalCandidate(const DolphinString& symbol1, const DolphinString& symbol2, int& ordinal1, int& ordinal2, SmartPointer<Array<int> >& ordinalBase);
int* getSortedIndices(bool asc, char nullsOrder, int& length);
inline bool supportOrder() const { return supportOrder_;}
/**
* enableOrdinalBase and disableOrdinalBase can't be used in multi-threading environment.
*/
void enableOrdinalBase();
void disableOrdinalBase();
SmartPointer<Array<int> > getOrdinalBase();
inline const DolphinString& getSymbol(int index) const { return key_[index];}
void getSymbols(int offset, int length, vector<DolphinString>& symbols) const;
int size() const {return key_.size();}
/**
* checkpoint is used for write transactions. When rolling back a transaction,
* one can roll back the in-memory symbol base to the checkpoint.
*/
void setCheckpoint(int n);
inline int getCheckpoint() const { return checkpoint_;}
const Guid& getID(){return baseID_;}
bool isModified(){return modified_;}
int getVersion(){return version_;}
const string& getDBPath() const {return dbPath_;}
void setDBPath(const string& dbPath) { dbPath_ = dbPath;}
string getString() const;
string getString(int start, int length) const;
static int readSymbolBaseVersion(const string symbolFile);
private:
SymbolBase(int size, const DynamicArray<DolphinString>& keys, bool supportOrder = false);
int getOrdinalCandidate(const DolphinString& symbol);
void reAssignOrdinal(int capacity);
bool reload(const string& symbolFile, const DataInputStreamSP& in, bool snapshot = false, bool needTruncate = false);
private:
Guid baseID_;
int interval_;
int version_;
string dbPath_;
int savingPoint_;
int checkpoint_;
bool modified_;
bool lastSaveSynchronized_;
bool supportOrder_;
DynamicArray<DolphinString> key_;
SmartPointer<Array<int> > ordinal_;
#ifndef LOCKFREE_SYMBASE
Mutex keyMutex_;
IrremovableFlatHashmap<DolphinString, int> keyMap_;
#else
IrremovableLocklessFlatHashmap<DolphinString, int> keyMap_;
#endif
deque<int> sortedIndices_;
mutable RWLock writeMutex_;
mutable Mutex versionMutex_;
bool readOnly_ = false;
};
class SymbolBaseManager{
public:
SymbolBaseManager(const string& symbolBaseDir);
SymbolBaseSP findAndLoad(int symBaseID);
SymbolBaseSP findOrInsert(const string& key);
SymbolBaseSP find(const string& key);
void reloadSymbolBase(const string& key);
string getSymbolFile(const string& key);
private:
int checkSymbolBaseVersion(const string& key);
private:
string dir_;
int devId_;
unordered_map<string, SymbolBaseSP> symbases_;
Mutex mutex_;
};
struct ControlFlowEdge {
void * edgeFrom;
void * edgeTo;
string varName;
ControlFlowEdge(void * from, void * to, const string & name): edgeFrom(from), edgeTo(to), varName(name) {}
bool operator==(const ControlFlowEdge & rhs) const {
return edgeFrom == rhs.edgeFrom && edgeTo == rhs.edgeTo && varName == rhs.varName;
}
};
namespace std {
template<>
struct hash<ControlFlowEdge> {
std::size_t operator()(const ControlFlowEdge & k) const {
using std::size_t;
using std::hash;
using std::string;
return hash<void*>{}(k.edgeFrom)
^ (hash<void*>{}(k.edgeTo) >> 1)
^ (hash<string>{}(k.varName) << 1);
}
};
}
struct FunctionSignature {
InferredTypeSP returnTy;
vector<InferredTypeSP> paramTys;
vector<int> missingParams;
FunctionDef* func;
void* jitFunc;
Function* funcObj;
FunctionSignature() : func(0), jitFunc(0), funcObj(0){}
};
struct InferredType {
DATA_FORM form;
DATA_TYPE type;
DATA_CATEGORY category;
FunctionSignatureSP signature;
InferredType(DATA_FORM form = DF_SCALAR, DATA_TYPE type = DT_VOID, DATA_CATEGORY category = NOTHING):
form(form), type(type), category(category){}
bool operator ==(const InferredType & rhs) const {
return form == rhs.form && type == rhs.type && category == rhs.category;
}
bool operator !=(const InferredType & rhs) const {
return !operator==(rhs);
}
string getString();
};
namespace std {
template<>
struct hash<InferredType> {
std::size_t operator()(const InferredType & k) const {
using std::size_t;
using std::hash;
using std::string;
return hash<int8_t>{}(k.form) ^ hash<int8_t>{}(k.type);
}
};
}
class Object {
public:
Object(OBJECT_TYPE type) : objType_(type){}
inline OBJECT_TYPE getObjectType() const { return objType_;}
bool isConstant() const {return objType_ == CONSTOBJ;}
bool isVariable() const {return objType_ ==VAR;}
virtual ConstantSP getValue(Heap* pHeap) = 0;
virtual ConstantSP getReference(Heap* pHeap) = 0;
virtual ~Object(){}
virtual string getScript() const = 0;
virtual IO_ERR serialize(Heap* pHeap, const ByteArrayCodeBufferSP& buffer) const = 0;
virtual bool isLargeConstant() const {return false;}
/**
* @brief Get the components of the object in the form of a dictionary.
*
* @return If the object doesn't support this method, return an empty dictionary.
*/
virtual ConstantSP getComponent() const;
virtual void collectUserDefinedFunctions(unordered_map<string,FunctionDef*>& functionDefs) const {}
void collectVariables(vector<int>& vars, int minIndex, int maxIndex) const;
/**
* @biref Retrieve all ColumnRef objects contained in the currrent object.
*
* @param table: Use the given table to judge if a column reference is a variable in the case the name is ambiguous.
* @param columns: in & out parameter, pair<string, string> represents a column's quanlifier and name.
*/
void retrieveColumns(const TableSP& table, vector<pair<string,string>>& columns) const;
/**
* @brief Whether the object or its sub components contains column reference.
*/
bool containColumnRef() const;
/**
* @brief Whether the object or its sub components contains analytic function.
*/
bool containAnalyticFunction() const;
/**
* @brief Check if the current object contains special functions.
*
* @param aggrOnly: if only check aggregate functions.
*
* @return an indicator -1, 0, 1 or 2
* -1: the object doesn't contain any column or variable
* 0: transform function only
* 1: aggregate function
* 2: order sensitive function)
* 3: other type function
*/
int checkSpecialFunction(bool aggrOnly, bool sqlMode=true) const;
/**
* @brief Replace the SQLContext of any ColumnRef within the current object with the given new context.
*
* @param context: context can't be null.
* @param localize: replace the variable with the concrete object and detach the link of any column
* reference to a variable if this parameter is set to true.
*
* @return If the returned pointer is null, the object doesn't contain any column reference.
*/
virtual ObjectSP copy(Heap* pHeap, const SQLContextSP& context, bool localize) const { return nullptr;}
/**
* @brief Replace the SQLContext of any ColumnRef within the current object with the given new context, and materialize
* all variables.
*
* @param context: if context is null, materialize the object only, otherwise copy and materialize the object.
* @param table: Use the given table to judge if a column reference is a variable in the case the name is ambiguous.
*
* @return If the returned pointer is null, the object doesn't contain any column reference or variable.
*/
virtual ObjectSP copyAndMaterialize(Heap* pHeap, const SQLContextSP& context, const TableSP& table) const { return nullptr;}
/**
* @brief Whether the object or its sub components contains column reference or variable.
*/
virtual bool mayContainColumnRefOrVariable() const { return false;}
/**
* @brief collect objects from the current object and its sub component.
*/
virtual void collectObjects(vector<const Object*>& vec) const {};
/**
* @brief judge if the given object should be collected by collectObjects function.
*
* Now we only collect non-constant object and dynamic function
*
*/
static bool isCollectibleObject(const Object* obj);
/**
* @brief Traverse all sub components of the given objects.
* @param objStack: objects to traverse. The container is also used as the buffer to collect sub
* components.
* @param func: func is an function with the signature bool func(Object*). The return value could
* be false (collecting sub components) or true (not collecting sub components).
* @param offset: Objects at or after the offset will be traversed.
*
*/
template<class T>
static void traverse(vector<const Object*>& objStack, T& func, int offset = 0){
while (static_cast<int>(objStack.size()) > offset) {
const Object* cur = objStack.back();
objStack.pop_back();
if(!func(cur))
cur->collectObjects(objStack);
}
}
/**
* @brief Traverse all sub components of the given objects with short circuit evaluation.
* @param objStack: objects to traverse. The container is also used as the buffer to collect sub
* components.
* @param func: func is an function with the signature int func(Object*). The return value could
* be 0 (collecting sub components), 1 (not collecting sub components), or 2 (finish traversal).
* @param offset: Objects at or after the offset will be traversed.
*
*/
template<class T>
static void traverseShortCircuit(vector<const Object*>& objStack, T& func, int offset = 0) {
while (static_cast<int>(objStack.size()) > offset) {
const Object* cur = objStack.back();
objStack.pop_back();
int ret = func(cur);
if(ret == 2)
return;
else if(ret == 0)
cur->collectObjects(objStack);
}
}
protected:
OBJECT_TYPE objType_;
};
#define NOT_IMPLEMENT \
throw RuntimeException("Data type [" + std::to_string(static_cast<int>(getType())) + "] form [" + \
std::to_string(static_cast<int>(getForm())) + "] does not implement `" + __func__ + "`"); \
//======
class Constant: public Object{
public:
static DolphinString DEMPTY;
static string EMPTY;
static string NULL_STR;
Constant() : Object(CONSTOBJ), flag_(3){}
Constant(unsigned short flag) : Object(CONSTOBJ), flag_(flag){}
Constant(DATA_FORM df, DATA_TYPE dt, DATA_CATEGORY dc) : Object(CONSTOBJ), flag_(3 + (df<<8) + (dt<<16) + (dc<<24)){}
virtual ~Constant(){}
inline bool isTemporary() const {return flag_ & 1;}
inline void setTemporary(bool val){ if(val) flag_ |= 1; else flag_ &= ~1;}
inline bool isIndependent() const {return flag_ & 2;}
inline void setIndependent(bool val){ if(val) flag_ |= 2; else flag_ &= ~2;}
inline bool isReadOnly() const {return flag_ & 4;}
inline void setReadOnly(bool val){ if(val) flag_ |= 4; else flag_ &= ~4;}
inline bool isReadOnlyArgument() const {return flag_ & 8;}
inline void setReadOnlyArgument(bool val){ if(val) flag_ |= 8; else flag_ &= ~8;}
inline bool isNothing() const {return flag_ & 16;}
inline void setNothing(bool val){ if(val) flag_ |= 16; else flag_ &= ~16;}
inline bool isStatic() const {return flag_ & 32;}
inline void setStatic(bool val){ if(val) flag_ |= 32; else flag_ &= ~32;}
inline bool transferAsString() const {return flag_ & 64;}
inline void transferAsString(bool val){ if(val) flag_ |= 64; else flag_ &= ~64;}
inline bool isSynchronized() const {return flag_ & 128;}
inline void setSynchronized(bool val){ if(val) flag_ |= 128; else flag_ &= ~128;}
inline bool isOOInstance() const {return flag_ & 4096;}
inline void setOOInstance(bool val){ if(val) flag_ |= 4096; else flag_ &= ~4096;}
inline bool isIndexed() const {return flag_ & 8192;}
inline void setIndexed(bool val){ if(val) flag_ |= 8192; else flag_ &= ~8192;}
inline bool isSeries() const {return flag_ & 16384;}
inline void setSeries(bool val){ if(val) flag_ |= 16384; else flag_ &= ~16384;}
inline bool isTransient() const {return flag_ & 32768;}
inline void setTransient(bool val){ if(val) flag_ |= 32768; else flag_ &= ~32768;}
inline DATA_FORM getForm() const {return DATA_FORM((flag_ >> 8) & 15);}
inline void setForm(DATA_FORM df){ flag_ = (flag_ & 4294963455U) + (df << 8);}
inline DATA_TYPE getType() const {return DATA_TYPE((flag_ >> 16) & 255);}
inline DATA_CATEGORY getCategory() const {return DATA_CATEGORY((flag_ >> 24) & 15);}
/**
* @brief set the COW(copy on write) flag (bit 28)
*/
inline void setCOW(bool val){ if(val) flag_ |= 268435456; else flag_ &= ~268435456;}
/**
* @brief Return whether the flag of COW is on.
*/
inline bool isCOW() const { return flag_ & 268435456;}
/**
* @brief Return whether this constant is scalar.
*/
inline bool isScalar() const { return getForm()==DF_SCALAR;}
inline bool isArray() const { return getForm()==DF_VECTOR;}
inline bool isPair() const { return getForm()==DF_PAIR;}
inline bool isMatrix() const {return getForm()==DF_MATRIX;}
//a vector could be array, pair or matrix.
inline bool isVector() const { DATA_FORM df = getForm();return df>=DF_VECTOR && df<=DF_MATRIX;}
inline bool isTable() const { return getForm()==DF_TABLE;}
inline bool isSet() const {return getForm()==DF_SET;}
inline bool isDictionary() const {return getForm()==DF_DICTIONARY;}
inline bool isChunk() const {return getForm()==DF_CHUNK;}
bool isTuple() const {return getForm()==DF_VECTOR && getType()==DT_ANY;}
bool isNumber() const { DATA_CATEGORY cat = getCategory(); return cat == INTEGRAL || cat == FLOATING || cat == DENARY; }
virtual bool isDatabase() const {return false;}
virtual char getBool() const {throw RuntimeException("The object can't be converted to boolean scalar.");}
virtual char getChar() const {throw RuntimeException("The object can't be converted to char scalar.");}
virtual short getShort() const {throw RuntimeException("The object can't be converted to short scalar.");}
virtual int getInt() const {throw RuntimeException("The object can't be converted to int scalar.");}
virtual long long getLong() const {throw RuntimeException("The object can't be converted to long scalar.");}
virtual INDEX getIndex() const {throw RuntimeException("The object can't be converted to index scalar.");}
virtual float getFloat() const {throw RuntimeException("The object can't be converted to float scalar.");}
virtual double getDouble() const {throw RuntimeException("The object can't be converted to double scalar.");}
/**
* @brief Get the string version of this constant.
* This function is very helpful for debugging.
*/
virtual string getString() const {return "";}
virtual string getScript() const { return getString();}
virtual const DolphinString& getStringRef() const {return DEMPTY;}
virtual const Guid getInt128() const {throw RuntimeException("The object can't be converted to int128 scalar.");}
virtual const unsigned char* getBinary() const {throw RuntimeException("The object can't be converted to int128 scalar.");}
virtual bool isNull() const {return false;}
virtual int getDecimal32(int scale) const { NOT_IMPLEMENT; }
virtual long long getDecimal64(int scale) const { NOT_IMPLEMENT; }
virtual int128 getDecimal128(int scale) const { NOT_IMPLEMENT; }
virtual void setBool(char val){}
virtual void setChar(char val){}
virtual void setShort(short val){}
virtual void setInt(int val){}
virtual void setLong(long long val){}
virtual void setIndex(INDEX val){}
virtual void setFloat(float val){}
virtual void setDouble(double val){}
virtual void setString(const DolphinString& val){}
virtual void setBinary(const unsigned char* val, int unitLength){}
virtual void setNull(){}
virtual char getBool(INDEX index) const {return getBool();}
virtual char getChar(INDEX index) const { return getChar();}
virtual short getShort(INDEX index) const { return getShort();}
virtual int getInt(INDEX index) const {return getInt();}
virtual long long getLong(INDEX index) const {return getLong();}
virtual INDEX getIndex(INDEX index) const {return getIndex();}
virtual float getFloat(INDEX index) const {return getFloat();}
virtual double getDouble(INDEX index) const {return getDouble();}
virtual string getString(INDEX index) const {return getString();}
virtual const DolphinString& getStringRef(INDEX index) const {return DEMPTY;}
virtual const Guid getInt128(INDEX index) const {return getInt128();}
virtual const unsigned char* getBinary(INDEX index) const {return getBinary();}
virtual bool isNull(INDEX index) const {return isNull();}
virtual int getDecimal32(INDEX index, int scale) const { NOT_IMPLEMENT; }
virtual long long getDecimal64(INDEX index, int scale) const { NOT_IMPLEMENT; }
virtual int128 getDecimal128(INDEX index, int scale) const { NOT_IMPLEMENT; }
virtual ConstantSP get(INDEX index) const {return getValue();}
virtual ConstantSP get(INDEX column, INDEX row) const {return get(row);}
/**
* @brief Get the data according to the index.
*
* @param index: the index gives the indices of data to get. If the index is out of range,
* i.e. negative or larger than the size, the null value is returned correspondingly.
* @return ConstantSP: the data
*/
virtual ConstantSP get(const ConstantSP& index) const {return getValue();}
/**
* @brief Get the data according to the index.
*
* @param offset: the index is offseted by offset
* @param index: the index gives the indices of data to get
* @return ConstantSP: the data
*/
virtual ConstantSP get(INDEX offset, const ConstantSP& index) const {return getValue();}
virtual ConstantSP getColumn(INDEX index) const {return getValue();}
virtual ConstantSP getRow(INDEX index) const {return get(index);}
virtual ConstantSP getItem(INDEX index) const {return get(index);}
virtual ConstantSP getItems(const ConstantSP& index) const {return get(index);}
virtual ConstantSP getWindow(INDEX colStart, int colLength, INDEX rowStart, int rowLength) const {return getValue();}
virtual ConstantSP getSlice(const ConstantSP& rowIndex, const ConstantSP& colIndex) const {throw RuntimeException("getSlice method not supported");}
virtual ConstantSP getRowLabel() const;
virtual ConstantSP getColumnLabel() const;
/**
* @brief Judge the data from start to (start + len - 1) is null or not
*
* @param start: the start index
* @param len: the length of data to be judged
* @param buf: the result is stored in buf
* @return true: the function call succeed
* @return false: the function call fail
*/
virtual bool isNull(INDEX start, int len, char* buf) const {return false;}
/**
* @brief Judge the data from start to (start + len - 1) is valid or not.
* All the param and return is the same as in isNull.
*/
virtual bool isValid(INDEX start, int len, char* buf) const {return false;}
/**
* @brief Get the boolean data from start to (start + len - 1).
* All the param and return is the same as in isNull.
*/
virtual bool getBool(INDEX start, int len, char* buf) const {return false;}
virtual bool getChar(INDEX start, int len,char* buf) const {return false;}
virtual bool getShort(INDEX start, int len, short* buf) const {return false;}
virtual bool getInt(INDEX start, int len, int* buf) const {return false;}
virtual bool getLong(INDEX start, int len, long long* buf) const {return false;}
virtual bool getIndex(INDEX start, int len, INDEX* buf) const {return false;}
virtual bool getFloat(INDEX start, int len, float* buf) const {return false;}
virtual bool getDouble(INDEX start, int len, double* buf) const {return false;}
virtual bool getSymbol(INDEX start, int len, int* buf, SymbolBase* symBase,bool insertIfNotThere) const {return false;}
virtual bool getString(INDEX start, int len, DolphinString** buf) const {return false;}
virtual bool getString(INDEX start, int len, char** buf) const {return false;}
virtual bool getBinary(INDEX start, int len, int unitLength, unsigned char* buf) const {return false;}
virtual bool getDecimal32(INDEX start, int len, int scale, int *buf) const { NOT_IMPLEMENT; }
virtual bool getDecimal64(INDEX start, int len, int scale, long long *buf) const { NOT_IMPLEMENT; }
virtual bool getDecimal128(INDEX start, int len, int scale, int128 *buf) const { NOT_IMPLEMENT; }
/**
* @brief Judge the data according to indices is null or not
*
* @param indices: the maybe out-of-ordered indices to judge
* @param len: the length of data to be judged
* @param buf: the result is stored in buf
* @return true: the function call succeed
* @return false: the function call fail
*/
virtual bool isNull(INDEX* indices, int len, char* buf) const {return false;}
virtual bool isValid(INDEX* indices, int len, char* buf) const {return false;}
/**
* @brief Get the boolean data according to indices.
* All the param and return is the same as in isNull.
*/
virtual bool getBool(INDEX* indices, int len, char* buf) const {return false;}
virtual bool getChar(INDEX* indices, int len,char* buf) const {return false;}
virtual bool getShort(INDEX* indices, int len, short* buf) const {return false;}
virtual bool getInt(INDEX* indices, int len, int* buf) const {return false;}
virtual bool getLong(INDEX* indices, int len, long long* buf) const {return false;}
virtual bool getIndex(INDEX* indices, int len, INDEX* buf) const {return false;}
virtual bool getFloat(INDEX* indices, int len, float* buf) const {return false;}
virtual bool getDouble(INDEX* indices, int len, double* buf) const {return false;}
virtual bool getSymbol(INDEX* indices, int len, int* buf, SymbolBase* symBase,bool insertIfNotThere) const {return false;}
virtual bool getString(INDEX* indices, int len, DolphinString** buf) const {return false;}
virtual bool getString(INDEX* indices, int len, char** buf) const {return false;}
virtual bool getBinary(INDEX* indices, int len, int unitLength, unsigned char* buf) const {return false;}
virtual bool getDecimal32(INDEX *indices, int len, int scale, int *buf) const { NOT_IMPLEMENT; }
virtual bool getDecimal64(INDEX *indices, int len, int scale, long long *buf) const { NOT_IMPLEMENT; }
virtual bool getDecimal128(INDEX *indices, int len, int scale, int128 *buf) const { NOT_IMPLEMENT; }
/**
* @brief Get the boolean data from start to (start + len - 1).
* This is the recommended method to view/iterate data in Constant.
* Note that if the required underlying data is contiguous, then there is
* no copy happened in this function and the underlying buffer is directly returned;
* otherwise, the data is copied into buf, and buf is returned.
*
* @param start: the start index
* @param len: the length of data to get
* @param buf: a buffer with at least length len
* @return a buffer with the data required.
*/
virtual const char* getBoolConst(INDEX start, int len, char* buf) const {throw RuntimeException("getBoolConst method not supported");}
virtual const char* getCharConst(INDEX start, int len,char* buf) const {throw RuntimeException("getCharConst method not supported");}
virtual const short* getShortConst(INDEX start, int len, short* buf) const {throw RuntimeException("getShortConst method not supported");}
virtual const int* getIntConst(INDEX start, int len, int* buf) const {throw RuntimeException("getIntConst method not supported");}
virtual const long long* getLongConst(INDEX start, int len, long long* buf) const {throw RuntimeException("getLongConst method not supported");}
virtual const INDEX* getIndexConst(INDEX start, int len, INDEX* buf) const {throw RuntimeException("getIndexConst method not supported");}
virtual const float* getFloatConst(INDEX start, int len, float* buf) const {throw RuntimeException("getFloatConst method not supported");}
virtual const double* getDoubleConst(INDEX start, int len, double* buf) const {throw RuntimeException("getDoubleConst method not supported");}
virtual const int* getSymbolConst(INDEX start, int len, int* buf, SymbolBase* symBase, bool insertIfNotThere) const {throw RuntimeException("getSymbolConst method not supported");}
virtual DolphinString** getStringConst(INDEX start, int len, DolphinString** buf) const {throw RuntimeException("getStringConst method not supported");}
virtual char** getStringConst(INDEX start, int len, char** buf) const {throw RuntimeException("getStringConst method not supported");}
virtual const unsigned char* getBinaryConst(INDEX start, int len, int unitLength, unsigned char* buf) const {throw RuntimeException("getBinaryConst method not supported");}
virtual const int* getDecimal32Const(INDEX start, int len, int scale, int *buf) const { NOT_IMPLEMENT; }
virtual const long long* getDecimal64Const(INDEX start, int len, int scale, long long *buf) const { NOT_IMPLEMENT; }
virtual const int128* getDecimal128Const(INDEX start, int len, int scale,
int128 *buf) const {
NOT_IMPLEMENT;
}
/**
* @brief Get a buffer for writing data from start to (start + len - 1).
* This is the recommended method to write data in Constant.
* This function is always used together with setBool(start, len, buf).
* Note that if the required underlying data is contiguous,
* then the underlying buffer is directly returned;
* otherwise, the buf is returned.
*
* @param start: the start index
* @param len: the length of data to get
* @param buf: a buffer with at least length len
* @return a buffer to write data.
*/
virtual char* getBoolBuffer(INDEX start, int len, char* buf) const {return buf;}
virtual char* getCharBuffer(INDEX start, int len,char* buf) const {return buf;}
virtual short* getShortBuffer(INDEX start, int len, short* buf) const {return buf;}
virtual int* getIntBuffer(INDEX start, int len, int* buf) const {return NULL;}
virtual long long* getLongBuffer(INDEX start, int len, long long* buf) const {return buf;}
virtual INDEX* getIndexBuffer(INDEX start, int len, INDEX* buf) const {return buf;}
virtual float* getFloatBuffer(INDEX start, int len, float* buf) const {return buf;}
virtual double* getDoubleBuffer(INDEX start, int len, double* buf) const {return buf;}
virtual unsigned char* getBinaryBuffer(INDEX start, int len, int unitLength, unsigned char* buf) const {return buf;}
virtual void* getDataBuffer(INDEX start, int len, void* buf) const {return buf;}
virtual int* getDecimal32Buffer(INDEX start, int len, int scale, int *buf) const { NOT_IMPLEMENT; }
virtual long long* getDecimal64Buffer(INDEX start, int len, int scale, long long *buf) const { NOT_IMPLEMENT; }
virtual int128* getDecimal128Buffer(INDEX start, int len, int scale,
int128 *buf) const {
NOT_IMPLEMENT;
}
virtual IO_ERR serialize(Heap* pHeap, const ByteArrayCodeBufferSP& buffer) const {return serialize(buffer);}
virtual IO_ERR serialize(const ByteArrayCodeBufferSP& buffer) const {throw RuntimeException("code serialize method not supported");}
virtual int serialize(char* buf, int bufSize, INDEX indexStart, int offset, int& numElement, int& partial) const {throw RuntimeException("serialize method not supported");}
virtual int serialize(char* buf, int bufSize, INDEX indexStart, int offset, int targetNumElement, int& numElement, int& partial) const;
virtual IO_ERR deserialize(DataInputStream* in, INDEX indexStart, int offset, INDEX targetNumElement, INDEX& numElement, int& partial) {throw RuntimeException("deserialize method not supported");}
/**
* @brief Fill the null value with val.
*
* @param val
*/
virtual void nullFill(const ConstantSP& val){}
/**
* @brief Set the index-th element to be val.
*
* @param index: the index of element to be set.
* @param val: the value to be set.
*/
virtual void setBool(INDEX index,char val){setBool(val);}
virtual void setChar(INDEX index,char val){setChar(val);}
virtual void setShort(INDEX index,short val){setShort(val);}
virtual void setInt(INDEX index,int val){setInt(val);}
virtual void setLong(INDEX index,long long val){setLong(val);}
virtual void setIndex(INDEX index,INDEX val){setIndex(val);}
virtual void setFloat(INDEX index,float val){setFloat(val);}
virtual void setDouble(INDEX index, double val){setDouble(val);}
virtual void setString(INDEX index, const DolphinString& val){setString(val);}
virtual void setBinary(INDEX index, int unitLength, const unsigned char* val){setBinary(val, unitLength);}
virtual void setNull(INDEX index){setNull();}
virtual void setDecimal32(INDEX index, int scale, int val) { NOT_IMPLEMENT; }
virtual void setDecimal64(INDEX index, int scale, long long val) { NOT_IMPLEMENT; }