Exemplo n.º 1
0
  /**
   * Commit an applied delta to this wavelet container.
   *
   * @param appliedDelta to commit
   * @param transformedDelta of the applied delta
   * @return result of the application
   */
  protected DeltaApplicationResult commitAppliedDelta(
      ByteStringMessage<ProtocolAppliedWaveletDelta> appliedDelta, WaveletDelta transformedDelta) {

    ProtocolWaveletDelta transformedProtocolDelta =
        WaveletOperationSerializer.serialize(transformedDelta, currentVersion);
    transformedDeltas.add(transformedProtocolDelta);
    deserializedTransformedDeltas.add(new VersionedWaveletDelta(transformedDelta, currentVersion));
    appliedDeltas.add(appliedDelta);

    HashedVersion newVersion =
        HASHED_HISTORY_VERSION_FACTORY.create(
            appliedDelta.getByteArray(), currentVersion, transformedDelta.getOperations().size());
    currentVersion = newVersion;

    return new DeltaApplicationResult(
        appliedDelta, transformedProtocolDelta, WaveletOperationSerializer.serialize(newVersion));
  }
Exemplo n.º 2
0
 /**
  * Return a dummy ProtocolWaveletDelta instance used as a range boundary for use in searches
  * within a NavigableSet of deltas.
  *
  * @param version the version to return the delta applied at
  * @return the generated dummy delta
  */
 private static ProtocolWaveletDelta emptyDeltaAtVersion(final long version) {
   return ProtocolWaveletDelta.newBuilder()
       .setAuthor("dummy")
       .setHashedVersion(WaveletOperationSerializer.serialize(HashedVersion.unsigned(version)))
       .build();
 }