Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 077CA200C85 for ; Tue, 30 May 2017 23:52:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 05C11160BE3; Tue, 30 May 2017 21:52:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4C675160BB1 for ; Tue, 30 May 2017 23:52:09 +0200 (CEST) Received: (qmail 65801 invoked by uid 500); 30 May 2017 21:52:06 -0000 Mailing-List: contact dev-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list dev@drill.apache.org Received: (qmail 64818 invoked by uid 99); 30 May 2017 21:52:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 May 2017 21:52:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0F41DE029E; Tue, 30 May 2017 21:52:06 +0000 (UTC) From: paul-rogers To: dev@drill.apache.org Reply-To: dev@drill.apache.org References: In-Reply-To: Subject: [GitHub] drill pull request #846: DRILL-5544: Out of heap running CTAS against text d... Content-Type: text/plain Message-Id: <20170530215206.0F41DE029E@git1-us-west.apache.org> Date: Tue, 30 May 2017 21:52:06 +0000 (UTC) archived-at: Tue, 30 May 2017 21:52:10 -0000 Github user paul-rogers commented on a diff in the pull request: https://github.com/apache/drill/pull/846#discussion_r119187078 --- Diff: exec/java-exec/src/main/java/org/apache/parquet/hadoop/ParquetColumnChunkPageWriteStore.java --- @@ -0,0 +1,269 @@ +/* + * 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. + */ +package org.apache.parquet.hadoop; + +import static org.apache.parquet.column.statistics.Statistics.getStatsBasedOnType; + +import java.io.Closeable; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.apache.drill.exec.store.parquet.ParquetDirectByteBufferAllocator; +import org.apache.parquet.bytes.BytesInput; +import org.apache.parquet.bytes.CapacityByteArrayOutputStream; +import org.apache.parquet.column.ColumnDescriptor; +import org.apache.parquet.column.Encoding; +import org.apache.parquet.column.page.DictionaryPage; +import org.apache.parquet.column.page.PageWriteStore; +import org.apache.parquet.column.page.PageWriter; +import org.apache.parquet.column.statistics.Statistics; +import org.apache.parquet.format.converter.ParquetMetadataConverter; +import org.apache.parquet.hadoop.CodecFactory.BytesCompressor; +import org.apache.parquet.io.ParquetEncodingException; +import org.apache.parquet.schema.MessageType; +import org.apache.parquet.bytes.ByteBufferAllocator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This is a copy of ColumnChunkPageWriteStore from parquet library except of OutputStream that is used here. + * Using of CapacityByteArrayOutputStream allows to use different ByteBuffer allocators. --- End diff -- A broader question. Is this code trying to write all of the Parquet chunk data to a memory buffer before writing to disk? What is the maximum file size? The size of one chunk? (256 MB or 512 MB?) Or, the size of the whole multi-chunk file? Many GB? Now, suppose this runs in parallel. Suppose we run, say, 10 of these at once. Would we need 10 * 256 MB memory = 2.5 GB? Or, if the file is 4 GB, would we need 10 * 4 GB = 40GB of memory to write the files concurrently? If so, I wonder if the problem is more than just using direct memory vs. heap. The problem is trying to buffer data in memory that properly belongs on disk. Perhaps the Parquet format is not designed for efficient writes. Is that the case? What prevents efficient writes and forces buffering? Given that, should we have a spill-to-disk solution? Write blocks to a temp file, then assemble them into the final file? All this needs to be considered because, as we try to manage memory, having a write that makes unlimited use of direct memory will be a problem. Perhaps add some notes somewhere to explain how Parquet does the writes. Or, if that is already described in Parquet somewhere, please just include a link to that description. --- 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 infrastructure@apache.org or file a JIRA ticket with INFRA. ---