accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1396774 - in /accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data: ./ ServerColumnUpdate.java ServerMutation.java
Date Wed, 10 Oct 2012 20:31:08 GMT
Author: ecn
Date: Wed Oct 10 20:31:08 2012
New Revision: 1396774

URL: http://svn.apache.org/viewvc?rev=1396774&view=rev
Log:
ACCUMULO-786: squeeze bytes out of the serialized form of Mutation

Added:
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/ServerColumnUpdate.java
  (with props)
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/ServerMutation.java
  (with props)

Added: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/ServerColumnUpdate.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/ServerColumnUpdate.java?rev=1396774&view=auto
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/ServerColumnUpdate.java
(added)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/ServerColumnUpdate.java
Wed Oct 10 20:31:08 2012
@@ -0,0 +1,20 @@
+package org.apache.accumulo.server.data;
+
+import org.apache.accumulo.core.data.ColumnUpdate;
+
+public class ServerColumnUpdate extends ColumnUpdate {
+  
+  ServerMutation parent;
+
+  public ServerColumnUpdate(ColumnUpdate update, ServerMutation serverMutation) {
+    super(update.getColumnFamily(), update.getColumnQualifier(), update.getColumnVisibility(),
update.hasTimestamp(), update.hasTimestamp() ? update.getTimestamp() : 0, update.isDeleted(),
update.getValue());
+    parent = serverMutation;
+  }
+
+  public long getTimestamp() {
+    if (hasTimestamp())
+      return super.getTimestamp();
+    return parent.getSystemTimestamp();
+  }
+
+}

Propchange: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/ServerColumnUpdate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/ServerMutation.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/ServerMutation.java?rev=1396774&view=auto
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/ServerMutation.java
(added)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/ServerMutation.java
Wed Oct 10 20:31:08 2012
@@ -0,0 +1,78 @@
+package org.apache.accumulo.server.data;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.accumulo.core.data.ColumnUpdate;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.thrift.TMutation;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.WritableUtils;
+import static org.apache.accumulo.core.data.Mutation.SERIALIZED_FORMAT.VERSION2;;
+
+/**
+ * Mutation that holds system time as computed by the tablet server when not provided by
the user.
+ */
+public class ServerMutation extends Mutation {
+  private long systemTime = 0l;
+  
+  public ServerMutation(TMutation tmutation) {
+    super(tmutation);
+  }
+
+  public ServerMutation(Text key) {
+    super(key);
+  }
+
+  public ServerMutation() {
+  }
+
+  @Override
+  public void readFields(DataInput in) throws IOException {
+    super.readFields(in);
+    // new format writes system time with the mutation
+    if (getSerializedFormat() == VERSION2)
+      systemTime = WritableUtils.readVLong(in);
+    else {
+      // old format stored it in the timestamp of each mutation
+      for (ColumnUpdate upd : getUpdates()) {
+        if (!upd.hasTimestamp()) {
+          systemTime = upd.getTimestamp();
+          break;
+        }
+      }
+    }
+  }
+  
+  @Override
+  public void write(DataOutput out) throws IOException {
+    super.write(out);
+    WritableUtils.writeVLong(out, systemTime);
+  }
+
+  public void setSystemTimestamp(long v) {
+    this.systemTime = v;
+  }
+  
+  public long getSystemTimestamp() {
+    return this.systemTime;
+  }
+  
+  public List<ColumnUpdate> getUpdates() {
+    List<ColumnUpdate> updates = super.getUpdates();
+    List<ColumnUpdate> result = new ArrayList<ColumnUpdate>(updates.size());
+    for (ColumnUpdate update : updates) {
+      result.add(new ServerColumnUpdate(update, this));
+    }
+    return result;
+  }
+
+  @Override
+  public long estimatedMemoryUsed() {
+    return super.estimatedMemoryUsed() + 8;
+  }
+
+}

Propchange: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/data/ServerMutation.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message