ctubbsii commented on a change in pull request #2224:
URL: https://github.com/apache/accumulo/pull/2224#discussion_r683947077



##########
File path: 
server/base/src/main/java/org/apache/accumulo/server/conf/codec/GzipPropEncoding.java
##########
@@ -0,0 +1,237 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.server.conf.codec;
+
+import static 
org.apache.accumulo.server.conf.codec.VersionedProperties.tsFormatter;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UncheckedIOException;
+import java.time.Instant;
+import java.util.AbstractMap;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * Initial property encoding that (optionally) uses gzip to compress the 
property map. The encoding
+ * version supported is EncodingVersion.V1_0.
+ */
+public class GzipPropEncoding implements PropSerdes {
+
+  private final EncodingOptions encodingOpts;
+
+  public GzipPropEncoding(final EncodingOptions encodingOpts) {
+    this.encodingOpts = encodingOpts;
+  }
+
+  /**
+   * Serialize the versioned properties. The version information on the 
properties is updated if the
+   * data is successfully serialized.
+   *
+   * @param vProps
+   *          the versioned properties.
+   * @return a byte array with the serialized properties.
+   */
+  @Override
+  public byte[] toBytes(final VersionedProperties vProps) {
+
+    try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        DataOutputStream dos = new DataOutputStream(bos)) {
+
+      // write header - version id, isCompressed
+      encodingOpts.encode(dos);
+
+      // write updated property versioning info (data version, time stamp)
+      dos.writeInt(vProps.getNextVersion());
+      dos.writeUTF(vProps.getTimestampISO());

Review comment:
       I don't see clock time as useful for versioning or for resolving 
conflicts between concurrent updates, since clock times aren't that precise, 
aren't unique at any level of precision, and don't necessarily have meaning 
across different servers with different clocks. The only value I see is the 
human being able to read it and see what time it was on the server that stored 
it... but that's of limited value. I don't think that's needed. We don't do 
that any other place (we don't store clock time in RFile metadata, or in other 
ZK nodes, for example). System logs and/or ZK metadata should suffice for that 
kind of thing anyway.
   
   I guess if you're finding that it is still handy, and avoids getting extra 
info from ZK, I'd have to try to understand how you're utilizing it at the next 
layer up.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to