@Override public void onBindViewHolder(CustomAdapter.ViewHolder holder, int position) { Sample sample = mySamples.get(position); holder.name.setText(sample.getName()); LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context .LAYOUT_INFLATER_SERVICE); for (int i = 0; i < 20; i++) { View v = inflater.inflate(R.layout.item_list, holder.linearLayout, false); TextView textView = (TextView) v.findViewById(R.id.textView); textView.setText("hello" + i); holder.linearLayout.addView(v); } }
private void addSample(Results.Row<Sample> row, Sample sample) { if (m_metrics.isEmpty() || m_metrics.contains(sample.getName())) { row.addElement(sample); } }
Sample sample = new Sample(); /*call the setter from Sample class and pass value to its parameter*/ sample.setName("Andrew"); /* access the name "Andrew" by calling getter */ System.out.println("Welcome " + sample.getName()); }
@Override public String toString() { return String.format( "%s[timestamp=%s, context=%s, resource=%s, name=%s, type=%s, value=%s]", getClass().getSimpleName(), getTimestamp(), getContext(), getResource(), getName(), getType(), getValue()); }
@Override public Row<Sample> next() { if (!hasNext()) throw new NoSuchElementException(); Row<Sample> working = m_input.next(); Row<Sample> result = new Row<>(working.getTimestamp(), working.getResource()); for (String metricName : m_metrics) { Sample sample = working.getElement(metricName); if (sample == null) { continue; } // Use rate as result if one of counter types, else pass through as-is. result.addElement(COUNTERS.contains(sample.getType()) ? getRate(sample) : sample); m_prevSamples.put(sample.getName(), sample); } return result; }
maybeIndexResource(cacheQueue, generators, sample.getContext(), sample.getResource()); maybeIndexResourceAttributes(cacheQueue, generators, sample.getContext(), sample.getResource()); maybeAddMetricName(cacheQueue, generators, sample.getContext(), sample.getResource(), sample.getName());
maybeIndexResource(cacheQueue, generators, sample.getContext(), sample.getResource()); maybeIndexResourceAttributes(cacheQueue, generators, sample.getContext(), sample.getResource()); maybeAddMetricName(cacheQueue, generators, sample.getContext(), sample.getResource(), sample.getName());
@Override public Sample call(Sample s) { Timestamp oldTs = s.getTimestamp(); Timestamp newTs = Timestamp.fromEpochMillis(m_timeoffset + Math.round(oldTs.asMillis()/m_timescaleFactor)); return new Sample(newTs, s.getResource(), s.getName(), s.getType(), s.getValue()); }
private Sample getRate(Sample sample) { ValueType<?> value = NAN; Sample previous = m_prevSamples.get(sample.getName()); if (previous != null) { long elapsed = sample.getTimestamp().asSeconds() - previous.getTimestamp().asSeconds(); try { value = new Gauge(sample.getValue().delta(previous.getValue()).doubleValue() / elapsed); } catch (ArithmeticException e) { value = NAN; } } return new Sample(sample.getTimestamp(), sample.getResource(), sample.getName(), GAUGE, value, sample.getAttributes()); }
.value(SchemaConstants.F_RESOURCE, m.getResource().getId()) .value(SchemaConstants.F_COLLECTED, m.getTimestamp().asMillis()) .value(SchemaConstants.F_METRIC_NAME, m.getName()) .value(SchemaConstants.F_VALUE, ValueType.decompose(m.getValue()));
@Override public String call(List<Sample> samples) { JSONBuilder bldr = new JSONBuilder(); for(Sample sample : samples) { if (isNaN(sample)) continue; //System.err.println("Importing: " + sample); bldr.newObject(); bldr.attr("timestamp", sample.getTimestamp().asMillis()); bldr.attr("resource", sample.getResource().getId()); bldr.attr("name", sample.getName()); bldr.attr("type", sample.getType().name()); if (sample.getType() == MetricType.GAUGE) { bldr.attr("value", sample.getValue().doubleValue()); } else { bldr.attr("value", sample.getValue().longValue()); } } return bldr.toString(); } };