implementing writing keys to output in group-by operator rather than aggregators
git-svn-id: https://hyracks.googlecode.com/svn/branches/aggregators_dev_next@983 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-algebricks/hyracks-algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/runtime/operators/aggreg/SerializableAggregatorDescriptorFactory.java b/hyracks-algebricks/hyracks-algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/runtime/operators/aggreg/SerializableAggregatorDescriptorFactory.java
index 92046d7..abfd1c1 100644
--- a/hyracks-algebricks/hyracks-algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/runtime/operators/aggreg/SerializableAggregatorDescriptorFactory.java
+++ b/hyracks-algebricks/hyracks-algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/runtime/operators/aggreg/SerializableAggregatorDescriptorFactory.java
@@ -46,7 +46,6 @@
@Override
public void init(ArrayTupleBuilder tb, IFrameTupleAccessor accessor, int tIndex, AggregateState state)
throws HyracksDataException {
- resetStateTupleBuilder(tb, keys, accessor, tIndex);
DataOutput output = tb.getDataOutput();
ftr.reset(accessor, tIndex);
for (int i = 0; i < aggs.length; i++) {
@@ -77,16 +76,6 @@
}
}
- private void resetStateTupleBuilder(ArrayTupleBuilder tb, final int[] keys, IFrameTupleAccessor accessor,
- int tIndex) throws HyracksDataException {
- // reset
- tb.reset();
- // add keys
- for (int i = 0; i < keys.length; i++) {
- tb.addField(accessor, tIndex, keys[i]);
- }
- }
-
@Override
public void aggregate(IFrameTupleAccessor accessor, int tIndex, IFrameTupleAccessor stateAccessor,
int stateTupleIndex, AggregateState state) throws HyracksDataException {
@@ -107,7 +96,6 @@
@Override
public void outputPartialResult(ArrayTupleBuilder tb, IFrameTupleAccessor accessor, int tIndex,
AggregateState state) throws HyracksDataException {
- resetStateTupleBuilder(tb, keys, accessor, tIndex);
byte[] data = accessor.getBuffer().array();
int startOffset = accessor.getTupleStartOffset(tIndex);
int aggFieldOffset = accessor.getFieldStartOffset(tIndex, offsetFieldIndex);
@@ -127,7 +115,6 @@
@Override
public void outputFinalResult(ArrayTupleBuilder tb, IFrameTupleAccessor accessor, int tIndex,
AggregateState state) throws HyracksDataException {
- resetStateTupleBuilder(tb, keys, accessor, tIndex);
byte[] data = accessor.getBuffer().array();
int startOffset = accessor.getTupleStartOffset(tIndex);
int aggFieldOffset = accessor.getFieldStartOffset(tIndex, offsetFieldIndex);
diff --git a/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/ExternalGroupOperatorDescriptor.java b/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/ExternalGroupOperatorDescriptor.java
index 2483470..ca17779 100644
--- a/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/ExternalGroupOperatorDescriptor.java
+++ b/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/ExternalGroupOperatorDescriptor.java
@@ -499,6 +499,10 @@
finalTupleBuilder.reset();
+ for (int k = 0; k < storedKeys.length; k++) {
+ finalTupleBuilder.addField(outFrameAccessor, i, storedKeys[k]);
+ }
+
if (isFinal) {
aggregator.outputFinalResult(finalTupleBuilder, outFrameAccessor, i, aggregateState);
diff --git a/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/HashSpillableTableFactory.java b/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/HashSpillableTableFactory.java
index 831e497..7d1ecd2 100644
--- a/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/HashSpillableTableFactory.java
+++ b/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/HashSpillableTableFactory.java
@@ -285,6 +285,9 @@
storedKeysAccessor1.reset(frames.get(bIndex));
outputTupleBuilder.reset();
+ for (int k = 0; k < storedKeys.length; k++) {
+ outputTupleBuilder.addField(storedKeysAccessor1, tIndex, storedKeys[k]);
+ }
if (isPartial) {
@@ -329,6 +332,9 @@
storedKeysAccessor1.reset(buffer);
outputTupleBuilder.reset();
+ for (int k = 0; k < storedKeys.length; k++) {
+ outputTupleBuilder.addField(storedKeysAccessor1, tupleIndex, storedKeys[k]);
+ }
if (isPartial) {
diff --git a/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/aggregators/MultiFieldsAggregatorFactory.java b/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/aggregators/MultiFieldsAggregatorFactory.java
index 5c6e94d..6c436a9 100644
--- a/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/aggregators/MultiFieldsAggregatorFactory.java
+++ b/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/aggregators/MultiFieldsAggregatorFactory.java
@@ -80,11 +80,6 @@
@Override
public void outputPartialResult(ArrayTupleBuilder tupleBuilder, IFrameTupleAccessor accessor, int tIndex,
AggregateState state) throws HyracksDataException {
-
- tupleBuilder.reset();
- for (int i = 0; i < keyFieldsInPartialResults.length; i++) {
- tupleBuilder.addField(accessor, tIndex, keyFieldsInPartialResults[i]);
- }
DataOutput dos = tupleBuilder.getDataOutput();
int tupleOffset = accessor.getTupleStartOffset(tIndex);
@@ -101,13 +96,6 @@
@Override
public void outputFinalResult(ArrayTupleBuilder tupleBuilder, IFrameTupleAccessor accessor, int tIndex,
AggregateState state) throws HyracksDataException {
-
- tupleBuilder.reset();
-
- for (int i = 0; i < keyFieldsInPartialResults.length; i++) {
- tupleBuilder.addField(accessor, tIndex, keyFieldsInPartialResults[i]);
- }
-
DataOutput dos = tupleBuilder.getDataOutput();
int tupleOffset = accessor.getTupleStartOffset(tIndex);
@@ -127,11 +115,6 @@
@Override
public void init(ArrayTupleBuilder tupleBuilder, IFrameTupleAccessor accessor, int tIndex,
AggregateState state) throws HyracksDataException {
-
- tupleBuilder.reset();
- for (int i = 0; i < keys.length; i++) {
- tupleBuilder.addField(accessor, tIndex, keys[i]);
- }
DataOutput dos = tupleBuilder.getDataOutput();
for (int i = 0; i < aggregators.length; i++) {