Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,19 @@ public static void aggregateTableStat(TableStats result, TableStats stats) {
continue;
}

agg.setNumDistVals(agg.getNumDistValues() + cs.getNumDistValues());
agg.setNumNulls(agg.getNumNulls() + cs.getNumNulls());
if (!cs.minIsNotSet() && (agg.minIsNotSet() ||
agg.getMinValue().compareTo(cs.getMinValue()) > 0)) {
agg.setMinValue(cs.getMinValue());
}
if (!cs.maxIsNotSet() && (agg.maxIsNotSet() ||
agg.getMaxValue().compareTo(cs.getMaxValue()) < 0)) {
agg.setMaxValue(stats.getColumnStats().get(i).getMaxValue());
try {
agg.setNumDistVals(agg.getNumDistValues() + cs.getNumDistValues());
agg.setNumNulls(agg.getNumNulls() + cs.getNumNulls());
if (!cs.minIsNotSet() && (agg.minIsNotSet() ||
agg.getMinValue().compareTo(cs.getMinValue()) > 0)) {
agg.setMinValue(cs.getMinValue());
}
if (!cs.maxIsNotSet() && (agg.maxIsNotSet() ||
agg.getMaxValue().compareTo(cs.getMaxValue()) < 0)) {
agg.setMaxValue(stats.getColumnStats().get(i).getMaxValue());
}
} catch (Exception e) {
LOG.warn(e.getMessage(), e);
}
}
}
Expand Down Expand Up @@ -117,15 +121,19 @@ public static TableStats aggregateTableStat(List<TableStats> tableStatses) {
LOG.warn("ERROR: One of column stats is NULL (expected column: " + css[i].getColumn() + ")");
continue;
}
css[i].setNumDistVals(css[i].getNumDistValues() + cs.getNumDistValues());
css[i].setNumNulls(css[i].getNumNulls() + cs.getNumNulls());
if (!cs.minIsNotSet() && (css[i].minIsNotSet() ||
css[i].getMinValue().compareTo(cs.getMinValue()) > 0)) {
css[i].setMinValue(cs.getMinValue());
}
if (!cs.maxIsNotSet() && (css[i].maxIsNotSet() ||
css[i].getMaxValue().compareTo(cs.getMaxValue()) < 0)) {
css[i].setMaxValue(ts.getColumnStats().get(i).getMaxValue());
try {
css[i].setNumDistVals(css[i].getNumDistValues() + cs.getNumDistValues());
css[i].setNumNulls(css[i].getNumNulls() + cs.getNumNulls());
if (!cs.minIsNotSet() && (css[i].minIsNotSet() ||
css[i].getMinValue().compareTo(cs.getMinValue()) > 0)) {
css[i].setMinValue(cs.getMinValue());
}
if (!cs.maxIsNotSet() && (css[i].maxIsNotSet() ||
css[i].getMaxValue().compareTo(cs.getMaxValue()) < 0)) {
css[i].setMaxValue(ts.getColumnStats().get(i).getMaxValue());
}
} catch (Exception e) {
LOG.warn(e.getMessage(), e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public Datum equalsTo(Datum datum) {
return datum;

default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand All @@ -156,7 +156,7 @@ public int compareTo(Datum datum) {
return -1;

default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public int compareTo(Datum datum) {
} else if (datum instanceof NullDatum || datum.isNull()) {
return -1;
} else {
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public Datum equalsTo(Datum datum) {
case NULL_TYPE:
return datum;
default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down Expand Up @@ -195,7 +195,7 @@ public int compareTo(Datum datum) {
case NULL_TYPE:
return -1;
default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down Expand Up @@ -268,7 +268,7 @@ public Datum multiply(Datum datum) {
case NULL_TYPE:
return datum;
default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public Datum equalsTo(Datum datum) {
case NULL_TYPE:
return datum;
default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down Expand Up @@ -184,7 +184,7 @@ public int compareTo(Datum datum) {
case NULL_TYPE:
return -1;
default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down Expand Up @@ -257,7 +257,7 @@ public Datum multiply(Datum datum) {
case NULL_TYPE:
return datum;
default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public Datum equalsTo(Datum datum) {
case NULL_TYPE:
return datum;
default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down Expand Up @@ -186,7 +186,7 @@ public int compareTo(Datum datum) {
case NULL_TYPE:
return -1;
default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public Datum equalsTo(Datum datum) {
case NULL_TYPE:
return datum;
default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down Expand Up @@ -190,7 +190,7 @@ public int compareTo(Datum datum) {
case NULL_TYPE:
return -1;
default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down Expand Up @@ -263,7 +263,7 @@ public Datum multiply(Datum datum) {
case NULL_TYPE:
return datum;
default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public Datum equalsTo(Datum datum) {
case NULL_TYPE:
return datum;
default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down Expand Up @@ -198,7 +198,7 @@ public int compareTo(Datum datum) {
return -1;

default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public IntervalDatum(String intervalStr) {

int length = intervalStr.getBytes().length;

int start = 0;
StringBuilder digitChars = new StringBuilder();
StringBuilder unitChars = new StringBuilder();
for (int i = 0; i < length; i++) {
Expand Down Expand Up @@ -406,7 +405,7 @@ public int compareTo(Datum datum) {
} else if (datum instanceof NullDatum || datum.isNull()) {
return -1;
} else {
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public int compareTo(Datum datum) {
return -1;

default:
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public Datum equalsTo(Datum datum) {
} else if (datum.isNull()) {
return datum;
} else {
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand All @@ -179,7 +179,7 @@ public int compareTo(Datum datum) {
} else if (datum instanceof NullDatum || datum.isNull()) {
return -1;
} else {
throw new InvalidOperationException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public Datum equalsTo(Datum datum) {
} else if (datum.isNull()) {
return datum;
} else {
throw new RuntimeException();
throw new InvalidOperationException(datum.type());
}
}

Expand All @@ -182,7 +182,7 @@ public int compareTo(Datum datum) {
} else if (datum.isNull()) {
return -1;
} else {
throw new RuntimeException();
throw new InvalidOperationException(datum.type());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.apache.tajo.storage;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tajo.catalog.Schema;
import org.apache.tajo.catalog.statistics.ColumnStats;
import org.apache.tajo.catalog.statistics.TableStats;
Expand All @@ -30,6 +32,7 @@
* This class is not thread-safe.
*/
public class TableStatistics {
private static final Log LOG = LogFactory.getLog(TableStatistics.class);
private Schema schema;
private Tuple minValues;
private Tuple maxValues;
Expand Down Expand Up @@ -104,8 +107,18 @@ public TableStats getTableStat() {
for (int i = 0; i < schema.size(); i++) {
columnStats = new ColumnStats(schema.getColumn(i));
columnStats.setNumNulls(numNulls[i]);
columnStats.setMinValue(minValues.get(i));
columnStats.setMaxValue(maxValues.get(i));
if (minValues.get(i) == null || schema.getColumn(i).getDataType().getType() == minValues.get(i).type()) {
columnStats.setMinValue(minValues.get(i));
} else {
LOG.warn("Wrong statistics column type (" + minValues.get(i).type() +
", expected=" + schema.getColumn(i).getDataType().getType() + ")");
}
if (minValues.get(i) == null || schema.getColumn(i).getDataType().getType() == minValues.get(i).type()) {
columnStats.setMaxValue(maxValues.get(i));
} else {
LOG.warn("Wrong statistics column type (" + minValues.get(i).type() +
", expected=" + schema.getColumn(i).getDataType().getType() + ")");
}
stat.addColumnStat(columnStats);
}

Expand Down