Tabnine Logo
TimelineCursor.getNextTime
Code IndexAdd Tabnine to your IDE (free)

How to use
getNextTime
method
in
com.ning.billing.meter.timeline.times.TimelineCursor

Best Java code snippets using com.ning.billing.meter.timeline.times.TimelineCursor.getNextTime (Showing top 3 results out of 315)

origin: com.ning.billing/killbill-meter

/**
 * Process sampleCount sequential samples with identical values.  sampleCount will usually be 1,
 * but may be larger than 1.  Implementors may just loop processing identical values, but some
 * implementations may optimize adding a bunch of repeated values
 *
 * @param timeCursor  a TimeCursor instance, which supplies successive int UNIX times
 * @param sampleCount the count of sequential, identical values
 * @param opcode      the opcode of the sample value, which may not be a REPEAT opcode
 * @param value       the value of this kind of sample over the sampleCount samples
 */
@Override
public void processSamples(final TimelineCursor timeCursor, final int sampleCount, final SampleOpcode opcode, final Object value) {
  for (int i = 0; i < sampleCount; i++) {
    // Check if the sample is in the right time range
    final DateTime sampleTime = timeCursor.getNextTime();
    if ((startTime == null || !sampleTime.isBefore(startTime)) && ((endTime == null || !sampleTime.isAfter(endTime)))) {
      processOneSample(sampleTime, opcode, value);
    }
  }
}
origin: com.ning.billing/killbill-meter

@Override
public void processSamples(final TimelineCursor timeCursor, final int sampleCount, final SampleOpcode opcode, final Object value) {
  if (builder.length() > 0) {
    builder.append(", ");
  }
  final DateTime timestamp = timeCursor.getNextTime();
  builder.append("at ").append(timestamp.toString("yyyy-MM-dd HH:mm:ss")).append(" ");
  if (sampleCount > 1) {
    builder.append(sampleCount).append(" of ");
  }
  builder.append(opcode.name().toLowerCase());
  switch (opcode) {
    case NULL:
    case DOUBLE_ZERO:
    case INT_ZERO:
      break;
    default:
      builder.append("(").append(String.valueOf(value)).append(")");
      break;
  }
}
origin: com.ning.billing/killbill-meter

@Test(groups = "fast")
public void testTimeRangeSampleProcessor() throws Exception {
  final DateTime startTime = new DateTime(dateFormatter.parseDateTime("2012-03-23T17:35:11.000Z"));
  final DateTime endTime = new DateTime(dateFormatter.parseDateTime("2012-03-23T17:35:17.000Z"));
  final int sampleCount = 2;
  final List<DateTime> dateTimes = ImmutableList.<DateTime>of(startTime, endTime);
  final byte[] compressedTimes = timelineCoder.compressDateTimes(dateTimes);
  final TimelineCursor cursor = new DefaultTimelineCursor(compressedTimes, sampleCount);
  Assert.assertEquals(cursor.getNextTime(), startTime);
  Assert.assertEquals(cursor.getNextTime(), endTime);
  // 2 x the value 12: REPEAT_BYTE, SHORT, 2, SHORT, 12 (2 bytes)
  final byte[] samples = new byte[]{(byte) 0xff, 2, 2, 0, 12};
  final AtomicInteger samplesCount = new AtomicInteger(0);
  sampleCoder.scan(samples, compressedTimes, sampleCount, new TimeRangeSampleProcessor(startTime, endTime) {
    @Override
    public void processOneSample(final DateTime time, final SampleOpcode opcode, final Object value) {
      if (samplesCount.get() == 0) {
        Assert.assertEquals(DateTimeUtils.unixSeconds(time), DateTimeUtils.unixSeconds(startTime));
      } else {
        Assert.assertEquals(DateTimeUtils.unixSeconds(time), DateTimeUtils.unixSeconds(endTime));
      }
      samplesCount.incrementAndGet();
    }
  });
  Assert.assertEquals(samplesCount.get(), sampleCount);
}
com.ning.billing.meter.timeline.timesTimelineCursorgetNextTime

Javadoc

Return the DateTime for the next sample

Popular methods of TimelineCursor

  • skipToSampleNumber
    Skip to the given sample number within the timeline, where 0 is the first sample number

Popular in Java

  • Reactive rest calls using spring rest template
  • setScale (BigDecimal)
  • findViewById (Activity)
  • requestLocationUpdates (LocationManager)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now