01: /*
02:
03: Derby - Class org.apache.derby.impl.sql.execute.SystemAggregator
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derby.impl.sql.execute;
23:
24: import org.apache.derby.iapi.services.sanity.SanityManager;
25: import org.apache.derby.iapi.error.StandardException;
26: import org.apache.derby.iapi.sql.execute.ExecAggregator;
27: import org.apache.derby.iapi.types.DataValueDescriptor;
28: import java.io.ObjectOutput;
29: import java.io.ObjectInput;
30: import java.io.IOException;
31:
32: /**
33: * Abstract aggregator that is extended by all internal
34: * (system) aggregators.
35: *
36: * @author jamie
37: */
38: abstract class SystemAggregator implements ExecAggregator {
39:
40: private boolean eliminatedNulls;
41:
42: public boolean didEliminateNulls() {
43: return eliminatedNulls;
44: }
45:
46: public void accumulate(DataValueDescriptor addend, Object ga)
47: throws StandardException {
48: if ((addend == null) || addend.isNull()) {
49: eliminatedNulls = true;
50: return;
51: }
52:
53: this .accumulate(addend);
54: }
55:
56: protected abstract void accumulate(DataValueDescriptor addend)
57: throws StandardException;
58:
59: /////////////////////////////////////////////////////////////
60: //
61: // EXTERNALIZABLE INTERFACE
62: //
63: /////////////////////////////////////////////////////////////
64:
65: public void writeExternal(ObjectOutput out) throws IOException {
66: out.writeBoolean(eliminatedNulls);
67: }
68:
69: public void readExternal(ObjectInput in) throws IOException,
70: ClassNotFoundException {
71: eliminatedNulls = in.readBoolean();
72: }
73: }
|