Example #1
0
    @Override
    public void readFrom(InputStream stream, ORecordVersion version) throws IOException {
      final ODistributedVersion distributedVersion = (ODistributedVersion) version;

      distributedVersion.counter = OBinaryProtocol.bytes2int(stream);
      distributedVersion.timestamp = OBinaryProtocol.bytes2long(stream);
      distributedVersion.macAddress = OBinaryProtocol.bytes2long(stream);
    }
Example #2
0
    @Override
    public void readFrom(DataInput in, ORecordVersion version) throws IOException {
      final ODistributedVersion distributedVersion = (ODistributedVersion) version;

      distributedVersion.counter = in.readInt();
      distributedVersion.timestamp = in.readLong();
      distributedVersion.macAddress = in.readLong();
    }
Example #3
0
 @Override
 public ORecordVersion copy() {
   ODistributedVersion copy = new ODistributedVersion();
   copy.counter = counter;
   copy.timestamp = timestamp;
   copy.macAddress = macAddress;
   return copy;
 }
Example #4
0
 public void writeVersion(final ORecordVersion version) throws IOException {
   if (version instanceof ODistributedVersion) {
     final ODistributedVersion v = (ODistributedVersion) version;
     writeInt(v.getCounter());
     writeLong(v.getTimestamp());
     writeLong(v.getMacAddress());
   } else {
     // Usual serialization
     writeInt(version.getCounter());
   }
 }
Example #5
0
    @Override
    public void fromString(String string, ORecordVersion version) {
      final ODistributedVersion distributedVersion = (ODistributedVersion) version;

      String[] parts = string.split("\\.");
      if (parts.length != 3)
        throw new IllegalArgumentException(
            "Not correct format of distributed version. Expected <recordVersion>.<timestamp>.<macAddress>");

      distributedVersion.counter = Integer.valueOf(parts[0]);
      distributedVersion.timestamp = Long.valueOf(parts[1]);
      distributedVersion.macAddress = Long.valueOf(parts[2]);
    }
Example #6
0
    @Override
    public int fastReadFrom(byte[] iStream, int pos, ORecordVersion version) {
      final ODistributedVersion distributedVersion = (ODistributedVersion) version;

      int len = 0;
      distributedVersion.counter = CONVERTER.getInt(iStream, pos + len);
      len += OBinaryProtocol.SIZE_INT;
      distributedVersion.timestamp = CONVERTER.getLong(iStream, pos + len);
      len += OBinaryProtocol.SIZE_LONG;
      distributedVersion.macAddress = CONVERTER.getLong(iStream, pos + len);
      len += OBinaryProtocol.SIZE_LONG;
      return len;
    }
Example #7
0
    @Override
    public long readFrom(OFile file, long pos, ORecordVersion version) throws IOException {
      final ODistributedVersion distributedVersion = (ODistributedVersion) version;

      int len = 0;
      distributedVersion.counter = file.readInt(pos + len);
      len += OBinaryProtocol.SIZE_INT;
      distributedVersion.timestamp = file.readLong(pos + len);
      len += OBinaryProtocol.SIZE_LONG;
      distributedVersion.macAddress = file.readLong(pos + len);
      len += OBinaryProtocol.SIZE_LONG;
      return len;
    }