/** * Hash code for the statistics object * @return hash code int */ @Override public int hashCode() { return 31 * type.hashCode() + 31 * Arrays.hashCode(getMaxBytes()) + 17 * Arrays.hashCode(getMinBytes()) + Long.valueOf(this.getNumNulls()).hashCode(); }
/** * Hash code for the statistics object * @return hash code int */ @Override public int hashCode() { return 31 * type.hashCode() + 31 * Arrays.hashCode(getMaxBytes()) + 17 * Arrays.hashCode(getMinBytes()) + Long.valueOf(this.getNumNulls()).hashCode(); }
/** * Equality comparison method to compare two statistics objects. * @param other Object to compare against * @return true if objects are equal, false otherwise */ @Override public boolean equals(Object other) { if (other == this) return true; if (!(other instanceof Statistics)) return false; Statistics stats = (Statistics) other; return type.equals(stats.type) && Arrays.equals(stats.getMaxBytes(), this.getMaxBytes()) && Arrays.equals(stats.getMinBytes(), this.getMinBytes()) && stats.getNumNulls() == this.getNumNulls(); }
/** * Equality comparison method to compare two statistics objects. * @param other Object to compare against * @return true if objects are equal, false otherwise */ @Override public boolean equals(Object other) { if (other == this) return true; if (!(other instanceof Statistics)) return false; Statistics stats = (Statistics) other; return type.equals(stats.type) && Arrays.equals(stats.getMaxBytes(), this.getMaxBytes()) && Arrays.equals(stats.getMinBytes(), this.getMinBytes()) && stats.getNumNulls() == this.getNumNulls(); }
/** * Creates decimal statistics where min and max values are re-created using given scale. * * @param statistics statistics that needs to be adjusted * @param scale adjustment scale * @return adjusted statistics */ @SuppressWarnings("unchecked") private Statistics<C> adjustDecimalStatistics(Statistics<C> statistics, int scale) { byte[] minBytes = new BigDecimal(new BigInteger(statistics.getMinBytes())) .setScale(scale, RoundingMode.HALF_UP).unscaledValue().toByteArray(); byte[] maxBytes = new BigDecimal(new BigInteger(statistics.getMaxBytes())) .setScale(scale, RoundingMode.HALF_UP).unscaledValue().toByteArray(); return (Statistics<C>) Statistics.getBuilderForReading(statistics.type()) .withMin(minBytes) .withMax(maxBytes) .withNumNulls(statistics.getNumNulls()) .build(); }
public static Statistics toParquetStatistics( org.apache.parquet.column.statistics.Statistics stats) { Statistics formatStats = new Statistics(); // Don't write stats larger than the max size rather than truncating. The // rationale is that some engines may use the minimum value in the page as // the true minimum for aggregations and there is no way to mark that a // value has been truncated and is a lower bound and not in the page. if (!stats.isEmpty() && stats.isSmallerThan(MAX_STATS_SIZE)) { formatStats.setNull_count(stats.getNumNulls()); if (stats.hasNonNullValue()) { byte[] min = stats.getMinBytes(); byte[] max = stats.getMaxBytes(); // Fill the former min-max statistics only if the comparison logic is // signed so the logic of V1 and V2 stats are the same (which is // trivially true for equal min-max values) if (sortOrder(stats.type()) == SortOrder.SIGNED || Arrays.equals(min, max)) { formatStats.setMin(min); formatStats.setMax(max); } if (isMinMaxStatsSupported(stats.type()) || Arrays.equals(min, max)) { formatStats.setMin_value(min); formatStats.setMax_value(max); } } } return formatStats; }
public static Statistics toParquetStatistics( org.apache.parquet.column.statistics.Statistics stats) { Statistics formatStats = new Statistics(); // Don't write stats larger than the max size rather than truncating. The // rationale is that some engines may use the minimum value in the page as // the true minimum for aggregations and there is no way to mark that a // value has been truncated and is a lower bound and not in the page. if (!stats.isEmpty() && stats.isSmallerThan(MAX_STATS_SIZE)) { formatStats.setNull_count(stats.getNumNulls()); if (stats.hasNonNullValue()) { byte[] min = stats.getMinBytes(); byte[] max = stats.getMaxBytes(); // Fill the former min-max statistics only if the comparison logic is // signed so the logic of V1 and V2 stats are the same (which is // trivially true for equal min-max values) if (sortOrder(stats.type()) == SortOrder.SIGNED || Arrays.equals(min, max)) { formatStats.setMin(min); formatStats.setMax(max); } if (isMinMaxStatsSupported(stats.type()) || Arrays.equals(min, max)) { formatStats.setMin_value(min); formatStats.setMax_value(max); } } } return formatStats; }