Skip to content
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 @@ -24,7 +24,7 @@ public class BinaryStatistics extends Statistics<Binary> {

@Override
public void updateStats(Binary value) {
if (this.isEmpty()) {
if (this.isEmpty() || !this.hasValidValue()) {
initializeStats(value, value);
} else {
updateStats(value, value);
Expand All @@ -34,17 +34,18 @@ public void updateStats(Binary value) {
@Override
public void mergeStatisticsMinMax(Statistics stats) {
BinaryStatistics binaryStats = (BinaryStatistics)stats;
if (this.isEmpty()) {
initializeStats(binaryStats.getMin(), binaryStats.getMax());
} else {
updateStats(binaryStats.getMin(), binaryStats.getMax());
}
if (this.isEmpty() || !this.hasValidValue()) {
initializeStats(binaryStats.getMin(), binaryStats.getMax());
} else {
updateStats(binaryStats.getMin(), binaryStats.getMax());
}
}

@Override
public void setMinMaxFromBytes(byte[] minBytes, byte[] maxBytes) {
max = Binary.fromByteArray(maxBytes);
min = Binary.fromByteArray(minBytes);
this.markHasValidValue();
this.markAsNotEmpty();
}

Expand All @@ -60,8 +61,10 @@ public byte[] getMinBytes() {

@Override
public String toString() {
if(!this.isEmpty())
if(this.hasValidValue())
return String.format("min: %s, max: %s, num_nulls: %d", min.toStringUsingUTF8(), max.toStringUsingUTF8(), this.getNumNulls());
else if(!this.isEmpty())
return String.format("num_nulls: %d, min/max not defined", this.getNumNulls());
else
return "no stats for this column";
}
Expand All @@ -74,6 +77,7 @@ public void updateStats(Binary min_value, Binary max_value) {
public void initializeStats(Binary min_value, Binary max_value) {
min = min_value;
max = max_value;
this.markHasValidValue();
this.markAsNotEmpty();
}

Expand All @@ -87,6 +91,24 @@ public Binary genericGetMax() {
return max;
}

@Override
public void incrementNumNulls() {
if (this.isEmpty()) {
this.markAsNotEmpty();
}

super.incrementNumNulls();
}

@Override
public void incrementNumNulls(long increment) {
if (this.isEmpty()) {
this.markAsNotEmpty();
}

super.incrementNumNulls(increment);
}

public Binary getMax() {
return max;
}
Expand All @@ -98,6 +120,8 @@ public Binary getMin() {
public void setMinMax(Binary min, Binary max) {
this.max = max;
this.min = min;
this.markHasValidValue();
this.markAsNotEmpty();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class BooleanStatistics extends Statistics<Boolean> {

@Override
public void updateStats(boolean value) {
if (this.isEmpty()) {
if (this.isEmpty() || !this.hasValidValue()) {
initializeStats(value, value);
} else {
updateStats(value, value);
Expand All @@ -34,7 +34,7 @@ public void updateStats(boolean value) {
@Override
public void mergeStatisticsMinMax(Statistics stats) {
BooleanStatistics boolStats = (BooleanStatistics)stats;
if (this.isEmpty()) {
if (this.isEmpty() || !this.hasValidValue()) {
initializeStats(boolStats.getMin(), boolStats.getMax());
} else {
updateStats(boolStats.getMin(), boolStats.getMax());
Expand All @@ -45,6 +45,7 @@ public void mergeStatisticsMinMax(Statistics stats) {
public void setMinMaxFromBytes(byte[] minBytes, byte[] maxBytes) {
max = BytesUtils.bytesToBool(maxBytes);
min = BytesUtils.bytesToBool(minBytes);
this.markHasValidValue();
this.markAsNotEmpty();
}

Expand All @@ -60,8 +61,10 @@ public byte[] getMinBytes() {

@Override
public String toString() {
if(!this.isEmpty())
if(this.hasValidValue())
return String.format("min: %b, max: %b, num_nulls: %d", min, max, this.getNumNulls());
else if(!this.isEmpty())
return String.format("num_nulls: %d, min/max not defined", this.getNumNulls());
else
return "no stats for this column";
}
Expand All @@ -74,6 +77,7 @@ public void updateStats(boolean min_value, boolean max_value) {
public void initializeStats(boolean min_value, boolean max_value) {
min = min_value;
max = max_value;
this.markHasValidValue();
this.markAsNotEmpty();
}

Expand All @@ -86,6 +90,24 @@ public Boolean genericGetMin() {
public Boolean genericGetMax() {
return max;
}

@Override
public void incrementNumNulls() {
if (this.isEmpty()) {
this.markAsNotEmpty();
}

super.incrementNumNulls();
}

@Override
public void incrementNumNulls(long increment) {
if (this.isEmpty()) {
this.markAsNotEmpty();
}

super.incrementNumNulls(increment);
}

public boolean getMax() {
return max;
Expand All @@ -98,6 +120,7 @@ public boolean getMin() {
public void setMinMax(boolean min, boolean max) {
this.max = max;
this.min = min;
this.markHasValidValue();
this.markAsNotEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class DoubleStatistics extends Statistics<Double> {

@Override
public void updateStats(double value) {
if (this.isEmpty()) {
if (this.isEmpty() || !this.hasValidValue()) {
initializeStats(value, value);
} else {
updateStats(value, value);
Expand All @@ -34,7 +34,7 @@ public void updateStats(double value) {
@Override
public void mergeStatisticsMinMax(Statistics stats) {
DoubleStatistics doubleStats = (DoubleStatistics)stats;
if (this.isEmpty()) {
if (this.isEmpty() || !this.hasValidValue()) {
initializeStats(doubleStats.getMin(), doubleStats.getMax());
} else {
updateStats(doubleStats.getMin(), doubleStats.getMax());
Expand All @@ -45,6 +45,7 @@ public void mergeStatisticsMinMax(Statistics stats) {
public void setMinMaxFromBytes(byte[] minBytes, byte[] maxBytes) {
max = Double.longBitsToDouble(BytesUtils.bytesToLong(maxBytes));
min = Double.longBitsToDouble(BytesUtils.bytesToLong(minBytes));
this.markHasValidValue();
this.markAsNotEmpty();
}

Expand All @@ -60,9 +61,11 @@ public byte[] getMinBytes() {

@Override
public String toString() {
if(!this.isEmpty())
if(this.hasValidValue())
return String.format("min: %.5f, max: %.5f, num_nulls: %d", min, max, this.getNumNulls());
else
else if(!this.isEmpty())
return String.format("num_nulls: %d, min, max not defined", this.getNumNulls());
else
return "no stats for this column";
}

Expand All @@ -74,6 +77,7 @@ public void updateStats(double min_value, double max_value) {
public void initializeStats(double min_value, double max_value) {
min = min_value;
max = max_value;
this.markHasValidValue();
this.markAsNotEmpty();
}

Expand All @@ -87,6 +91,24 @@ public Double genericGetMax() {
return max;
}

@Override
public void incrementNumNulls() {
if (this.isEmpty()) {
this.markAsNotEmpty();
}

super.incrementNumNulls();
}

@Override
public void incrementNumNulls(long increment) {
if (this.isEmpty()) {
this.markAsNotEmpty();
}

super.incrementNumNulls(increment);
}

public double getMax() {
return max;
}
Expand All @@ -98,6 +120,7 @@ public double getMin() {
public void setMinMax(double min, double max) {
this.max = max;
this.min = min;
this.markHasValidValue();
this.markAsNotEmpty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class FloatStatistics extends Statistics<Float> {

@Override
public void updateStats(float value) {
if (this.isEmpty()) {
if (this.isEmpty() || !this.hasValidValue()) {
initializeStats(value, value);
} else {
updateStats(value, value);
Expand All @@ -34,7 +34,7 @@ public void updateStats(float value) {
@Override
public void mergeStatisticsMinMax(Statistics stats) {
FloatStatistics floatStats = (FloatStatistics)stats;
if (this.isEmpty()) {
if (this.isEmpty() || !this.hasValidValue()) {
initializeStats(floatStats.getMin(), floatStats.getMax());
} else {
updateStats(floatStats.getMin(), floatStats.getMax());
Expand All @@ -45,6 +45,7 @@ public void mergeStatisticsMinMax(Statistics stats) {
public void setMinMaxFromBytes(byte[] minBytes, byte[] maxBytes) {
max = Float.intBitsToFloat(BytesUtils.bytesToInt(maxBytes));
min = Float.intBitsToFloat(BytesUtils.bytesToInt(minBytes));
this.markHasValidValue();
this.markAsNotEmpty();
}

Expand All @@ -60,8 +61,10 @@ public byte[] getMinBytes() {

@Override
public String toString() {
if(!this.isEmpty())
if(this.hasValidValue())
return String.format("min: %.5f, max: %.5f, num_nulls: %d", min, max, this.getNumNulls());
else if(!this.isEmpty())
return String.format("num_nulls: %d, min/max not defined", this.getNumNulls());
else
return "no stats for this column";
}
Expand All @@ -74,6 +77,7 @@ public void updateStats(float min_value, float max_value) {
public void initializeStats(float min_value, float max_value) {
min = min_value;
max = max_value;
this.markHasValidValue();
this.markAsNotEmpty();
}

Expand All @@ -86,6 +90,24 @@ public Float genericGetMin() {
public Float genericGetMax() {
return max;
}

@Override
public void incrementNumNulls() {
if (this.isEmpty()) {
this.markAsNotEmpty();
}

super.incrementNumNulls();
}

@Override
public void incrementNumNulls(long increment) {
if (this.isEmpty()) {
this.markAsNotEmpty();
}

super.incrementNumNulls(increment);
}

public float getMax() {
return max;
Expand All @@ -98,6 +120,7 @@ public float getMin() {
public void setMinMax(float min, float max) {
this.max = max;
this.min = min;
this.markHasValidValue();
this.markAsNotEmpty();
}
}
Loading