Tabnine Logo
TimelineOpcode
Code IndexAdd Tabnine to your IDE (free)

How to use
TimelineOpcode
in
com.ning.billing.meter.timeline.times

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

origin: com.ning.billing/killbill-meter

private void writeRepeatedDelta(final int delta, final int repeatCount, final DataOutputStream dataStream) throws IOException {
  if (repeatCount > 1) {
    if (repeatCount > MAX_BYTE_REPEAT_COUNT) {
      dataStream.writeByte(TimelineOpcode.REPEATED_DELTA_TIME_SHORT.getOpcodeIndex());
      dataStream.writeShort(repeatCount);
    } else if (repeatCount == 2) {
      dataStream.writeByte(delta);
    } else {
      dataStream.writeByte(TimelineOpcode.REPEATED_DELTA_TIME_BYTE.getOpcodeIndex());
      dataStream.writeByte(repeatCount);
    }
  }
  dataStream.writeByte(delta);
}
origin: com.ning.billing/killbill-meter

  @Test(groups = "fast")
  public void testMaxDeltaTime() throws Exception {
    for (final TimelineOpcode opcode : TimelineOpcode.values()) {
      Assert.assertTrue(opcode.getOpcodeIndex() >= TimelineOpcode.MAX_DELTA_TIME);
    }
  }
}
origin: com.ning.billing/killbill-meter

  private void writeTime(final int lastTime, final int newTime, final DataOutputStream dataStream) throws IOException {
    if (newTime > lastTime) {
      final int delta = (newTime - lastTime);
      if (delta <= TimelineOpcode.MAX_DELTA_TIME) {
        dataStream.writeByte(delta);
      } else {
        dataStream.writeByte(TimelineOpcode.FULL_TIME.getOpcodeIndex());
        dataStream.writeInt(newTime);
      }
    } else if (newTime == lastTime) {
      dataStream.writeByte(0);
    }
  }
}
origin: com.ning.billing/killbill-meter

  return nextOpcode;
if (nextOpcode == TimelineOpcode.FULL_TIME.getOpcodeIndex()) {
  lastValue = timelineDataStream.readInt();
  byteCursor += 4;
} else if (nextOpcode == TimelineOpcode.REPEATED_DELTA_TIME_BYTE.getOpcodeIndex()) {
  repeatCount = timelineDataStream.readUnsignedByte() - 1;
  delta = timelineDataStream.read();
  byteCursor += 2;
  lastValue += delta;
} else if (nextOpcode == TimelineOpcode.REPEATED_DELTA_TIME_SHORT.getOpcodeIndex()) {
  repeatCount = timelineDataStream.readUnsignedShort() - 1;
  delta = timelineDataStream.read();
origin: com.ning.billing/killbill-meter

int opcode;
while ((opcode = byteDataStream.read()) != -1) {
  if (opcode == TimelineOpcode.FULL_TIME.getOpcodeIndex()) {
    byteDataStream.readInt();
    count++;
  } else if (opcode <= TimelineOpcode.MAX_DELTA_TIME) {
    count++;
  } else if (opcode == TimelineOpcode.REPEATED_DELTA_TIME_BYTE.getOpcodeIndex()) {
    count += byteDataStream.read();
  } else if (opcode == TimelineOpcode.REPEATED_DELTA_TIME_SHORT.getOpcodeIndex()) {
    count += byteDataStream.readUnsignedShort();
origin: com.ning.billing/killbill-meter

if (nextOpcode == TimelineOpcode.FULL_TIME.getOpcodeIndex()) {
  lastValue = timelineDataStream.readInt();
  byteCursor += 4;
  sampleNumber++;
} else if (nextOpcode == TimelineOpcode.REPEATED_DELTA_TIME_BYTE.getOpcodeIndex()) {
  repeatCount = timelineDataStream.readUnsignedByte() - 1;
  delta = timelineDataStream.read();
  lastValue += delta;
  sampleNumber++;
} else if (nextOpcode == TimelineOpcode.REPEATED_DELTA_TIME_SHORT.getOpcodeIndex()) {
  repeatCount = timelineDataStream.readUnsignedShort() - 1;
  delta = timelineDataStream.read();
origin: com.ning.billing/killbill-meter

if (opcode == TimelineOpcode.FULL_TIME.getOpcodeIndex()) {
  lastTime = byteDataStream.readInt();
  dateTimeList.add(DateTimeUtils.dateTimeFromUnixSeconds(lastTime));
} else if (opcode == TimelineOpcode.REPEATED_DELTA_TIME_BYTE.getOpcodeIndex()) {
  final int repeatCount = byteDataStream.readUnsignedByte();
  final int delta = byteDataStream.readUnsignedByte();
    dateTimeList.add(DateTimeUtils.dateTimeFromUnixSeconds(lastTime));
} else if (opcode == TimelineOpcode.REPEATED_DELTA_TIME_SHORT.getOpcodeIndex()) {
  final int repeatCount = byteDataStream.readUnsignedShort();
  final int delta = byteDataStream.readUnsignedByte();
origin: com.ning.billing/killbill-meter

boolean useNewDelta = false;
boolean nonDeltaTime = false;
if (opcode == TimelineOpcode.FULL_TIME.getOpcodeIndex()) {
  newTime = byteDataStream.readInt();
  if (newTime < lastTime) {
  useNewDelta = true;
  newCount = 1;
} else if (opcode == TimelineOpcode.REPEATED_DELTA_TIME_BYTE.getOpcodeIndex()) {
  newCount = byteDataStream.read();
  newDelta = byteDataStream.read();
                           opcode, byteCursor, chunkCounter, new String(Hex.encodeHex(times))));
} else if (opcode == TimelineOpcode.REPEATED_DELTA_TIME_SHORT.getOpcodeIndex()) {
  newCount = byteDataStream.readUnsignedShort();
  newDelta = byteDataStream.read();
origin: com.ning.billing/killbill-meter

final byte[] compressedTimes2 = timelineCoder.compressDateTimes(unencodedTimes2);
Assert.assertEquals(compressedTimes1.length, 8);
Assert.assertEquals(compressedTimes1[0] & 0xff, TimelineOpcode.FULL_TIME.getOpcodeIndex());
Assert.assertEquals(compressedTimes1[5] & 0xff, TimelineOpcode.REPEATED_DELTA_TIME_BYTE.getOpcodeIndex());
Assert.assertEquals(compressedTimes1[6] & 0xff, sampleCount - 1);
Assert.assertEquals(compressedTimes1[7] & 0xff, 100);
Assert.assertEquals(compressedTimes2.length, 8);
Assert.assertEquals(compressedTimes2[0] & 0xff, TimelineOpcode.FULL_TIME.getOpcodeIndex());
Assert.assertEquals(compressedTimes2[5] & 0xff, TimelineOpcode.REPEATED_DELTA_TIME_BYTE.getOpcodeIndex());
Assert.assertEquals(compressedTimes2[6] & 0xff, sampleCount - 1);
Assert.assertEquals(compressedTimes2[7] & 0xff, 100);
final byte[] combinedTimes = timelineCoder.combineTimelines(timesList, null);
Assert.assertEquals(combinedTimes.length, 9);
Assert.assertEquals(combinedTimes[0] & 0xff, TimelineOpcode.FULL_TIME.getOpcodeIndex());
Assert.assertEquals(combinedTimes[5] & 0xff, TimelineOpcode.REPEATED_DELTA_TIME_SHORT.getOpcodeIndex());
Assert.assertEquals(combinedTimes[6] & 0xff, 1);
Assert.assertEquals(combinedTimes[7] & 0xff, sampleCount * 2 - 1 - 256);
origin: com.ning.billing/killbill-meter

final byte[] compressedTimes2 = timelineCoder.compressDateTimes(unencodedTimes2);
Assert.assertEquals(compressedTimes1.length, 8);
Assert.assertEquals(compressedTimes1[0] & 0xff, TimelineOpcode.FULL_TIME.getOpcodeIndex());
Assert.assertEquals(compressedTimes1[5] & 0xff, TimelineOpcode.REPEATED_DELTA_TIME_BYTE.getOpcodeIndex());
Assert.assertEquals(compressedTimes1[6] & 0xff, 9);
Assert.assertEquals(compressedTimes1[7] & 0xff, 100);
Assert.assertEquals(compressedTimes2.length, 8);
Assert.assertEquals(compressedTimes2[0] & 0xff, TimelineOpcode.FULL_TIME.getOpcodeIndex());
Assert.assertEquals(compressedTimes2[5] & 0xff, TimelineOpcode.REPEATED_DELTA_TIME_BYTE.getOpcodeIndex());
Assert.assertEquals(compressedTimes2[6] & 0xff, 9);
Assert.assertEquals(compressedTimes2[7] & 0xff, 100);
final byte[] combinedTimes = timelineCoder.combineTimelines(timesList, null);
Assert.assertEquals(combinedTimes.length, 8);
Assert.assertEquals(combinedTimes[0] & 0xff, TimelineOpcode.FULL_TIME.getOpcodeIndex());
Assert.assertEquals(combinedTimes[5] & 0xff, TimelineOpcode.REPEATED_DELTA_TIME_BYTE.getOpcodeIndex());
Assert.assertEquals(combinedTimes[6] & 0xff, 19);
Assert.assertEquals(combinedTimes[7] & 0xff, 100);
com.ning.billing.meter.timeline.timesTimelineOpcode

Javadoc

Opcodes are 1-byte entities. Any "opcode" whose value is 240 or less is treated as a time delta to be added to the previous time value.

Most used methods

  • getOpcodeIndex
  • values

Popular in Java

  • Parsing JSON documents to java classes using gson
  • addToBackStack (FragmentTransaction)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • startActivity (Activity)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Best plugins for Eclipse
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