wgtmac commented on code in PR #1307:
URL: https://github.com/apache/orc/pull/1307#discussion_r1018628411
##########
c++/src/ColumnWriter.cc:
##########
@@ -415,109 +415,97 @@ namespace orc {
}
}
+ template <typename BatchType>
class IntegerColumnWriter : public ColumnWriter {
public:
IntegerColumnWriter(const Type& type, const StreamsFactory& factory,
- const WriterOptions& options);
+ const WriterOptions& options)
+ : ColumnWriter(type, factory, options),
rleVersion(options.getRleVersion()) {
+ std::unique_ptr<BufferedOutputStream> dataStream =
+ factory.createStream(proto::Stream_Kind_DATA);
+ rleEncoder = createRleEncoder(std::move(dataStream), true, rleVersion,
memPool,
+ options.getAlignedBitpacking());
- virtual void add(ColumnVectorBatch& rowBatch, uint64_t offset, uint64_t
numValues,
- const char* incomingMask) override;
+ if (enableIndex) {
+ recordPosition();
+ }
+ }
- virtual void flush(std::vector<proto::Stream>& streams) override;
+ virtual void add(ColumnVectorBatch& rowBatch, uint64_t offset, uint64_t
numValues,
+ const char* incomingMask) override {
+ const BatchType* intBatch = dynamic_cast<const BatchType*>(&rowBatch);
+ if (intBatch == nullptr) {
+ throw InvalidArgument("Failed to cast to LongVectorBatch");
Review Comment:
```suggestion
throw InvalidArgument("Failed to cast to integer vector batch");
```
##########
c++/src/MemoryPool.cc:
##########
@@ -180,6 +198,60 @@ namespace orc {
currentSize = newSize;
}
+ // Specializations for int32_t
+
+ template <>
+ DataBuffer<int32_t>::~DataBuffer() {
+ if (buf) {
+ memoryPool.free(reinterpret_cast<char*>(buf));
+ }
+ }
+
+ template <>
+ void DataBuffer<int32_t>::resize(uint64_t newSize) {
+ reserve(newSize);
+ if (newSize > currentSize) {
+ memset(buf + currentSize, 0, (newSize - currentSize) * sizeof(int32_t));
+ }
+ currentSize = newSize;
+ }
+
+ // Specializations for int16_t
+
+ template <>
+ DataBuffer<int16_t>::~DataBuffer() {
+ if (buf) {
+ memoryPool.free(reinterpret_cast<char*>(buf));
+ }
+ }
+
+ template <>
+ void DataBuffer<int16_t>::resize(uint64_t newSize) {
Review Comment:
resize of different vectors should also be in the unit test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]