[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-08-08 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/orc/pull/128


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-08-07 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r131780372
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,228 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the data compression block size.
+ */
+WriterOptions& setCompressionBlockSize(uint64_t size);
+
+/**
+ * Get the data compression block size.
+ * @return if not set, return default value.
+ */
+uint64_t getCompressionBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
--- End diff --

Sure.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-08-07 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r131738738
  
--- Diff: c++/src/ColumnWriter.cc ---
@@ -0,0 +1,507 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Int128.hh"
+#include "orc/Writer.hh"
+
+#include "ByteRLE.hh"
+#include "ColumnWriter.hh"
+#include "RLE.hh"
+#include "Statistics.hh"
+#include "Timezone.hh"
+
+namespace orc {
+  StreamsFactory::~StreamsFactory() {
+//PASS
+  }
+
+  class StreamsFactoryImpl : public StreamsFactory {
+  public:
+StreamsFactoryImpl(
+   const WriterOptions& writerOptions,
+   OutputStream * outputStream) :
+   options(writerOptions),
+   outStream(outputStream) {
+   }
+
+virtual std::unique_ptr
+createStream(proto::Stream_Kind kind) override;
+  private:
+const WriterOptions& options;
+OutputStream * outStream;
+  };
+
+  std::unique_ptr StreamsFactoryImpl::createStream(
+  proto::Stream_Kind) {
+// In the future, we can decide compression strategy and modifier
+// based on stream kind. But for now we just use the setting from
+// WriterOption
+return createCompressor(
+options.getCompression(),
+outStream,
+options.getCompressionStrategy(),
+options.getBufferSize(),
+options.getBlockSize(),
+*options.getMemoryPool());
+  }
+
+  std::unique_ptr createStreamsFactory(
+const WriterOptions& options,
+OutputStream * outStream) {
+return std::unique_ptr(
+   new StreamsFactoryImpl(options, 
outStream));
+  }
+
+  RowIndexPositionRecorder::~RowIndexPositionRecorder() {
+// PASS
+  }
+
+  ColumnWriter::ColumnWriter(
+ const Type& type,
+ StreamsFactory& factory,
+ const WriterOptions& options) :
+columnId(type.getColumnId()),
+streamsFactory(factory),
+colIndexStatistics(),
+colStripeStatistics(),
+colFileStatistics(),
+enableIndex(options.getEnableIndex()),
+enableStats(options.getEnableStats()),
+rowIndex(),
+rowIndexEntry(),
+rowIndexPosition(),
+memPool(*options.getMemoryPool()),
+indexStream() {
+
+std::unique_ptr presentStream =
+factory.createStream(proto::Stream_Kind_PRESENT);
+notNullEncoder = createBooleanRleEncoder(std::move(presentStream));
+
+if (enableIndex || enableStats) {
+  bool enableStrCmp = options.getEnableStrStatsCmp();
+  colIndexStatistics = createColumnStatistics(type, enableStrCmp);
+  if (enableStats) {
+colStripeStatistics = createColumnStatistics(type, enableStrCmp);
+colFileStatistics = createColumnStatistics(type, enableStrCmp);
+  }
+}
+
+if (enableIndex) {
+  rowIndex = std::unique_ptr(new proto::RowIndex());
+  rowIndexEntry =
+std::unique_ptr(new proto::RowIndexEntry());
+  rowIndexPosition = std::unique_ptr(
+ new RowIndexPositionRecorder(*rowIndexEntry));
+  indexStream =
+

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-08-07 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r131718481
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,228 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the data compression block size.
+ */
+WriterOptions& setCompressionBlockSize(uint64_t size);
+
+/**
+ * Get the data compression block size.
+ * @return if not set, return default value.
+ */
+uint64_t getCompressionBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set Orc file version
+ */
+WriterOptions& setFileVersion(const FileVersion& version);
+
+/**
+ * Get Orc file version
+ */
+FileVersion getFileVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**
+ * Set the compression strategy.
+ */
+WriterOptions& setCompressionStrategy(CompressionStrategy strategy);
+
+/**
+ * Get the compression strategy.
+ * @return if not set, return default value which is speed.
+ */
+CompressionStrategy getCompressionStrategy() const;
+
+/**
+ * Set the padding tolerance.
+ */
+WriterOptions& setPaddingTolerance(double tolerance);
+
+/**
+ * Get the padding tolerance.
+ * @return if not set, return default value which is zero.
+ */
+double getPaddingTolerance() const;

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-08-07 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r131738380
  
--- Diff: c++/include/orc/Common.hh ---
@@ -27,6 +27,30 @@
 #include 
 
 namespace orc {
+
+  class FileVersion {
--- End diff --

You should have 2 instance values for HIVE_0_11 and HIVE_0_12. With the 
current implementation, you'll need to throw if they use anything but 
HIVE_0_11, since that corresponds to RLEv1. We'll also need to have 
Reader.getFormatVersion() return this type too, but that can be done later.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-08-07 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r131718185
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,228 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the data compression block size.
+ */
+WriterOptions& setCompressionBlockSize(uint64_t size);
+
+/**
+ * Get the data compression block size.
+ * @return if not set, return default value.
+ */
+uint64_t getCompressionBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
--- End diff --

Please add a comment here that setting the stride to 0 disables the index.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-07-20 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r128647874
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**
+ 

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-07-19 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r128392669
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**
+ 

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-07-17 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r127855671
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-07-17 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r127855265
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-07-17 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r127854823
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-07-17 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r127853962
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
--- End diff --

Ok, after tracking through the code I understand what they are being used 
for now. The source of confusion is that C++ and Java are using the names very 
differently.

C++ | Java | Use
-| -| --
setBlockSize  | bufferSize | set the compression chunk size
setBufferSize | n/a | set space pre-allocated for each stream
n/a  | blockSize  | set the HDFS block size

C++'s setBuffer size is an artifact of preallocating the stream in a single 
chunk. I think we should use the compression chunk size for now, remove 
setBufferSize, either rename or document really well C++'s setBlockSize, and 
improve the memory management later.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-29 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r124720147
  
--- Diff: c++/src/ColumnWriter.cc ---
@@ -0,0 +1,507 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Int128.hh"
+#include "orc/Writer.hh"
+
+#include "ByteRLE.hh"
+#include "ColumnWriter.hh"
+#include "RLE.hh"
+#include "Statistics.hh"
+#include "Timezone.hh"
+
+namespace orc {
+  StreamsFactory::~StreamsFactory() {
+//PASS
+  }
+
+  class StreamsFactoryImpl : public StreamsFactory {
+  public:
+StreamsFactoryImpl(
+   const WriterOptions& writerOptions,
+   OutputStream* outputStream) :
+   options(writerOptions),
+   outStream(outputStream) {
+   }
+
+virtual std::unique_ptr
+createStream(proto::Stream_Kind kind) override;
+  private:
+const WriterOptions& options;
+OutputStream* outStream;
+  };
+
+  std::unique_ptr StreamsFactoryImpl::createStream(
+  proto::Stream_Kind) {
+// In the future, we can decide compression strategy and modifier
+// based on stream kind. But for now we just use the setting from
+// WriterOption
+return createCompressor(
+options.getCompression(),
+outStream,
+options.getCompressionStrategy(),
+options.getBufferSize(),
+options.getBlockSize(),
+*options.getMemoryPool());
+  }
+
+  std::unique_ptr createStreamsFactory(
+const WriterOptions& options,
+OutputStream* outStream) {
+return std::unique_ptr(
+   new StreamsFactoryImpl(options, 
outStream));
+  }
+
+  RowIndexPositionRecorder::~RowIndexPositionRecorder() {
+// PASS
+  }
+
+  ColumnWriter::ColumnWriter(
+ const Type& type,
+ StreamsFactory& factory,
+ const WriterOptions& options) :
+columnId(type.getColumnId()),
+streamsFactory(factory),
+colIndexStatistics(),
+colStripeStatistics(),
+colFileStatistics(),
+enableIndex(options.getEnableIndex()),
+enableStats(options.getEnableStats()),
+rowIndex(),
+rowIndexEntry(),
+rowIndexPosition(),
+memPool(*options.getMemoryPool()),
+indexStream() {
+
+std::unique_ptr presentStream =
+factory.createStream(proto::Stream_Kind_PRESENT);
+notNullEncoder = createBooleanRleEncoder(std::move(presentStream));
+
+if (enableIndex || enableStats) {
+  bool enableStrCmp = options.getEnableStrStatsCmp();
+  colIndexStatistics = createColumnStatistics(type, enableStrCmp);
+  if (enableStats) {
+colStripeStatistics = createColumnStatistics(type, enableStrCmp);
+colFileStatistics = createColumnStatistics(type, enableStrCmp);
+  }
+}
+
+if (enableIndex) {
+  rowIndex = std::unique_ptr(new proto::RowIndex());
+  rowIndexEntry =
+std::unique_ptr(new proto::RowIndexEntry());
+  rowIndexPosition = std::unique_ptr(
+ new RowIndexPositionRecorder(*rowIndexEntry));
+  indexStream =
+

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-29 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r124720134
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**
+ 

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-29 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r124718827
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**
+ 

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-29 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r124718523
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**
+ 

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-29 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r124718336
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
--- End diff --

Sure. Will do.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-28 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r124715175
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
--- End diff --

I will add a FileVersion enum. I will still keep RleVersion enum for 
creating different version of encoder but will remove it from public header.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-28 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r124667097
  
--- Diff: c++/src/ColumnWriter.cc ---
@@ -0,0 +1,507 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Int128.hh"
+#include "orc/Writer.hh"
+
+#include "ByteRLE.hh"
+#include "ColumnWriter.hh"
+#include "RLE.hh"
+#include "Statistics.hh"
+#include "Timezone.hh"
+
+namespace orc {
+  StreamsFactory::~StreamsFactory() {
+//PASS
+  }
+
+  class StreamsFactoryImpl : public StreamsFactory {
+  public:
+StreamsFactoryImpl(
+   const WriterOptions& writerOptions,
+   OutputStream* outputStream) :
+   options(writerOptions),
+   outStream(outputStream) {
+   }
+
+virtual std::unique_ptr
+createStream(proto::Stream_Kind kind) override;
+  private:
+const WriterOptions& options;
+OutputStream* outStream;
+  };
+
+  std::unique_ptr StreamsFactoryImpl::createStream(
+  proto::Stream_Kind) {
+// In the future, we can decide compression strategy and modifier
+// based on stream kind. But for now we just use the setting from
+// WriterOption
+return createCompressor(
+options.getCompression(),
+outStream,
+options.getCompressionStrategy(),
+options.getBufferSize(),
+options.getBlockSize(),
+*options.getMemoryPool());
+  }
+
+  std::unique_ptr createStreamsFactory(
+const WriterOptions& options,
+OutputStream* outStream) {
+return std::unique_ptr(
+   new StreamsFactoryImpl(options, 
outStream));
+  }
+
+  RowIndexPositionRecorder::~RowIndexPositionRecorder() {
+// PASS
+  }
+
+  ColumnWriter::ColumnWriter(
+ const Type& type,
+ StreamsFactory& factory,
+ const WriterOptions& options) :
+columnId(type.getColumnId()),
+streamsFactory(factory),
+colIndexStatistics(),
+colStripeStatistics(),
+colFileStatistics(),
+enableIndex(options.getEnableIndex()),
+enableStats(options.getEnableStats()),
+rowIndex(),
+rowIndexEntry(),
+rowIndexPosition(),
+memPool(*options.getMemoryPool()),
+indexStream() {
+
+std::unique_ptr presentStream =
+factory.createStream(proto::Stream_Kind_PRESENT);
+notNullEncoder = createBooleanRleEncoder(std::move(presentStream));
+
+if (enableIndex || enableStats) {
+  bool enableStrCmp = options.getEnableStrStatsCmp();
+  colIndexStatistics = createColumnStatistics(type, enableStrCmp);
+  if (enableStats) {
+colStripeStatistics = createColumnStatistics(type, enableStrCmp);
+colFileStatistics = createColumnStatistics(type, enableStrCmp);
+  }
+}
+
+if (enableIndex) {
+  rowIndex = std::unique_ptr(new proto::RowIndex());
+  rowIndexEntry =
+std::unique_ptr(new proto::RowIndexEntry());
+  rowIndexPosition = std::unique_ptr(
+ new RowIndexPositionRecorder(*rowIndexEntry));
+  indexStream =
+

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-28 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r124665356
  
--- Diff: c++/src/ColumnWriter.cc ---
@@ -0,0 +1,507 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Int128.hh"
+#include "orc/Writer.hh"
+
+#include "ByteRLE.hh"
+#include "ColumnWriter.hh"
+#include "RLE.hh"
+#include "Statistics.hh"
+#include "Timezone.hh"
+
+namespace orc {
+  StreamsFactory::~StreamsFactory() {
+//PASS
+  }
+
+  class StreamsFactoryImpl : public StreamsFactory {
+  public:
+StreamsFactoryImpl(
+   const WriterOptions& writerOptions,
+   OutputStream * outputStream) :
+   options(writerOptions),
+   outStream(outputStream) {
+   }
+
+virtual std::unique_ptr
+createStream(proto::Stream_Kind kind) override;
+  private:
+const WriterOptions& options;
+OutputStream * outStream;
+  };
+
+  std::unique_ptr StreamsFactoryImpl::createStream(
+  proto::Stream_Kind) {
+// In the future, we can decide compression strategy and modifier
+// based on stream kind. But for now we just use the setting from
+// WriterOption
+return createCompressor(
+options.getCompression(),
+outStream,
+options.getCompressionStrategy(),
+options.getBufferSize(),
+options.getBlockSize(),
+*options.getMemoryPool());
+  }
+
+  std::unique_ptr createStreamsFactory(
+const WriterOptions& options,
+OutputStream * outStream) {
+return std::unique_ptr(
+   new StreamsFactoryImpl(options, 
outStream));
+  }
+
+  RowIndexPositionRecorder::~RowIndexPositionRecorder() {
+// PASS
+  }
+
+  ColumnWriter::ColumnWriter(
+ const Type& type,
+ StreamsFactory& factory,
+ const WriterOptions& options) :
+columnId(type.getColumnId()),
+streamsFactory(factory),
+colIndexStatistics(),
+colStripeStatistics(),
+colFileStatistics(),
+enableIndex(options.getEnableIndex()),
+enableStats(options.getEnableStats()),
+rowIndex(),
+rowIndexEntry(),
+rowIndexPosition(),
+memPool(*options.getMemoryPool()),
+indexStream() {
+
+std::unique_ptr presentStream =
+factory.createStream(proto::Stream_Kind_PRESENT);
+notNullEncoder = createBooleanRleEncoder(std::move(presentStream));
+
+if (enableIndex || enableStats) {
+  bool enableStrCmp = options.getEnableStrStatsCmp();
+  colIndexStatistics = createColumnStatistics(type, enableStrCmp);
+  if (enableStats) {
+colStripeStatistics = createColumnStatistics(type, enableStrCmp);
+colFileStatistics = createColumnStatistics(type, enableStrCmp);
+  }
+}
+
+if (enableIndex) {
+  rowIndex = std::unique_ptr(new proto::RowIndex());
+  rowIndexEntry =
+std::unique_ptr(new proto::RowIndexEntry());
+  rowIndexPosition = std::unique_ptr(
+ new RowIndexPositionRecorder(*rowIndexEntry));
+  indexStream =
+

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-28 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r124657688
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-28 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r124658015
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-28 Thread omalley
Github user omalley commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r124657014
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-07 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120799267
  
--- Diff: c++/src/Writer.cc ---
@@ -0,0 +1,659 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Common.hh"
+#include "orc/OrcFile.hh"
+
+#include "ColumnWriter.hh"
+#include "Timezone.hh"
+
+#include 
+
+namespace orc {
+
+  struct WriterOptionsPrivate {
+uint64_t stripeSize;
+uint64_t blockSize;
+uint64_t rowIndexStride;
+uint64_t bufferSize;
+bool blockPadding;
+CompressionKind compression;
+EncodingStrategy encodingStrategy;
+CompressionStrategy compressionStrategy;
+MemoryPool* memoryPool;
+WriterVersion version;
+double paddingTolerance;
+std::ostream* errorStream;
+RleVersion rleVersion;
+double dictionaryKeySizeThreshold;
+bool enableStats;
+bool enableStrStatsCmp;
+bool enableIndex;
+const Timezone* timezone;
+
+WriterOptionsPrivate() {
+  stripeSize = 64 * 1024 * 1024; // 64M
+  blockSize = 256 * 1024; // 256K
+  rowIndexStride = 1;
+  bufferSize = 4 * 1024 * 1024; // 4M
+  blockPadding = false;
+  compression = CompressionKind_ZLIB;
+  encodingStrategy = EncodingStrategy_SPEED;
+  compressionStrategy = CompressionStrategy_SPEED;
+  memoryPool = getDefaultPool();
+  version = WriterVersion_ORC_135;
+  paddingTolerance = 0.0;
+  errorStream = ::cerr;
+  rleVersion = RleVersion_1;
+  dictionaryKeySizeThreshold = 0.0;
+  enableStats = true;
+  enableStrStatsCmp = false;
+  enableIndex = true;
+  timezone = ();
+}
+  };
+
+  WriterOptions::WriterOptions():
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate())) {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(const WriterOptions& rhs):
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate(*(rhs.privateBits.get() {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(WriterOptions& rhs) {
+// swap privateBits with rhs
+WriterOptionsPrivate* l = privateBits.release();
+privateBits.reset(rhs.privateBits.release());
+rhs.privateBits.reset(l);
+  }
+
+  WriterOptions& WriterOptions::operator=(const WriterOptions& rhs) {
+if (this != ) {
+  privateBits.reset(new 
WriterOptionsPrivate(*(rhs.privateBits.get(;
+}
+return *this;
+  }
+
+  WriterOptions::~WriterOptions() {
+// PASS
+  }
+
+  WriterOptions& WriterOptions::setStripeSize(uint64_t size) {
+privateBits->stripeSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getStripeSize() const {
+return privateBits->stripeSize;
+  }
+
+  WriterOptions& WriterOptions::setBlockSize(uint64_t size) {
+privateBits->blockSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBlockSize() const {
+return privateBits->blockSize;
+  }
+
+  WriterOptions& WriterOptions::setRowIndexStride(uint64_t stride) {
+privateBits->rowIndexStride = stride;
+return *this;
+  }
+
+  uint64_t WriterOptions::getRowIndexStride() const {
+return privateBits->rowIndexStride;
+  }
+
+  WriterOptions& WriterOptions::setBufferSize(uint64_t size) {
+privateBits->bufferSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBufferSize() const {
+return privateBits->bufferSize;
+  }
+
+  WriterOptions& WriterOptions::setDictionaryKeySizeThreshold(double val) {
+privateBits->dictionaryKeySizeThreshold = val;
+return *this;
+  }
+
+  double WriterOptions::getDictionaryKeySizeThreshold() const {
+return privateBits->dictionaryKeySizeThreshold;

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-07 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120751420
  
--- Diff: c++/src/Writer.cc ---
@@ -0,0 +1,659 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Common.hh"
+#include "orc/OrcFile.hh"
+
+#include "ColumnWriter.hh"
+#include "Timezone.hh"
+
+#include 
+
+namespace orc {
+
+  struct WriterOptionsPrivate {
+uint64_t stripeSize;
+uint64_t blockSize;
+uint64_t rowIndexStride;
+uint64_t bufferSize;
+bool blockPadding;
+CompressionKind compression;
+EncodingStrategy encodingStrategy;
+CompressionStrategy compressionStrategy;
+MemoryPool* memoryPool;
+WriterVersion version;
+double paddingTolerance;
+std::ostream* errorStream;
+RleVersion rleVersion;
+double dictionaryKeySizeThreshold;
+bool enableStats;
+bool enableStrStatsCmp;
+bool enableIndex;
+const Timezone* timezone;
+
+WriterOptionsPrivate() {
+  stripeSize = 64 * 1024 * 1024; // 64M
+  blockSize = 256 * 1024; // 256K
+  rowIndexStride = 1;
+  bufferSize = 4 * 1024 * 1024; // 4M
+  blockPadding = false;
+  compression = CompressionKind_ZLIB;
+  encodingStrategy = EncodingStrategy_SPEED;
+  compressionStrategy = CompressionStrategy_SPEED;
+  memoryPool = getDefaultPool();
+  version = WriterVersion_ORC_135;
+  paddingTolerance = 0.0;
+  errorStream = ::cerr;
+  rleVersion = RleVersion_1;
+  dictionaryKeySizeThreshold = 0.0;
+  enableStats = true;
+  enableStrStatsCmp = false;
+  enableIndex = true;
+  timezone = ();
+}
+  };
+
+  WriterOptions::WriterOptions():
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate())) {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(const WriterOptions& rhs):
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate(*(rhs.privateBits.get() {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(WriterOptions& rhs) {
+// swap privateBits with rhs
+WriterOptionsPrivate* l = privateBits.release();
+privateBits.reset(rhs.privateBits.release());
+rhs.privateBits.reset(l);
+  }
+
+  WriterOptions& WriterOptions::operator=(const WriterOptions& rhs) {
+if (this != ) {
+  privateBits.reset(new 
WriterOptionsPrivate(*(rhs.privateBits.get(;
+}
+return *this;
+  }
+
+  WriterOptions::~WriterOptions() {
+// PASS
+  }
+
+  WriterOptions& WriterOptions::setStripeSize(uint64_t size) {
+privateBits->stripeSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getStripeSize() const {
+return privateBits->stripeSize;
+  }
+
+  WriterOptions& WriterOptions::setBlockSize(uint64_t size) {
+privateBits->blockSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBlockSize() const {
+return privateBits->blockSize;
+  }
+
+  WriterOptions& WriterOptions::setRowIndexStride(uint64_t stride) {
+privateBits->rowIndexStride = stride;
+return *this;
+  }
+
+  uint64_t WriterOptions::getRowIndexStride() const {
+return privateBits->rowIndexStride;
+  }
+
+  WriterOptions& WriterOptions::setBufferSize(uint64_t size) {
+privateBits->bufferSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBufferSize() const {
+return privateBits->bufferSize;
+  }
+
+  WriterOptions& WriterOptions::setDictionaryKeySizeThreshold(double val) {
+privateBits->dictionaryKeySizeThreshold = val;
+return *this;
+  }
+
+  double WriterOptions::getDictionaryKeySizeThreshold() const {
+return privateBits->dictionaryKeySizeThreshold;

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-07 Thread majetideepak
Github user majetideepak commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120745645
  
--- Diff: c++/src/Writer.cc ---
@@ -0,0 +1,659 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Common.hh"
+#include "orc/OrcFile.hh"
+
+#include "ColumnWriter.hh"
+#include "Timezone.hh"
+
+#include 
+
+namespace orc {
+
+  struct WriterOptionsPrivate {
+uint64_t stripeSize;
+uint64_t blockSize;
+uint64_t rowIndexStride;
+uint64_t bufferSize;
+bool blockPadding;
+CompressionKind compression;
+EncodingStrategy encodingStrategy;
+CompressionStrategy compressionStrategy;
+MemoryPool* memoryPool;
+WriterVersion version;
+double paddingTolerance;
+std::ostream* errorStream;
+RleVersion rleVersion;
+double dictionaryKeySizeThreshold;
+bool enableStats;
+bool enableStrStatsCmp;
+bool enableIndex;
+const Timezone* timezone;
+
+WriterOptionsPrivate() {
+  stripeSize = 64 * 1024 * 1024; // 64M
+  blockSize = 256 * 1024; // 256K
+  rowIndexStride = 1;
+  bufferSize = 4 * 1024 * 1024; // 4M
+  blockPadding = false;
+  compression = CompressionKind_ZLIB;
+  encodingStrategy = EncodingStrategy_SPEED;
+  compressionStrategy = CompressionStrategy_SPEED;
+  memoryPool = getDefaultPool();
+  version = WriterVersion_ORC_135;
+  paddingTolerance = 0.0;
+  errorStream = ::cerr;
+  rleVersion = RleVersion_1;
+  dictionaryKeySizeThreshold = 0.0;
+  enableStats = true;
+  enableStrStatsCmp = false;
+  enableIndex = true;
+  timezone = ();
+}
+  };
+
+  WriterOptions::WriterOptions():
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate())) {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(const WriterOptions& rhs):
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate(*(rhs.privateBits.get() {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(WriterOptions& rhs) {
+// swap privateBits with rhs
+WriterOptionsPrivate* l = privateBits.release();
+privateBits.reset(rhs.privateBits.release());
+rhs.privateBits.reset(l);
+  }
+
+  WriterOptions& WriterOptions::operator=(const WriterOptions& rhs) {
+if (this != ) {
+  privateBits.reset(new 
WriterOptionsPrivate(*(rhs.privateBits.get(;
+}
+return *this;
+  }
+
+  WriterOptions::~WriterOptions() {
+// PASS
+  }
+
+  WriterOptions& WriterOptions::setStripeSize(uint64_t size) {
+privateBits->stripeSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getStripeSize() const {
+return privateBits->stripeSize;
+  }
+
+  WriterOptions& WriterOptions::setBlockSize(uint64_t size) {
+privateBits->blockSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBlockSize() const {
+return privateBits->blockSize;
+  }
+
+  WriterOptions& WriterOptions::setRowIndexStride(uint64_t stride) {
+privateBits->rowIndexStride = stride;
+return *this;
+  }
+
+  uint64_t WriterOptions::getRowIndexStride() const {
+return privateBits->rowIndexStride;
+  }
+
+  WriterOptions& WriterOptions::setBufferSize(uint64_t size) {
+privateBits->bufferSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBufferSize() const {
+return privateBits->bufferSize;
+  }
+
+  WriterOptions& WriterOptions::setDictionaryKeySizeThreshold(double val) {
+privateBits->dictionaryKeySizeThreshold = val;
+return *this;
+  }
+
+  double WriterOptions::getDictionaryKeySizeThreshold() const {
+return 

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-07 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120739743
  
--- Diff: c++/src/Writer.cc ---
@@ -0,0 +1,659 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Common.hh"
+#include "orc/OrcFile.hh"
+
+#include "ColumnWriter.hh"
+#include "Timezone.hh"
+
+#include 
+
+namespace orc {
+
+  struct WriterOptionsPrivate {
+uint64_t stripeSize;
+uint64_t blockSize;
+uint64_t rowIndexStride;
+uint64_t bufferSize;
+bool blockPadding;
+CompressionKind compression;
+EncodingStrategy encodingStrategy;
+CompressionStrategy compressionStrategy;
+MemoryPool* memoryPool;
+WriterVersion version;
+double paddingTolerance;
+std::ostream* errorStream;
+RleVersion rleVersion;
+double dictionaryKeySizeThreshold;
+bool enableStats;
+bool enableStrStatsCmp;
+bool enableIndex;
+const Timezone* timezone;
+
+WriterOptionsPrivate() {
+  stripeSize = 64 * 1024 * 1024; // 64M
+  blockSize = 256 * 1024; // 256K
+  rowIndexStride = 1;
+  bufferSize = 4 * 1024 * 1024; // 4M
+  blockPadding = false;
+  compression = CompressionKind_ZLIB;
+  encodingStrategy = EncodingStrategy_SPEED;
+  compressionStrategy = CompressionStrategy_SPEED;
+  memoryPool = getDefaultPool();
+  version = WriterVersion_ORC_135;
+  paddingTolerance = 0.0;
+  errorStream = ::cerr;
+  rleVersion = RleVersion_1;
+  dictionaryKeySizeThreshold = 0.0;
+  enableStats = true;
+  enableStrStatsCmp = false;
+  enableIndex = true;
+  timezone = ();
+}
+  };
+
+  WriterOptions::WriterOptions():
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate())) {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(const WriterOptions& rhs):
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate(*(rhs.privateBits.get() {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(WriterOptions& rhs) {
+// swap privateBits with rhs
+WriterOptionsPrivate* l = privateBits.release();
+privateBits.reset(rhs.privateBits.release());
+rhs.privateBits.reset(l);
+  }
+
+  WriterOptions& WriterOptions::operator=(const WriterOptions& rhs) {
+if (this != ) {
+  privateBits.reset(new 
WriterOptionsPrivate(*(rhs.privateBits.get(;
+}
+return *this;
+  }
+
+  WriterOptions::~WriterOptions() {
+// PASS
+  }
+
+  WriterOptions& WriterOptions::setStripeSize(uint64_t size) {
+privateBits->stripeSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getStripeSize() const {
+return privateBits->stripeSize;
+  }
+
+  WriterOptions& WriterOptions::setBlockSize(uint64_t size) {
+privateBits->blockSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBlockSize() const {
+return privateBits->blockSize;
+  }
+
+  WriterOptions& WriterOptions::setRowIndexStride(uint64_t stride) {
+privateBits->rowIndexStride = stride;
+return *this;
+  }
+
+  uint64_t WriterOptions::getRowIndexStride() const {
+return privateBits->rowIndexStride;
+  }
+
+  WriterOptions& WriterOptions::setBufferSize(uint64_t size) {
+privateBits->bufferSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBufferSize() const {
+return privateBits->bufferSize;
+  }
+
+  WriterOptions& WriterOptions::setDictionaryKeySizeThreshold(double val) {
+privateBits->dictionaryKeySizeThreshold = val;
+return *this;
+  }
+
+  double WriterOptions::getDictionaryKeySizeThreshold() const {
+return privateBits->dictionaryKeySizeThreshold;

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-07 Thread majetideepak
Github user majetideepak commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120728928
  
--- Diff: c++/src/Writer.cc ---
@@ -0,0 +1,659 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Common.hh"
+#include "orc/OrcFile.hh"
+
+#include "ColumnWriter.hh"
+#include "Timezone.hh"
+
+#include 
+
+namespace orc {
+
+  struct WriterOptionsPrivate {
+uint64_t stripeSize;
+uint64_t blockSize;
+uint64_t rowIndexStride;
+uint64_t bufferSize;
+bool blockPadding;
+CompressionKind compression;
+EncodingStrategy encodingStrategy;
+CompressionStrategy compressionStrategy;
+MemoryPool* memoryPool;
+WriterVersion version;
+double paddingTolerance;
+std::ostream* errorStream;
+RleVersion rleVersion;
+double dictionaryKeySizeThreshold;
+bool enableStats;
+bool enableStrStatsCmp;
+bool enableIndex;
+const Timezone* timezone;
+
+WriterOptionsPrivate() {
+  stripeSize = 64 * 1024 * 1024; // 64M
+  blockSize = 256 * 1024; // 256K
+  rowIndexStride = 1;
+  bufferSize = 4 * 1024 * 1024; // 4M
+  blockPadding = false;
+  compression = CompressionKind_ZLIB;
+  encodingStrategy = EncodingStrategy_SPEED;
+  compressionStrategy = CompressionStrategy_SPEED;
+  memoryPool = getDefaultPool();
+  version = WriterVersion_ORC_135;
+  paddingTolerance = 0.0;
+  errorStream = ::cerr;
+  rleVersion = RleVersion_1;
+  dictionaryKeySizeThreshold = 0.0;
+  enableStats = true;
+  enableStrStatsCmp = false;
+  enableIndex = true;
+  timezone = ();
+}
+  };
+
+  WriterOptions::WriterOptions():
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate())) {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(const WriterOptions& rhs):
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate(*(rhs.privateBits.get() {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(WriterOptions& rhs) {
+// swap privateBits with rhs
+WriterOptionsPrivate* l = privateBits.release();
+privateBits.reset(rhs.privateBits.release());
+rhs.privateBits.reset(l);
+  }
+
+  WriterOptions& WriterOptions::operator=(const WriterOptions& rhs) {
+if (this != ) {
+  privateBits.reset(new 
WriterOptionsPrivate(*(rhs.privateBits.get(;
+}
+return *this;
+  }
+
+  WriterOptions::~WriterOptions() {
+// PASS
+  }
+
+  WriterOptions& WriterOptions::setStripeSize(uint64_t size) {
+privateBits->stripeSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getStripeSize() const {
+return privateBits->stripeSize;
+  }
+
+  WriterOptions& WriterOptions::setBlockSize(uint64_t size) {
+privateBits->blockSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBlockSize() const {
+return privateBits->blockSize;
+  }
+
+  WriterOptions& WriterOptions::setRowIndexStride(uint64_t stride) {
+privateBits->rowIndexStride = stride;
+return *this;
+  }
+
+  uint64_t WriterOptions::getRowIndexStride() const {
+return privateBits->rowIndexStride;
+  }
+
+  WriterOptions& WriterOptions::setBufferSize(uint64_t size) {
+privateBits->bufferSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBufferSize() const {
+return privateBits->bufferSize;
+  }
+
+  WriterOptions& WriterOptions::setDictionaryKeySizeThreshold(double val) {
+privateBits->dictionaryKeySizeThreshold = val;
+return *this;
+  }
+
+  double WriterOptions::getDictionaryKeySizeThreshold() const {
+return 

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-07 Thread majetideepak
Github user majetideepak commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120729334
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-07 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120708078
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+/**
+ 

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-07 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120706989
  
--- Diff: c++/src/Writer.cc ---
@@ -0,0 +1,659 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Common.hh"
+#include "orc/OrcFile.hh"
+
+#include "ColumnWriter.hh"
+#include "Timezone.hh"
+
+#include 
+
+namespace orc {
+
+  struct WriterOptionsPrivate {
+uint64_t stripeSize;
+uint64_t blockSize;
+uint64_t rowIndexStride;
+uint64_t bufferSize;
+bool blockPadding;
+CompressionKind compression;
+EncodingStrategy encodingStrategy;
+CompressionStrategy compressionStrategy;
+MemoryPool *memoryPool;
+WriterVersion version;
+double paddingTolerance;
+std::ostream* errorStream;
+RleVersion rleVersion;
+double dictionaryKeySizeThreshold;
+bool enableStats;
+bool enableStrStatsCmp;
+bool enableIndex;
+const Timezone* timezone;
+
+WriterOptionsPrivate() {
+  stripeSize = 64 * 1024 * 1024; // 64M
+  blockSize = 256 * 1024; // 256K
+  rowIndexStride = 1;
+  bufferSize = 4 * 1024 * 1024; // 4M
+  blockPadding = false;
+  compression = CompressionKind_ZLIB;
+  encodingStrategy = EncodingStrategy_SPEED;
+  compressionStrategy = CompressionStrategy_SPEED;
+  memoryPool = getDefaultPool();
+  version = WriterVersion_ORC_135;
+  paddingTolerance = 0.0;
+  errorStream = ::cerr;
+  rleVersion = RleVersion_1;
+  dictionaryKeySizeThreshold = 0.0;
+  enableStats = true;
+  enableStrStatsCmp = false;
+  enableIndex = true;
+  timezone = ();
+}
+  };
+
+  WriterOptions::WriterOptions():
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate())) {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(const WriterOptions& rhs):
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate(*(rhs.privateBits.get() {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(WriterOptions& rhs) {
+// swap privateBits with rhs
+WriterOptionsPrivate* l = privateBits.release();
+privateBits.reset(rhs.privateBits.release());
+rhs.privateBits.reset(l);
+  }
+
+  WriterOptions& WriterOptions::operator=(const WriterOptions& rhs) {
+if (this != ) {
+  privateBits.reset(new 
WriterOptionsPrivate(*(rhs.privateBits.get(;
+}
+return *this;
+  }
+
+  WriterOptions::~WriterOptions() {
+// PASS
+  }
+
+  WriterOptions& WriterOptions::setStripeSize(uint64_t size) {
+privateBits->stripeSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getStripeSize() const {
+return privateBits->stripeSize;
+  }
+
+  WriterOptions& WriterOptions::setBlockSize(uint64_t size) {
+privateBits->blockSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBlockSize() const {
+return privateBits->blockSize;
+  }
+
+  WriterOptions& WriterOptions::setRowIndexStride(uint64_t stride) {
+privateBits->rowIndexStride = stride;
+return *this;
+  }
+
+  uint64_t WriterOptions::getRowIndexStride() const {
+return privateBits->rowIndexStride;
+  }
+
+  WriterOptions& WriterOptions::setBufferSize(uint64_t size) {
+privateBits->bufferSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBufferSize() const {
+return privateBits->bufferSize;
+  }
+
+  WriterOptions& WriterOptions::setDictionaryKeySizeThreshold(double val) {
+privateBits->dictionaryKeySizeThreshold = val;
+return *this;
+  }
+
+  double WriterOptions::getDictionaryKeySizeThreshold() const {
+return privateBits->dictionaryKeySizeThreshold;

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-07 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120704852
  
--- Diff: c++/src/ColumnWriter.cc ---
@@ -0,0 +1,507 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Int128.hh"
+#include "orc/Writer.hh"
+
+#include "ByteRLE.hh"
+#include "ColumnWriter.hh"
+#include "RLE.hh"
+#include "Statistics.hh"
+#include "Timezone.hh"
+
+namespace orc {
+  StreamsFactory::~StreamsFactory() {
+//PASS
+  }
+
+  class StreamsFactoryImpl : public StreamsFactory {
+  public:
+StreamsFactoryImpl(
+   const WriterOptions& writerOptions,
+   OutputStream * outputStream) :
+   options(writerOptions),
+   outStream(outputStream) {
+   }
+
+virtual std::unique_ptr
+createStream(proto::Stream_Kind kind) override;
+  private:
+const WriterOptions& options;
+OutputStream * outStream;
+  };
+
+  std::unique_ptr StreamsFactoryImpl::createStream(
+  proto::Stream_Kind) {
+// In the future, we can decide compression strategy and modifier
+// based on stream kind. But for now we just use the setting from
+// WriterOption
+return createCompressor(
+options.getCompression(),
+outStream,
+options.getCompressionStrategy(),
+options.getBufferSize(),
+options.getBlockSize(),
+*options.getMemoryPool());
+  }
+
+  std::unique_ptr createStreamsFactory(
+const WriterOptions& options,
+OutputStream * outStream) {
+return std::unique_ptr(
+   new StreamsFactoryImpl(options, 
outStream));
+  }
+
+  RowIndexPositionRecorder::~RowIndexPositionRecorder() {
+// PASS
+  }
+
+  ColumnWriter::ColumnWriter(
+ const Type& type,
+ StreamsFactory& factory,
+ const WriterOptions& options) :
+columnId(type.getColumnId()),
+streamsFactory(factory),
+colIndexStatistics(),
+colStripeStatistics(),
+colFileStatistics(),
+enableIndex(options.getEnableIndex()),
+enableStats(options.getEnableStats()),
+rowIndex(),
+rowIndexEntry(),
+rowIndexPosition(),
+memPool(*options.getMemoryPool()),
+indexStream() {
+
+std::unique_ptr presentStream =
+factory.createStream(proto::Stream_Kind_PRESENT);
+notNullEncoder = createBooleanRleEncoder(std::move(presentStream));
+
+if (enableIndex || enableStats) {
+  bool enableStrCmp = options.getEnableStrStatsCmp();
+  colIndexStatistics = createColumnStatistics(type, enableStrCmp);
+  if (enableStats) {
+colStripeStatistics = createColumnStatistics(type, enableStrCmp);
+colFileStatistics = createColumnStatistics(type, enableStrCmp);
+  }
+}
+
+if (enableIndex) {
+  rowIndex = std::unique_ptr(new proto::RowIndex());
+  rowIndexEntry =
+std::unique_ptr(new proto::RowIndexEntry());
+  rowIndexPosition = std::unique_ptr(
+ new RowIndexPositionRecorder(*rowIndexEntry));
+  indexStream =
+

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-07 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120701079
  
--- Diff: c++/src/ColumnWriter.cc ---
@@ -0,0 +1,507 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Int128.hh"
+#include "orc/Writer.hh"
+
+#include "ByteRLE.hh"
+#include "ColumnWriter.hh"
+#include "RLE.hh"
+#include "Statistics.hh"
+#include "Timezone.hh"
+
+namespace orc {
+  StreamsFactory::~StreamsFactory() {
+//PASS
+  }
+
+  class StreamsFactoryImpl : public StreamsFactory {
+  public:
+StreamsFactoryImpl(
+   const WriterOptions& writerOptions,
+   OutputStream * outputStream) :
+   options(writerOptions),
+   outStream(outputStream) {
+   }
+
+virtual std::unique_ptr
+createStream(proto::Stream_Kind kind) override;
+  private:
+const WriterOptions& options;
+OutputStream * outStream;
+  };
+
+  std::unique_ptr StreamsFactoryImpl::createStream(
+  proto::Stream_Kind) {
+// In the future, we can decide compression strategy and modifier
+// based on stream kind. But for now we just use the setting from
+// WriterOption
+return createCompressor(
+options.getCompression(),
+outStream,
+options.getCompressionStrategy(),
+options.getBufferSize(),
+options.getBlockSize(),
+*options.getMemoryPool());
+  }
+
+  std::unique_ptr createStreamsFactory(
+const WriterOptions& options,
+OutputStream * outStream) {
+return std::unique_ptr(
+   new StreamsFactoryImpl(options, 
outStream));
+  }
+
+  RowIndexPositionRecorder::~RowIndexPositionRecorder() {
+// PASS
+  }
+
+  ColumnWriter::ColumnWriter(
+ const Type& type,
+ StreamsFactory& factory,
+ const WriterOptions& options) :
+columnId(type.getColumnId()),
+streamsFactory(factory),
+colIndexStatistics(),
+colStripeStatistics(),
+colFileStatistics(),
+enableIndex(options.getEnableIndex()),
+enableStats(options.getEnableStats()),
+rowIndex(),
+rowIndexEntry(),
+rowIndexPosition(),
+memPool(*options.getMemoryPool()),
+indexStream() {
+
+std::unique_ptr presentStream =
+factory.createStream(proto::Stream_Kind_PRESENT);
+notNullEncoder = createBooleanRleEncoder(std::move(presentStream));
+
+if (enableIndex || enableStats) {
+  bool enableStrCmp = options.getEnableStrStatsCmp();
+  colIndexStatistics = createColumnStatistics(type, enableStrCmp);
+  if (enableStats) {
+colStripeStatistics = createColumnStatistics(type, enableStrCmp);
+colFileStatistics = createColumnStatistics(type, enableStrCmp);
+  }
+}
+
+if (enableIndex) {
+  rowIndex = std::unique_ptr(new proto::RowIndex());
+  rowIndexEntry =
+std::unique_ptr(new proto::RowIndexEntry());
+  rowIndexPosition = std::unique_ptr(
+ new RowIndexPositionRecorder(*rowIndexEntry));
+  indexStream =
+

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-07 Thread xndai
Github user xndai commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120699358
  
--- Diff: c++/include/orc/OrcFile.hh ---
@@ -119,6 +120,17 @@ namespace orc {
* @param path the name of the file in the local file system
*/
   ORC_UNIQUE_PTR writeLocalFile(const std::string& path);
+
+  /**
+   * Create a writer to write the ORC file.
+   * @param type the type of data to be written
+   * @param stream the stream to write to
+   * @param options the options for writing the file
+   */
+  ORC_UNIQUE_PTR createWriter(
+  const Type& type,
+  OutputStream * stream,
--- End diff --

I will fix all occurrences of the space issue.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-06 Thread majetideepak
Github user majetideepak commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120483146
  
--- Diff: c++/include/orc/Writer.hh ---
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ORC_WRITER_HH
+#define ORC_WRITER_HH
+
+#include "orc/Common.hh"
+#include "orc/orc-config.hh"
+#include "orc/Type.hh"
+#include "orc/Vector.hh"
+
+#include 
+#include 
+#include 
+
+namespace orc {
+
+  // classes that hold data members so we can maintain binary compatibility
+  struct WriterOptionsPrivate;
+
+  enum EncodingStrategy {
+EncodingStrategy_SPEED = 0,
+EncodingStrategy_COMPRESSION
+  };
+
+  enum CompressionStrategy {
+CompressionStrategy_SPEED = 0,
+CompressionStrategy_COMPRESSION
+  };
+
+  enum RleVersion {
+RleVersion_1,
+RleVersion_2
+  };
+
+  class Timezone;
+
+  /**
+   * Options for creating a Writer.
+   */
+  class WriterOptions {
+  private:
+ORC_UNIQUE_PTR privateBits;
+
+  public:
+WriterOptions();
+WriterOptions(const WriterOptions&);
+WriterOptions(WriterOptions&);
+WriterOptions& operator=(const WriterOptions&);
+virtual ~WriterOptions();
+
+/**
+ * Set the strip size.
+ */
+WriterOptions& setStripeSize(uint64_t size);
+
+/**
+ * Get the strip size.
+ * @return if not set, return default value.
+ */
+uint64_t getStripeSize() const;
+
+/**
+ * Set the block size.
+ */
+WriterOptions& setBlockSize(uint64_t size);
+
+/**
+ * Get the block size.
+ * @return if not set, return default value.
+ */
+uint64_t getBlockSize() const;
+
+/**
+ * Set row index stride.
+ */
+WriterOptions& setRowIndexStride(uint64_t stride);
+
+/**
+ * Get the index stride size.
+ * @return if not set, return default value.
+ */
+uint64_t getRowIndexStride() const;
+
+/**
+ * Set the buffer size.
+ */
+WriterOptions& setBufferSize(uint64_t size);
+
+/**
+ * Get the buffer size.
+ * @return if not set, return default value.
+ */
+uint64_t getBufferSize() const;
+
+/**
+ * Set the dictionary key size threshold.
+ * 0 to disable dictionary encoding.
+ * 1 to always enable dictionary encoding.
+ */
+WriterOptions& setDictionaryKeySizeThreshold(double val);
+
+/**
+ * Get the dictionary key size threshold.
+ */
+double getDictionaryKeySizeThreshold() const;
+
+/**
+ * Set whether or not to have block padding.
+ */
+WriterOptions& setBlockPadding(bool padding);
+
+/**
+ * Get whether or not to have block padding.
+ * @return if not set, return default value which is false.
+ */
+bool getBlockPadding() const;
+
+/**
+ * Set Run length encoding version
+ */
+WriterOptions& setRleVersion(RleVersion version);
+
+/**
+ * Get Run Length Encoding version
+ */
+RleVersion getRleVersion() const;
+
+/**
+ * Set compression kind.
+ */
+WriterOptions& setCompression(CompressionKind comp);
+
+/**
+ * Get the compression kind.
+ * @return if not set, return default value which is ZLIB.
+ */
+CompressionKind getCompression() const;
+
+/**
+ * Set the encoding strategy.
+ */
+WriterOptions& setEncodingStrategy(EncodingStrategy strategy);
+
+/**
+ * Get the encoding strategy.
+ * @return if not set, return default value which is SPEED.
+ */
+EncodingStrategy getEncodingStrategy() const;
+
+

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-06 Thread majetideepak
Github user majetideepak commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120476831
  
--- Diff: c++/src/Writer.cc ---
@@ -0,0 +1,659 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Common.hh"
+#include "orc/OrcFile.hh"
+
+#include "ColumnWriter.hh"
+#include "Timezone.hh"
+
+#include 
+
+namespace orc {
+
+  struct WriterOptionsPrivate {
+uint64_t stripeSize;
+uint64_t blockSize;
+uint64_t rowIndexStride;
+uint64_t bufferSize;
+bool blockPadding;
+CompressionKind compression;
+EncodingStrategy encodingStrategy;
+CompressionStrategy compressionStrategy;
+MemoryPool *memoryPool;
+WriterVersion version;
+double paddingTolerance;
+std::ostream* errorStream;
+RleVersion rleVersion;
+double dictionaryKeySizeThreshold;
+bool enableStats;
+bool enableStrStatsCmp;
+bool enableIndex;
+const Timezone* timezone;
+
+WriterOptionsPrivate() {
+  stripeSize = 64 * 1024 * 1024; // 64M
+  blockSize = 256 * 1024; // 256K
+  rowIndexStride = 1;
+  bufferSize = 4 * 1024 * 1024; // 4M
+  blockPadding = false;
+  compression = CompressionKind_ZLIB;
+  encodingStrategy = EncodingStrategy_SPEED;
+  compressionStrategy = CompressionStrategy_SPEED;
+  memoryPool = getDefaultPool();
+  version = WriterVersion_ORC_135;
+  paddingTolerance = 0.0;
+  errorStream = ::cerr;
+  rleVersion = RleVersion_1;
+  dictionaryKeySizeThreshold = 0.0;
+  enableStats = true;
+  enableStrStatsCmp = false;
+  enableIndex = true;
+  timezone = ();
+}
+  };
+
+  WriterOptions::WriterOptions():
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate())) {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(const WriterOptions& rhs):
+privateBits(std::unique_ptr
+(new WriterOptionsPrivate(*(rhs.privateBits.get() {
+// PASS
+  }
+
+  WriterOptions::WriterOptions(WriterOptions& rhs) {
+// swap privateBits with rhs
+WriterOptionsPrivate* l = privateBits.release();
+privateBits.reset(rhs.privateBits.release());
+rhs.privateBits.reset(l);
+  }
+
+  WriterOptions& WriterOptions::operator=(const WriterOptions& rhs) {
+if (this != ) {
+  privateBits.reset(new 
WriterOptionsPrivate(*(rhs.privateBits.get(;
+}
+return *this;
+  }
+
+  WriterOptions::~WriterOptions() {
+// PASS
+  }
+
+  WriterOptions& WriterOptions::setStripeSize(uint64_t size) {
+privateBits->stripeSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getStripeSize() const {
+return privateBits->stripeSize;
+  }
+
+  WriterOptions& WriterOptions::setBlockSize(uint64_t size) {
+privateBits->blockSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBlockSize() const {
+return privateBits->blockSize;
+  }
+
+  WriterOptions& WriterOptions::setRowIndexStride(uint64_t stride) {
+privateBits->rowIndexStride = stride;
+return *this;
+  }
+
+  uint64_t WriterOptions::getRowIndexStride() const {
+return privateBits->rowIndexStride;
+  }
+
+  WriterOptions& WriterOptions::setBufferSize(uint64_t size) {
+privateBits->bufferSize = size;
+return *this;
+  }
+
+  uint64_t WriterOptions::getBufferSize() const {
+return privateBits->bufferSize;
+  }
+
+  WriterOptions& WriterOptions::setDictionaryKeySizeThreshold(double val) {
+privateBits->dictionaryKeySizeThreshold = val;
+return *this;
+  }
+
+  double WriterOptions::getDictionaryKeySizeThreshold() const {
+return 

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-06 Thread majetideepak
Github user majetideepak commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r119640657
  
--- Diff: c++/include/orc/OrcFile.hh ---
@@ -119,6 +120,17 @@ namespace orc {
* @param path the name of the file in the local file system
*/
   ORC_UNIQUE_PTR writeLocalFile(const std::string& path);
+
+  /**
+   * Create a writer to write the ORC file.
+   * @param type the type of data to be written
+   * @param stream the stream to write to
+   * @param options the options for writing the file
+   */
+  ORC_UNIQUE_PTR createWriter(
+  const Type& type,
+  OutputStream * stream,
--- End diff --

remove space `OutputStream*`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-06 Thread majetideepak
Github user majetideepak commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120483772
  
--- Diff: c++/src/ColumnWriter.cc ---
@@ -0,0 +1,507 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Int128.hh"
+#include "orc/Writer.hh"
+
+#include "ByteRLE.hh"
+#include "ColumnWriter.hh"
+#include "RLE.hh"
+#include "Statistics.hh"
+#include "Timezone.hh"
+
+namespace orc {
+  StreamsFactory::~StreamsFactory() {
+//PASS
+  }
+
+  class StreamsFactoryImpl : public StreamsFactory {
+  public:
+StreamsFactoryImpl(
+   const WriterOptions& writerOptions,
+   OutputStream * outputStream) :
+   options(writerOptions),
+   outStream(outputStream) {
+   }
+
+virtual std::unique_ptr
+createStream(proto::Stream_Kind kind) override;
+  private:
+const WriterOptions& options;
+OutputStream * outStream;
+  };
+
+  std::unique_ptr StreamsFactoryImpl::createStream(
+  proto::Stream_Kind) {
+// In the future, we can decide compression strategy and modifier
+// based on stream kind. But for now we just use the setting from
+// WriterOption
+return createCompressor(
+options.getCompression(),
+outStream,
+options.getCompressionStrategy(),
+options.getBufferSize(),
+options.getBlockSize(),
+*options.getMemoryPool());
+  }
+
+  std::unique_ptr createStreamsFactory(
+const WriterOptions& options,
+OutputStream * outStream) {
+return std::unique_ptr(
+   new StreamsFactoryImpl(options, 
outStream));
+  }
+
+  RowIndexPositionRecorder::~RowIndexPositionRecorder() {
+// PASS
+  }
+
+  ColumnWriter::ColumnWriter(
+ const Type& type,
+ StreamsFactory& factory,
+ const WriterOptions& options) :
+columnId(type.getColumnId()),
+streamsFactory(factory),
+colIndexStatistics(),
+colStripeStatistics(),
+colFileStatistics(),
+enableIndex(options.getEnableIndex()),
+enableStats(options.getEnableStats()),
+rowIndex(),
+rowIndexEntry(),
+rowIndexPosition(),
+memPool(*options.getMemoryPool()),
+indexStream() {
+
+std::unique_ptr presentStream =
+factory.createStream(proto::Stream_Kind_PRESENT);
+notNullEncoder = createBooleanRleEncoder(std::move(presentStream));
+
+if (enableIndex || enableStats) {
+  bool enableStrCmp = options.getEnableStrStatsCmp();
+  colIndexStatistics = createColumnStatistics(type, enableStrCmp);
+  if (enableStats) {
+colStripeStatistics = createColumnStatistics(type, enableStrCmp);
+colFileStatistics = createColumnStatistics(type, enableStrCmp);
+  }
+}
+
+if (enableIndex) {
+  rowIndex = std::unique_ptr(new proto::RowIndex());
+  rowIndexEntry =
+std::unique_ptr(new proto::RowIndexEntry());
+  rowIndexPosition = std::unique_ptr(
+ new RowIndexPositionRecorder(*rowIndexEntry));
+  indexStream =
+

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-06 Thread majetideepak
Github user majetideepak commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r119641608
  
--- Diff: c++/src/ColumnWriter.cc ---
@@ -0,0 +1,507 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Int128.hh"
+#include "orc/Writer.hh"
+
+#include "ByteRLE.hh"
+#include "ColumnWriter.hh"
+#include "RLE.hh"
+#include "Statistics.hh"
+#include "Timezone.hh"
+
+namespace orc {
+  StreamsFactory::~StreamsFactory() {
+//PASS
+  }
+
+  class StreamsFactoryImpl : public StreamsFactory {
+  public:
+StreamsFactoryImpl(
+   const WriterOptions& writerOptions,
+   OutputStream * outputStream) :
--- End diff --

Remove space `OutputStream*`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-06-06 Thread majetideepak
Github user majetideepak commented on a diff in the pull request:

https://github.com/apache/orc/pull/128#discussion_r120458268
  
--- Diff: c++/src/ColumnWriter.cc ---
@@ -0,0 +1,507 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/Int128.hh"
+#include "orc/Writer.hh"
+
+#include "ByteRLE.hh"
+#include "ColumnWriter.hh"
+#include "RLE.hh"
+#include "Statistics.hh"
+#include "Timezone.hh"
+
+namespace orc {
+  StreamsFactory::~StreamsFactory() {
+//PASS
+  }
+
+  class StreamsFactoryImpl : public StreamsFactory {
+  public:
+StreamsFactoryImpl(
+   const WriterOptions& writerOptions,
+   OutputStream * outputStream) :
+   options(writerOptions),
+   outStream(outputStream) {
+   }
+
+virtual std::unique_ptr
+createStream(proto::Stream_Kind kind) override;
+  private:
+const WriterOptions& options;
+OutputStream * outStream;
+  };
+
+  std::unique_ptr StreamsFactoryImpl::createStream(
+  proto::Stream_Kind) {
+// In the future, we can decide compression strategy and modifier
+// based on stream kind. But for now we just use the setting from
+// WriterOption
+return createCompressor(
+options.getCompression(),
+outStream,
+options.getCompressionStrategy(),
+options.getBufferSize(),
+options.getBlockSize(),
+*options.getMemoryPool());
+  }
+
+  std::unique_ptr createStreamsFactory(
+const WriterOptions& options,
+OutputStream * outStream) {
+return std::unique_ptr(
+   new StreamsFactoryImpl(options, 
outStream));
+  }
+
+  RowIndexPositionRecorder::~RowIndexPositionRecorder() {
+// PASS
+  }
+
+  ColumnWriter::ColumnWriter(
+ const Type& type,
+ StreamsFactory& factory,
+ const WriterOptions& options) :
+columnId(type.getColumnId()),
+streamsFactory(factory),
+colIndexStatistics(),
+colStripeStatistics(),
+colFileStatistics(),
+enableIndex(options.getEnableIndex()),
+enableStats(options.getEnableStats()),
+rowIndex(),
+rowIndexEntry(),
+rowIndexPosition(),
+memPool(*options.getMemoryPool()),
+indexStream() {
+
+std::unique_ptr presentStream =
+factory.createStream(proto::Stream_Kind_PRESENT);
+notNullEncoder = createBooleanRleEncoder(std::move(presentStream));
+
+if (enableIndex || enableStats) {
+  bool enableStrCmp = options.getEnableStrStatsCmp();
+  colIndexStatistics = createColumnStatistics(type, enableStrCmp);
+  if (enableStats) {
+colStripeStatistics = createColumnStatistics(type, enableStrCmp);
+colFileStatistics = createColumnStatistics(type, enableStrCmp);
+  }
+}
+
+if (enableIndex) {
+  rowIndex = std::unique_ptr(new proto::RowIndex());
+  rowIndexEntry =
+std::unique_ptr(new proto::RowIndexEntry());
+  rowIndexPosition = std::unique_ptr(
+ new RowIndexPositionRecorder(*rowIndexEntry));
+  indexStream =
+

[GitHub] orc pull request #128: ORC-178 Implement Basic C++ Writer and Writer Option

2017-05-24 Thread xndai
GitHub user xndai opened a pull request:

https://github.com/apache/orc/pull/128

ORC-178 Implement Basic C++ Writer and Writer Option

1. Add basic Writer and WriterOption
2. Add StructColumnWriter and IntegerColumnWriter. With them, we will be
able to write a complete ORC file that contains only int columns. To
limit the scope of this change, we will add more column writers later.
3. Add a base class for column statistics impl classes. This
is to be used by the base class of ColumnWriter so we don't have to
duplicate a bunch of logics everywhere.
4. Right now the UTs are pretty primative. We will add more UTs
(especially for stats and index) as we are adding more column writers.
At this moment, it's really hard to extract more UTs from our code base
without intorducing additional column writers.

Change-Id: I694dda600136e5d285e70a8124aa1cc334f4ef14

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/xndai/orc dev_writer

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/orc/pull/128.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #128


commit 013d18dc459f75763fa1951717c9d3624ab38519
Author: Xiening.Dai 
Date:   2017-05-24T22:01:52Z

ORC-178 Implement Basic C++ Writer and Writer Option

1. Add basic Writer and WriterOption
2. Add StructColumnWriter and IntegerColumnWriter. With them, we will be
able to write a complete ORC file that contains only int columns. To
limit the scope of this change, we will add more column writers later.
3. Add a base class for column statistics impl classes. This
is to be used by the base class of ColumnWriter so we don't have to
duplicate a bunch of logics everywhere.
4. Right now the UTs are pretty primative. We will add more UTs
(especially for stats and index) as we are adding more column writers.
At this moment, it's really hard to extract more UTs from our code base
without intorducing additional column writers.

Change-Id: I694dda600136e5d285e70a8124aa1cc334f4ef14




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---