diff options
author | Ben-Zvi <bben-zvi@mapr.com> | 2018-12-10 13:52:53 -0800 |
---|---|---|
committer | Gautam Parai <gparai@apache.org> | 2019-01-03 16:35:30 -0800 |
commit | 10b105953fc2cdee1bee8970ecbaeca285d6bb2d (patch) | |
tree | 9cd170fbf4af235b3deca3794c553ca602232bc9 | |
parent | a9331361c72d47c98ae16087e865bdf61eb01d96 (diff) |
DRILL-6888: Move nested classes outside HashAggTemplate to allow for plain java compile option
closes #1569
3 files changed, 97 insertions, 56 deletions
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggSpilledPartition.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggSpilledPartition.java new file mode 100644 index 000000000..e5e82e0d3 --- /dev/null +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggSpilledPartition.java @@ -0,0 +1,51 @@ +/* + * 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.drill.exec.physical.impl.aggregate; + +import org.apache.drill.exec.physical.impl.common.AbstractSpilledPartitionMetadata; +import org.apache.drill.shaded.guava.com.google.common.base.Preconditions; + +public class HashAggSpilledPartition extends AbstractSpilledPartitionMetadata { + private final int spilledBatches; + private final String spillFile; + + public HashAggSpilledPartition(final int cycle, + final int originPartition, + final int prevOriginPartition, + final int spilledBatches, + final String spillFile) { + super(cycle, originPartition, prevOriginPartition); + + this.spilledBatches = spilledBatches; + this.spillFile = Preconditions.checkNotNull(spillFile); + } + + public int getSpilledBatches() { + return spilledBatches; + } + + public String getSpillFile() { + return spillFile; + } + + @Override + public String makeDebugString() { + return String.format("Start reading spilled partition %d (prev %d) from cycle %d.", + this.getOriginPartition(), this.getPrevOriginPartition(), this.getCycle()); + } +} diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggTemplate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggTemplate.java index d10a84af9..2f50dd6e8 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggTemplate.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggTemplate.java @@ -49,7 +49,6 @@ import org.apache.drill.exec.ops.OperatorContext; import org.apache.drill.exec.ops.OperatorStats; import org.apache.drill.exec.physical.base.AbstractBase; import org.apache.drill.exec.physical.config.HashAggregate; -import org.apache.drill.exec.physical.impl.common.AbstractSpilledPartitionMetadata; import org.apache.drill.exec.physical.impl.common.ChainedHashTable; import org.apache.drill.exec.physical.impl.common.CodeGenMemberInjector; import org.apache.drill.exec.physical.impl.common.HashTable; @@ -84,7 +83,6 @@ import org.apache.drill.exec.vector.ObjectVector; import org.apache.drill.exec.vector.ValueVector; import org.apache.drill.exec.vector.VariableWidthVector; -import org.apache.drill.shaded.guava.com.google.common.base.Preconditions; import static org.apache.drill.exec.physical.impl.common.HashTable.BATCH_MASK; import static org.apache.drill.exec.record.RecordBatch.MAX_BATCH_ROW_COUNT; @@ -149,7 +147,7 @@ public abstract class HashAggTemplate implements HashAggregator { private int outBatchIndex[]; // For handling spilling - private HashAggUpdater updater = new HashAggUpdater(); + private HashAggUpdater updater; private SpilledState<HashAggSpilledPartition> spilledState = new SpilledState<>(); private SpillSet spillSet; SpilledRecordbatch newIncoming; // when reading a spilled file - work like an "incoming" @@ -171,59 +169,6 @@ public abstract class HashAggTemplate implements HashAggregator { private OperatorStats stats = null; private HashTableStats htStats = new HashTableStats(); - public static class HashAggSpilledPartition extends AbstractSpilledPartitionMetadata { - private final int spilledBatches; - private final String spillFile; - - public HashAggSpilledPartition(final int cycle, - final int originPartition, - final int prevOriginPartition, - final int spilledBatches, - final String spillFile) { - super(cycle, originPartition, prevOriginPartition); - - this.spilledBatches = spilledBatches; - this.spillFile = Preconditions.checkNotNull(spillFile); - } - - public int getSpilledBatches() { - return spilledBatches; - } - - public String getSpillFile() { - return spillFile; - } - - @Override - public String makeDebugString() { - return String.format("Start reading spilled partition %d (prev %d) from cycle %d.", - this.getOriginPartition(), this.getPrevOriginPartition(), this.getCycle()); - } - } - - public class HashAggUpdater implements SpilledState.Updater { - - @Override - public void cleanup() { - this.cleanup(); - } - - @Override - public String getFailureMessage() { - return null; - } - - @Override - public long getMemLimit() { - return allocator.getLimit(); - } - - @Override - public boolean hasPartitionLimit() { - return false; - } - } - public enum Metric implements MetricDef { NUM_BUCKETS, @@ -375,6 +320,7 @@ public abstract class HashAggTemplate implements HashAggregator { this.context = context; this.stats = oContext.getStats(); this.allocator = oContext.getAllocator(); + this.updater = new HashAggUpdater(allocator); this.oContext = oContext; this.incoming = incoming; this.outgoing = outgoing; diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggUpdater.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggUpdater.java new file mode 100644 index 000000000..3ee26ebef --- /dev/null +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggUpdater.java @@ -0,0 +1,44 @@ +/* + * 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.drill.exec.physical.impl.aggregate; + +import org.apache.drill.exec.memory.BufferAllocator; +import org.apache.drill.exec.physical.impl.common.SpilledState; + +public class HashAggUpdater implements SpilledState.Updater { + private final BufferAllocator allocator; + public HashAggUpdater(BufferAllocator allocator) { this.allocator = allocator; } + + @Override + public void cleanup() { } + + @Override + public String getFailureMessage() { + return null; + } + + @Override + public long getMemLimit() { + return allocator.getLimit(); + } + + @Override + public boolean hasPartitionLimit() { + return false; + } +} |