final Number[] values = new Number[metricIds.length]; for (final MetricValue metric : op.getMetricList()) { int metricId = metric.getMetricId(); if (toSkip) { if (metric.hasLongValue()) { values[metricId] = metric.getLongValue(); } else if (metric.hasDoubleValue()) { values[metricId] = metric.getDoubleValue(); Optional<Integer> columnIndex = Optional.ofNullable(metricIdToMetricTableColumnIndex.get(metric.getMetricId())); columnIndex.ifPresent(index -> { if (metric.hasLongValue()) { values[index] = metric.getLongValue(); } else if (metric.hasDoubleValue()) { values[index] = metric.getDoubleValue();
/** * <code>repeated .exec.shared.MetricValue metric = 8;</code> */ public com.dremio.exec.proto.UserBitShared.MetricValue.Builder addMetricBuilder( int index) { return getMetricFieldBuilder().addBuilder( index, com.dremio.exec.proto.UserBitShared.MetricValue.getDefaultInstance()); } /**
public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeInt32(1, metricId_); } if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeInt64(2, longValue_); } if (((bitField0_ & 0x00000004) == 0x00000004)) { output.writeDouble(3, doubleValue_); } getUnknownFields().writeTo(output); }
break; case 8: builder.addMetric(input.mergeObject(com.dremio.exec.proto.UserBitShared.MetricValue.newBuilder(), com.dremio.exec.proto.SchemaUserBitShared.MetricValue.MERGE));
@Test public void testGetMetricsTableHandlesNotRegisteredMetrics() { OperatorProfile op = OperatorProfile .newBuilder().addMetric( UserBitShared.MetricValue.newBuilder() .setMetricId(1) .setDoubleValue(200)) .addMetric( UserBitShared.MetricValue.newBuilder() .setMetricId(3) .setDoubleValue(21)) .setOperatorId(UserBitShared.CoreOperatorType.PARQUET_ROW_GROUP_SCAN.getNumber()) .build(); ImmutablePair<OperatorProfile, Integer> pair = new ImmutablePair<>(op, 1); OperatorWrapper ow = new OperatorWrapper(1, ImmutableList.of(pair), OperatorMetricRegistry.getCoreOperatorTypeMetricsMap()); String html = ow.getMetricsTable(); Pattern columnPattern = Pattern.compile("<td>.*?</td>"); Matcher matcher = columnPattern.matcher(html); int count = 0; while (matcher.find()){ count++; } // Unregistered metrics should not appear on profiles screen assertEquals(2, count); }
public com.dremio.exec.proto.UserBitShared.MetricValue buildPartial() { com.dremio.exec.proto.UserBitShared.MetricValue result = new com.dremio.exec.proto.UserBitShared.MetricValue(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.metricId_ = metricId_; if (((from_bitField0_ & 0x00000002) == 0x00000002)) { to_bitField0_ |= 0x00000002; } result.longValue_ = longValue_; if (((from_bitField0_ & 0x00000004) == 0x00000004)) { to_bitField0_ |= 0x00000004; } result.doubleValue_ = doubleValue_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
public Builder toBuilder() { return newBuilder(this); }
private boolean renderingOldProfiles(OperatorProfile op) { final List<MetricValue> metricValues = op.getMetricList(); for (MetricValue metric : metricValues) { final int metricId = metric.getMetricId(); if (metricId == HashAggStats.SKIP_METRIC_START) { /* if the ordinal (metric id) to skip is indeed present * in the serialized profile that we are trying to render * then we are definitely working with new profiles */ return false; } } return true; } }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(com.dremio.exec.proto.UserBitShared.MetricValue prototype) {
public com.dremio.exec.proto.UserBitShared.MetricValue getDefaultInstanceForType() { return com.dremio.exec.proto.UserBitShared.MetricValue.getDefaultInstance(); }
@Override public void apply(int key, double value) { builder.addMetric(MetricValue.newBuilder().setMetricId(key).setDoubleValue(value)); }
@Override public void apply(int key, long value) { builder.addMetric(MetricValue.newBuilder().setMetricId(key).setLongValue(value)); }
public static Builder newBuilder(com.dremio.exec.proto.UserBitShared.MetricValue prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
/** * <code>repeated .exec.shared.MetricValue metric = 8;</code> */ public com.dremio.exec.proto.UserBitShared.MetricValue.Builder addMetricBuilder() { return getMetricFieldBuilder().addBuilder( com.dremio.exec.proto.UserBitShared.MetricValue.getDefaultInstance()); } /**
public Builder mergeFrom(com.dremio.exec.proto.UserBitShared.MetricValue other) { if (other == com.dremio.exec.proto.UserBitShared.MetricValue.getDefaultInstance()) return this; if (other.hasMetricId()) { setMetricId(other.getMetricId()); } if (other.hasLongValue()) { setLongValue(other.getLongValue()); } if (other.hasDoubleValue()) { setDoubleValue(other.getDoubleValue()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
private boolean isArrowWriterOutputLimited(OperatorProfile operatorProfile) { for (int i = 0; i < operatorProfile.getMetricCount(); i++) { UserBitShared.MetricValue metricValue = operatorProfile.getMetric(i); if (metricValue.getMetricId() == WriterOperator.Metric.OUTPUT_LIMITED.ordinal()) { return metricValue.getLongValue() > 0; } } return false; }
public void writeTo(io.protostuff.Output output, com.dremio.exec.proto.UserBitShared.MetricValue message) throws java.io.IOException { if(message.hasMetricId()) output.writeInt32(1, message.getMetricId(), false); if(message.hasLongValue()) output.writeInt64(2, message.getLongValue(), false); if(message.hasDoubleValue()) output.writeDouble(3, message.getDoubleValue(), false); } public boolean isInitialized(com.dremio.exec.proto.UserBitShared.MetricValue message)
private static long findMetric(OperatorProfile operatorProfile, final int id) { return FluentIterable.from(operatorProfile.getMetricList()).firstMatch(new Predicate<MetricValue>() { @Override public boolean apply(@Nullable MetricValue input) { return input.getMetricId() == id; } }).get().getLongValue(); }
private void setSortSpillInfo(CoreOperatorType operatorType, OperatorProfile operatorProfile) { initSpillJobDetails(); final int operatorNumber = operatorType.getNumber(); Preconditions.checkState(operatorNumber == CoreOperatorType.EXTERNAL_SORT_VALUE); final List<UserBitShared.MetricValue> metricValues = operatorProfile.getMetricList(); for (UserBitShared.MetricValue metricValue : metricValues) { final int metricId = metricValue.getMetricId(); if (metricId == ExternalSortOperator.Metric.TOTAL_SPILLED_DATA_SIZE.ordinal() && metricValue.hasLongValue()) { spillJobDetails.setTotalBytesSpilledBySort(spillJobDetails.getTotalBytesSpilledBySort() + metricValue.getLongValue()); } } }
private void setAggSpillInfo(CoreOperatorType operatorType, OperatorProfile operatorProfile) { initSpillJobDetails(); final int operatorNumber = operatorType.getNumber(); Preconditions.checkState(operatorNumber == CoreOperatorType.HASH_AGGREGATE_VALUE); final List<UserBitShared.MetricValue> metricValues = operatorProfile.getMetricList(); for (UserBitShared.MetricValue metricValue : metricValues) { final int metricId = metricValue.getMetricId(); if (metricId == HashAggStats.Metric.TOTAL_SPILLED_DATA_SIZE.ordinal() && metricValue.hasLongValue()) { spillJobDetails.setTotalBytesSpilledByHashAgg(spillJobDetails.getTotalBytesSpilledByHashAgg() + metricValue.getLongValue()); } } }