Пример #1
0
  /**
   * Used to create copies of objects
   *
   * @return a copy of the internal TimestampWritable byte[]
   */
  public byte[] getBytes() {
    checkBytes();

    int len = getTotalLength();
    byte[] b = new byte[len];

    System.arraycopy(currentBytes, offset, b, 0, len);
    return b;
  }
Пример #2
0
 public int compareTo(TimestampWritable t) {
   checkBytes();
   long s1 = this.getSeconds();
   long s2 = t.getSeconds();
   if (s1 == s2) {
     int n1 = this.getNanos();
     int n2 = t.getNanos();
     if (n1 == n2) {
       return 0;
     }
     return n1 - n2;
   } else {
     return s1 < s2 ? -1 : 1;
   }
 }
Пример #3
0
 public void write(OutputStream out) throws IOException {
   checkBytes();
   out.write(currentBytes, offset, getTotalLength());
 }
Пример #4
0
 /**
  * @return length of serialized TimestampWritable data. As a side effect, populates the internal
  *     byte array if empty.
  */
 int getTotalLength() {
   checkBytes();
   return getTotalLength(currentBytes, offset);
 }
Пример #5
0
 public void writeToByteStream(Output byteStream) {
   checkBytes();
   byteStream.write(currentBytes, offset, getTotalLength());
 }