duckdb 0.3.3-dev948.0 → 0.3.3-dev957.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb.hpp +2 -2
- package/src/parquet-amalgamation.cpp +287 -287
package/package.json
CHANGED
package/src/duckdb.hpp
CHANGED
|
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
13
|
#define DUCKDB_AMALGAMATION_EXTENDED 1
|
|
14
|
-
#define DUCKDB_SOURCE_ID "
|
|
15
|
-
#define DUCKDB_VERSION "v0.3.3-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "d13fbab42"
|
|
15
|
+
#define DUCKDB_VERSION "v0.3.3-dev957"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -8,6 +8,48 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
// LICENSE_CHANGE_BEGIN
|
|
12
|
+
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #2
|
|
13
|
+
// See the end of this file for a list
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
17
|
+
* or more contributor license agreements. See the NOTICE file
|
|
18
|
+
* distributed with this work for additional information
|
|
19
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
20
|
+
* to you under the Apache License, Version 2.0 (the
|
|
21
|
+
* "License"); you may not use this file except in compliance
|
|
22
|
+
* with the License. You may obtain a copy of the License at
|
|
23
|
+
*
|
|
24
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
*
|
|
26
|
+
* Unless required by applicable law or agreed to in writing,
|
|
27
|
+
* software distributed under the License is distributed on an
|
|
28
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
29
|
+
* KIND, either express or implied. See the License for the
|
|
30
|
+
* specific language governing permissions and limitations
|
|
31
|
+
* under the License.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
namespace duckdb_apache {
|
|
37
|
+
namespace thrift {
|
|
38
|
+
namespace protocol {
|
|
39
|
+
|
|
40
|
+
TProtocol::~TProtocol() = default;
|
|
41
|
+
uint32_t TProtocol::skip_virt(TType type) {
|
|
42
|
+
return ::duckdb_apache::thrift::protocol::skip(*this, type);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
TProtocolFactory::~TProtocolFactory() = default;
|
|
46
|
+
|
|
47
|
+
}}} // duckdb_apache::thrift::protocol
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
// LICENSE_CHANGE_END
|
|
51
|
+
|
|
52
|
+
|
|
11
53
|
// LICENSE_CHANGE_BEGIN
|
|
12
54
|
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #3
|
|
13
55
|
// See the end of this file for a list
|
|
@@ -18965,293 +19007,6 @@ size_t ZSTD_compressBlock_btultra_extDict(
|
|
|
18965
19007
|
// LICENSE_CHANGE_END
|
|
18966
19008
|
|
|
18967
19009
|
|
|
18968
|
-
// LICENSE_CHANGE_BEGIN
|
|
18969
|
-
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #2
|
|
18970
|
-
// See the end of this file for a list
|
|
18971
|
-
|
|
18972
|
-
/*
|
|
18973
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
18974
|
-
* or more contributor license agreements. See the NOTICE file
|
|
18975
|
-
* distributed with this work for additional information
|
|
18976
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
18977
|
-
* to you under the Apache License, Version 2.0 (the
|
|
18978
|
-
* "License"); you may not use this file except in compliance
|
|
18979
|
-
* with the License. You may obtain a copy of the License at
|
|
18980
|
-
*
|
|
18981
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18982
|
-
*
|
|
18983
|
-
* Unless required by applicable law or agreed to in writing,
|
|
18984
|
-
* software distributed under the License is distributed on an
|
|
18985
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
18986
|
-
* KIND, either express or implied. See the License for the
|
|
18987
|
-
* specific language governing permissions and limitations
|
|
18988
|
-
* under the License.
|
|
18989
|
-
*/
|
|
18990
|
-
|
|
18991
|
-
#include <cassert>
|
|
18992
|
-
#include <algorithm>
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
// LICENSE_CHANGE_BEGIN
|
|
18996
|
-
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #2
|
|
18997
|
-
// See the end of this file for a list
|
|
18998
|
-
|
|
18999
|
-
#ifndef THRIFT_EXPORT_H
|
|
19000
|
-
#define THRIFT_EXPORT_H
|
|
19001
|
-
|
|
19002
|
-
#ifdef THRIFT_STATIC_DEFINE
|
|
19003
|
-
# define THRIFT_EXPORT
|
|
19004
|
-
#elif defined(_MSC_VER )
|
|
19005
|
-
# ifndef THRIFT_EXPORT
|
|
19006
|
-
# ifdef thrift_EXPORTS
|
|
19007
|
-
/* We are building this library */
|
|
19008
|
-
# define THRIFT_EXPORT __declspec(dllexport)
|
|
19009
|
-
# else
|
|
19010
|
-
/* We are using this library */
|
|
19011
|
-
# define THRIFT_EXPORT __declspec(dllimport)
|
|
19012
|
-
# endif
|
|
19013
|
-
# endif
|
|
19014
|
-
#else
|
|
19015
|
-
# define THRIFT_EXPORT
|
|
19016
|
-
#endif
|
|
19017
|
-
|
|
19018
|
-
#endif /* THRIFT_EXPORT_H */
|
|
19019
|
-
|
|
19020
|
-
|
|
19021
|
-
// LICENSE_CHANGE_END
|
|
19022
|
-
|
|
19023
|
-
|
|
19024
|
-
|
|
19025
|
-
|
|
19026
|
-
using std::string;
|
|
19027
|
-
|
|
19028
|
-
namespace duckdb_apache {
|
|
19029
|
-
namespace thrift {
|
|
19030
|
-
namespace transport {
|
|
19031
|
-
|
|
19032
|
-
|
|
19033
|
-
|
|
19034
|
-
|
|
19035
|
-
void TMemoryBuffer::computeRead(uint32_t len, uint8_t** out_start, uint32_t* out_give) {
|
|
19036
|
-
// Correct rBound_ so we can use the fast path in the future.
|
|
19037
|
-
rBound_ = wBase_;
|
|
19038
|
-
|
|
19039
|
-
// Decide how much to give.
|
|
19040
|
-
uint32_t give = (std::min)(len, available_read());
|
|
19041
|
-
|
|
19042
|
-
*out_start = rBase_;
|
|
19043
|
-
*out_give = give;
|
|
19044
|
-
|
|
19045
|
-
// Preincrement rBase_ so the caller doesn't have to.
|
|
19046
|
-
rBase_ += give;
|
|
19047
|
-
}
|
|
19048
|
-
|
|
19049
|
-
uint32_t TMemoryBuffer::readSlow(uint8_t* buf, uint32_t len) {
|
|
19050
|
-
uint8_t* start;
|
|
19051
|
-
uint32_t give;
|
|
19052
|
-
computeRead(len, &start, &give);
|
|
19053
|
-
|
|
19054
|
-
// Copy into the provided buffer.
|
|
19055
|
-
memcpy(buf, start, give);
|
|
19056
|
-
|
|
19057
|
-
return give;
|
|
19058
|
-
}
|
|
19059
|
-
|
|
19060
|
-
uint32_t TMemoryBuffer::readAppendToString(std::string& str, uint32_t len) {
|
|
19061
|
-
// Don't get some stupid assertion failure.
|
|
19062
|
-
if (buffer_ == nullptr) {
|
|
19063
|
-
return 0;
|
|
19064
|
-
}
|
|
19065
|
-
|
|
19066
|
-
uint8_t* start;
|
|
19067
|
-
uint32_t give;
|
|
19068
|
-
computeRead(len, &start, &give);
|
|
19069
|
-
|
|
19070
|
-
// Append to the provided string.
|
|
19071
|
-
str.append((char*)start, give);
|
|
19072
|
-
|
|
19073
|
-
return give;
|
|
19074
|
-
}
|
|
19075
|
-
|
|
19076
|
-
void TMemoryBuffer::ensureCanWrite(uint32_t len) {
|
|
19077
|
-
// Check available space
|
|
19078
|
-
uint32_t avail = available_write();
|
|
19079
|
-
if (len <= avail) {
|
|
19080
|
-
return;
|
|
19081
|
-
}
|
|
19082
|
-
|
|
19083
|
-
if (!owner_) {
|
|
19084
|
-
throw TTransportException("Insufficient space in external MemoryBuffer");
|
|
19085
|
-
}
|
|
19086
|
-
|
|
19087
|
-
// Grow the buffer as necessary.
|
|
19088
|
-
uint64_t new_size = bufferSize_;
|
|
19089
|
-
while (len > avail) {
|
|
19090
|
-
new_size = new_size > 0 ? new_size * 2 : 1;
|
|
19091
|
-
if (new_size > maxBufferSize_) {
|
|
19092
|
-
throw TTransportException(TTransportException::BAD_ARGS,
|
|
19093
|
-
"Internal buffer size overflow");
|
|
19094
|
-
}
|
|
19095
|
-
avail = available_write() + (static_cast<uint32_t>(new_size) - bufferSize_);
|
|
19096
|
-
}
|
|
19097
|
-
|
|
19098
|
-
// Allocate into a new pointer so we don't bork ours if it fails.
|
|
19099
|
-
auto* new_buffer = static_cast<uint8_t*>(std::realloc(buffer_, new_size));
|
|
19100
|
-
if (new_buffer == nullptr) {
|
|
19101
|
-
throw std::bad_alloc();
|
|
19102
|
-
}
|
|
19103
|
-
|
|
19104
|
-
rBase_ = new_buffer + (rBase_ - buffer_);
|
|
19105
|
-
rBound_ = new_buffer + (rBound_ - buffer_);
|
|
19106
|
-
wBase_ = new_buffer + (wBase_ - buffer_);
|
|
19107
|
-
wBound_ = new_buffer + new_size;
|
|
19108
|
-
buffer_ = new_buffer;
|
|
19109
|
-
bufferSize_ = static_cast<uint32_t>(new_size);
|
|
19110
|
-
}
|
|
19111
|
-
|
|
19112
|
-
void TMemoryBuffer::writeSlow(const uint8_t* buf, uint32_t len) {
|
|
19113
|
-
ensureCanWrite(len);
|
|
19114
|
-
|
|
19115
|
-
// Copy into the buffer and increment wBase_.
|
|
19116
|
-
memcpy(wBase_, buf, len);
|
|
19117
|
-
wBase_ += len;
|
|
19118
|
-
}
|
|
19119
|
-
|
|
19120
|
-
void TMemoryBuffer::wroteBytes(uint32_t len) {
|
|
19121
|
-
uint32_t avail = available_write();
|
|
19122
|
-
if (len > avail) {
|
|
19123
|
-
throw TTransportException("Client wrote more bytes than size of buffer.");
|
|
19124
|
-
}
|
|
19125
|
-
wBase_ += len;
|
|
19126
|
-
}
|
|
19127
|
-
|
|
19128
|
-
const uint8_t* TMemoryBuffer::borrowSlow(uint8_t* buf, uint32_t* len) {
|
|
19129
|
-
(void)buf;
|
|
19130
|
-
rBound_ = wBase_;
|
|
19131
|
-
if (available_read() >= *len) {
|
|
19132
|
-
*len = available_read();
|
|
19133
|
-
return rBase_;
|
|
19134
|
-
}
|
|
19135
|
-
return nullptr;
|
|
19136
|
-
}
|
|
19137
|
-
}
|
|
19138
|
-
}
|
|
19139
|
-
} // duckdb_apache::thrift::transport
|
|
19140
|
-
|
|
19141
|
-
|
|
19142
|
-
// LICENSE_CHANGE_END
|
|
19143
|
-
|
|
19144
|
-
|
|
19145
|
-
// LICENSE_CHANGE_BEGIN
|
|
19146
|
-
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #2
|
|
19147
|
-
// See the end of this file for a list
|
|
19148
|
-
|
|
19149
|
-
/*
|
|
19150
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
19151
|
-
* or more contributor license agreements. See the NOTICE file
|
|
19152
|
-
* distributed with this work for additional information
|
|
19153
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
19154
|
-
* to you under the Apache License, Version 2.0 (the
|
|
19155
|
-
* "License"); you may not use this file except in compliance
|
|
19156
|
-
* with the License. You may obtain a copy of the License at
|
|
19157
|
-
*
|
|
19158
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
19159
|
-
*
|
|
19160
|
-
* Unless required by applicable law or agreed to in writing,
|
|
19161
|
-
* software distributed under the License is distributed on an
|
|
19162
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
19163
|
-
* KIND, either express or implied. See the License for the
|
|
19164
|
-
* specific language governing permissions and limitations
|
|
19165
|
-
* under the License.
|
|
19166
|
-
*/
|
|
19167
|
-
|
|
19168
|
-
|
|
19169
|
-
#include <cstring>
|
|
19170
|
-
|
|
19171
|
-
|
|
19172
|
-
|
|
19173
|
-
using std::string;
|
|
19174
|
-
|
|
19175
|
-
namespace duckdb_apache {
|
|
19176
|
-
namespace thrift {
|
|
19177
|
-
namespace transport {
|
|
19178
|
-
|
|
19179
|
-
const char* TTransportException::what() const noexcept {
|
|
19180
|
-
if (message_.empty()) {
|
|
19181
|
-
switch (type_) {
|
|
19182
|
-
case UNKNOWN:
|
|
19183
|
-
return "TTransportException: Unknown transport exception";
|
|
19184
|
-
case NOT_OPEN:
|
|
19185
|
-
return "TTransportException: Transport not open";
|
|
19186
|
-
case TIMED_OUT:
|
|
19187
|
-
return "TTransportException: Timed out";
|
|
19188
|
-
case END_OF_FILE:
|
|
19189
|
-
return "TTransportException: End of file";
|
|
19190
|
-
case INTERRUPTED:
|
|
19191
|
-
return "TTransportException: Interrupted";
|
|
19192
|
-
case BAD_ARGS:
|
|
19193
|
-
return "TTransportException: Invalid arguments";
|
|
19194
|
-
case CORRUPTED_DATA:
|
|
19195
|
-
return "TTransportException: Corrupted Data";
|
|
19196
|
-
case INTERNAL_ERROR:
|
|
19197
|
-
return "TTransportException: Internal error";
|
|
19198
|
-
default:
|
|
19199
|
-
return "TTransportException: (Invalid exception type)";
|
|
19200
|
-
}
|
|
19201
|
-
} else {
|
|
19202
|
-
return message_.c_str();
|
|
19203
|
-
}
|
|
19204
|
-
}
|
|
19205
|
-
}
|
|
19206
|
-
}
|
|
19207
|
-
} // duckdb_apache::thrift::transport
|
|
19208
|
-
|
|
19209
|
-
|
|
19210
|
-
// LICENSE_CHANGE_END
|
|
19211
|
-
|
|
19212
|
-
|
|
19213
|
-
// LICENSE_CHANGE_BEGIN
|
|
19214
|
-
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #2
|
|
19215
|
-
// See the end of this file for a list
|
|
19216
|
-
|
|
19217
|
-
/*
|
|
19218
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
19219
|
-
* or more contributor license agreements. See the NOTICE file
|
|
19220
|
-
* distributed with this work for additional information
|
|
19221
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
19222
|
-
* to you under the Apache License, Version 2.0 (the
|
|
19223
|
-
* "License"); you may not use this file except in compliance
|
|
19224
|
-
* with the License. You may obtain a copy of the License at
|
|
19225
|
-
*
|
|
19226
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
19227
|
-
*
|
|
19228
|
-
* Unless required by applicable law or agreed to in writing,
|
|
19229
|
-
* software distributed under the License is distributed on an
|
|
19230
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
19231
|
-
* KIND, either express or implied. See the License for the
|
|
19232
|
-
* specific language governing permissions and limitations
|
|
19233
|
-
* under the License.
|
|
19234
|
-
*/
|
|
19235
|
-
|
|
19236
|
-
|
|
19237
|
-
|
|
19238
|
-
namespace duckdb_apache {
|
|
19239
|
-
namespace thrift {
|
|
19240
|
-
namespace protocol {
|
|
19241
|
-
|
|
19242
|
-
TProtocol::~TProtocol() = default;
|
|
19243
|
-
uint32_t TProtocol::skip_virt(TType type) {
|
|
19244
|
-
return ::duckdb_apache::thrift::protocol::skip(*this, type);
|
|
19245
|
-
}
|
|
19246
|
-
|
|
19247
|
-
TProtocolFactory::~TProtocolFactory() = default;
|
|
19248
|
-
|
|
19249
|
-
}}} // duckdb_apache::thrift::protocol
|
|
19250
|
-
|
|
19251
|
-
|
|
19252
|
-
// LICENSE_CHANGE_END
|
|
19253
|
-
|
|
19254
|
-
|
|
19255
19010
|
// LICENSE_CHANGE_BEGIN
|
|
19256
19011
|
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #3
|
|
19257
19012
|
// See the end of this file for a list
|
|
@@ -32883,6 +32638,251 @@ size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx,
|
|
|
32883
32638
|
// LICENSE_CHANGE_END
|
|
32884
32639
|
|
|
32885
32640
|
|
|
32641
|
+
// LICENSE_CHANGE_BEGIN
|
|
32642
|
+
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #2
|
|
32643
|
+
// See the end of this file for a list
|
|
32644
|
+
|
|
32645
|
+
/*
|
|
32646
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
32647
|
+
* or more contributor license agreements. See the NOTICE file
|
|
32648
|
+
* distributed with this work for additional information
|
|
32649
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
32650
|
+
* to you under the Apache License, Version 2.0 (the
|
|
32651
|
+
* "License"); you may not use this file except in compliance
|
|
32652
|
+
* with the License. You may obtain a copy of the License at
|
|
32653
|
+
*
|
|
32654
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
32655
|
+
*
|
|
32656
|
+
* Unless required by applicable law or agreed to in writing,
|
|
32657
|
+
* software distributed under the License is distributed on an
|
|
32658
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
32659
|
+
* KIND, either express or implied. See the License for the
|
|
32660
|
+
* specific language governing permissions and limitations
|
|
32661
|
+
* under the License.
|
|
32662
|
+
*/
|
|
32663
|
+
|
|
32664
|
+
#include <cassert>
|
|
32665
|
+
#include <algorithm>
|
|
32666
|
+
|
|
32667
|
+
|
|
32668
|
+
// LICENSE_CHANGE_BEGIN
|
|
32669
|
+
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #2
|
|
32670
|
+
// See the end of this file for a list
|
|
32671
|
+
|
|
32672
|
+
#ifndef THRIFT_EXPORT_H
|
|
32673
|
+
#define THRIFT_EXPORT_H
|
|
32674
|
+
|
|
32675
|
+
#ifdef THRIFT_STATIC_DEFINE
|
|
32676
|
+
# define THRIFT_EXPORT
|
|
32677
|
+
#elif defined(_MSC_VER )
|
|
32678
|
+
# ifndef THRIFT_EXPORT
|
|
32679
|
+
# ifdef thrift_EXPORTS
|
|
32680
|
+
/* We are building this library */
|
|
32681
|
+
# define THRIFT_EXPORT __declspec(dllexport)
|
|
32682
|
+
# else
|
|
32683
|
+
/* We are using this library */
|
|
32684
|
+
# define THRIFT_EXPORT __declspec(dllimport)
|
|
32685
|
+
# endif
|
|
32686
|
+
# endif
|
|
32687
|
+
#else
|
|
32688
|
+
# define THRIFT_EXPORT
|
|
32689
|
+
#endif
|
|
32690
|
+
|
|
32691
|
+
#endif /* THRIFT_EXPORT_H */
|
|
32692
|
+
|
|
32693
|
+
|
|
32694
|
+
// LICENSE_CHANGE_END
|
|
32695
|
+
|
|
32696
|
+
|
|
32697
|
+
|
|
32698
|
+
|
|
32699
|
+
using std::string;
|
|
32700
|
+
|
|
32701
|
+
namespace duckdb_apache {
|
|
32702
|
+
namespace thrift {
|
|
32703
|
+
namespace transport {
|
|
32704
|
+
|
|
32705
|
+
|
|
32706
|
+
|
|
32707
|
+
|
|
32708
|
+
void TMemoryBuffer::computeRead(uint32_t len, uint8_t** out_start, uint32_t* out_give) {
|
|
32709
|
+
// Correct rBound_ so we can use the fast path in the future.
|
|
32710
|
+
rBound_ = wBase_;
|
|
32711
|
+
|
|
32712
|
+
// Decide how much to give.
|
|
32713
|
+
uint32_t give = (std::min)(len, available_read());
|
|
32714
|
+
|
|
32715
|
+
*out_start = rBase_;
|
|
32716
|
+
*out_give = give;
|
|
32717
|
+
|
|
32718
|
+
// Preincrement rBase_ so the caller doesn't have to.
|
|
32719
|
+
rBase_ += give;
|
|
32720
|
+
}
|
|
32721
|
+
|
|
32722
|
+
uint32_t TMemoryBuffer::readSlow(uint8_t* buf, uint32_t len) {
|
|
32723
|
+
uint8_t* start;
|
|
32724
|
+
uint32_t give;
|
|
32725
|
+
computeRead(len, &start, &give);
|
|
32726
|
+
|
|
32727
|
+
// Copy into the provided buffer.
|
|
32728
|
+
memcpy(buf, start, give);
|
|
32729
|
+
|
|
32730
|
+
return give;
|
|
32731
|
+
}
|
|
32732
|
+
|
|
32733
|
+
uint32_t TMemoryBuffer::readAppendToString(std::string& str, uint32_t len) {
|
|
32734
|
+
// Don't get some stupid assertion failure.
|
|
32735
|
+
if (buffer_ == nullptr) {
|
|
32736
|
+
return 0;
|
|
32737
|
+
}
|
|
32738
|
+
|
|
32739
|
+
uint8_t* start;
|
|
32740
|
+
uint32_t give;
|
|
32741
|
+
computeRead(len, &start, &give);
|
|
32742
|
+
|
|
32743
|
+
// Append to the provided string.
|
|
32744
|
+
str.append((char*)start, give);
|
|
32745
|
+
|
|
32746
|
+
return give;
|
|
32747
|
+
}
|
|
32748
|
+
|
|
32749
|
+
void TMemoryBuffer::ensureCanWrite(uint32_t len) {
|
|
32750
|
+
// Check available space
|
|
32751
|
+
uint32_t avail = available_write();
|
|
32752
|
+
if (len <= avail) {
|
|
32753
|
+
return;
|
|
32754
|
+
}
|
|
32755
|
+
|
|
32756
|
+
if (!owner_) {
|
|
32757
|
+
throw TTransportException("Insufficient space in external MemoryBuffer");
|
|
32758
|
+
}
|
|
32759
|
+
|
|
32760
|
+
// Grow the buffer as necessary.
|
|
32761
|
+
uint64_t new_size = bufferSize_;
|
|
32762
|
+
while (len > avail) {
|
|
32763
|
+
new_size = new_size > 0 ? new_size * 2 : 1;
|
|
32764
|
+
if (new_size > maxBufferSize_) {
|
|
32765
|
+
throw TTransportException(TTransportException::BAD_ARGS,
|
|
32766
|
+
"Internal buffer size overflow");
|
|
32767
|
+
}
|
|
32768
|
+
avail = available_write() + (static_cast<uint32_t>(new_size) - bufferSize_);
|
|
32769
|
+
}
|
|
32770
|
+
|
|
32771
|
+
// Allocate into a new pointer so we don't bork ours if it fails.
|
|
32772
|
+
auto* new_buffer = static_cast<uint8_t*>(std::realloc(buffer_, new_size));
|
|
32773
|
+
if (new_buffer == nullptr) {
|
|
32774
|
+
throw std::bad_alloc();
|
|
32775
|
+
}
|
|
32776
|
+
|
|
32777
|
+
rBase_ = new_buffer + (rBase_ - buffer_);
|
|
32778
|
+
rBound_ = new_buffer + (rBound_ - buffer_);
|
|
32779
|
+
wBase_ = new_buffer + (wBase_ - buffer_);
|
|
32780
|
+
wBound_ = new_buffer + new_size;
|
|
32781
|
+
buffer_ = new_buffer;
|
|
32782
|
+
bufferSize_ = static_cast<uint32_t>(new_size);
|
|
32783
|
+
}
|
|
32784
|
+
|
|
32785
|
+
void TMemoryBuffer::writeSlow(const uint8_t* buf, uint32_t len) {
|
|
32786
|
+
ensureCanWrite(len);
|
|
32787
|
+
|
|
32788
|
+
// Copy into the buffer and increment wBase_.
|
|
32789
|
+
memcpy(wBase_, buf, len);
|
|
32790
|
+
wBase_ += len;
|
|
32791
|
+
}
|
|
32792
|
+
|
|
32793
|
+
void TMemoryBuffer::wroteBytes(uint32_t len) {
|
|
32794
|
+
uint32_t avail = available_write();
|
|
32795
|
+
if (len > avail) {
|
|
32796
|
+
throw TTransportException("Client wrote more bytes than size of buffer.");
|
|
32797
|
+
}
|
|
32798
|
+
wBase_ += len;
|
|
32799
|
+
}
|
|
32800
|
+
|
|
32801
|
+
const uint8_t* TMemoryBuffer::borrowSlow(uint8_t* buf, uint32_t* len) {
|
|
32802
|
+
(void)buf;
|
|
32803
|
+
rBound_ = wBase_;
|
|
32804
|
+
if (available_read() >= *len) {
|
|
32805
|
+
*len = available_read();
|
|
32806
|
+
return rBase_;
|
|
32807
|
+
}
|
|
32808
|
+
return nullptr;
|
|
32809
|
+
}
|
|
32810
|
+
}
|
|
32811
|
+
}
|
|
32812
|
+
} // duckdb_apache::thrift::transport
|
|
32813
|
+
|
|
32814
|
+
|
|
32815
|
+
// LICENSE_CHANGE_END
|
|
32816
|
+
|
|
32817
|
+
|
|
32818
|
+
// LICENSE_CHANGE_BEGIN
|
|
32819
|
+
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #2
|
|
32820
|
+
// See the end of this file for a list
|
|
32821
|
+
|
|
32822
|
+
/*
|
|
32823
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
32824
|
+
* or more contributor license agreements. See the NOTICE file
|
|
32825
|
+
* distributed with this work for additional information
|
|
32826
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
32827
|
+
* to you under the Apache License, Version 2.0 (the
|
|
32828
|
+
* "License"); you may not use this file except in compliance
|
|
32829
|
+
* with the License. You may obtain a copy of the License at
|
|
32830
|
+
*
|
|
32831
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
32832
|
+
*
|
|
32833
|
+
* Unless required by applicable law or agreed to in writing,
|
|
32834
|
+
* software distributed under the License is distributed on an
|
|
32835
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
32836
|
+
* KIND, either express or implied. See the License for the
|
|
32837
|
+
* specific language governing permissions and limitations
|
|
32838
|
+
* under the License.
|
|
32839
|
+
*/
|
|
32840
|
+
|
|
32841
|
+
|
|
32842
|
+
#include <cstring>
|
|
32843
|
+
|
|
32844
|
+
|
|
32845
|
+
|
|
32846
|
+
using std::string;
|
|
32847
|
+
|
|
32848
|
+
namespace duckdb_apache {
|
|
32849
|
+
namespace thrift {
|
|
32850
|
+
namespace transport {
|
|
32851
|
+
|
|
32852
|
+
const char* TTransportException::what() const noexcept {
|
|
32853
|
+
if (message_.empty()) {
|
|
32854
|
+
switch (type_) {
|
|
32855
|
+
case UNKNOWN:
|
|
32856
|
+
return "TTransportException: Unknown transport exception";
|
|
32857
|
+
case NOT_OPEN:
|
|
32858
|
+
return "TTransportException: Transport not open";
|
|
32859
|
+
case TIMED_OUT:
|
|
32860
|
+
return "TTransportException: Timed out";
|
|
32861
|
+
case END_OF_FILE:
|
|
32862
|
+
return "TTransportException: End of file";
|
|
32863
|
+
case INTERRUPTED:
|
|
32864
|
+
return "TTransportException: Interrupted";
|
|
32865
|
+
case BAD_ARGS:
|
|
32866
|
+
return "TTransportException: Invalid arguments";
|
|
32867
|
+
case CORRUPTED_DATA:
|
|
32868
|
+
return "TTransportException: Corrupted Data";
|
|
32869
|
+
case INTERNAL_ERROR:
|
|
32870
|
+
return "TTransportException: Internal error";
|
|
32871
|
+
default:
|
|
32872
|
+
return "TTransportException: (Invalid exception type)";
|
|
32873
|
+
}
|
|
32874
|
+
} else {
|
|
32875
|
+
return message_.c_str();
|
|
32876
|
+
}
|
|
32877
|
+
}
|
|
32878
|
+
}
|
|
32879
|
+
}
|
|
32880
|
+
} // duckdb_apache::thrift::transport
|
|
32881
|
+
|
|
32882
|
+
|
|
32883
|
+
// LICENSE_CHANGE_END
|
|
32884
|
+
|
|
32885
|
+
|
|
32886
32886
|
// LICENSE_CHANGE_BEGIN
|
|
32887
32887
|
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #4
|
|
32888
32888
|
// See the end of this file for a list
|