cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r948316 [2/5] - in /cassandra/trunk: interface/ interface/thrift/gen-java/org/apache/cassandra/thrift/ src/java/org/apache/cassandra/avro/ src/java/org/apache/cassandra/cli/ src/java/org/apache/cassandra/config/ src/java/org/apache/cassandr...
Date Wed, 26 May 2010 04:45:47 GMT
Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Deletion.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Deletion.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Deletion.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Deletion.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;
@@ -26,17 +47,17 @@ import org.apache.thrift.protocol.*;
 public class Deletion implements TBase<Deletion._Fields>, java.io.Serializable, Cloneable, Comparable<Deletion> {
   private static final TStruct STRUCT_DESC = new TStruct("Deletion");
 
-  private static final TField TIMESTAMP_FIELD_DESC = new TField("timestamp", TType.I64, (short)1);
+  private static final TField CLOCK_FIELD_DESC = new TField("clock", TType.STRUCT, (short)1);
   private static final TField SUPER_COLUMN_FIELD_DESC = new TField("super_column", TType.STRING, (short)2);
   private static final TField PREDICATE_FIELD_DESC = new TField("predicate", TType.STRUCT, (short)3);
 
-  public long timestamp;
+  public Clock clock;
   public byte[] super_column;
   public SlicePredicate predicate;
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements TFieldIdEnum {
-    TIMESTAMP((short)1, "timestamp"),
+    CLOCK((short)1, "clock"),
     SUPER_COLUMN((short)2, "super_column"),
     PREDICATE((short)3, "predicate");
 
@@ -92,12 +113,10 @@ public class Deletion implements TBase<D
   }
 
   // isset id assignments
-  private static final int __TIMESTAMP_ISSET_ID = 0;
-  private BitSet __isset_bit_vector = new BitSet(1);
 
   public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
-    put(_Fields.TIMESTAMP, new FieldMetaData("timestamp", TFieldRequirementType.REQUIRED, 
-        new FieldValueMetaData(TType.I64)));
+    put(_Fields.CLOCK, new FieldMetaData("clock", TFieldRequirementType.REQUIRED, 
+        new StructMetaData(TType.STRUCT, Clock.class)));
     put(_Fields.SUPER_COLUMN, new FieldMetaData("super_column", TFieldRequirementType.OPTIONAL, 
         new FieldValueMetaData(TType.STRING)));
     put(_Fields.PREDICATE, new FieldMetaData("predicate", TFieldRequirementType.OPTIONAL, 
@@ -112,20 +131,19 @@ public class Deletion implements TBase<D
   }
 
   public Deletion(
-    long timestamp)
+    Clock clock)
   {
     this();
-    this.timestamp = timestamp;
-    setTimestampIsSet(true);
+    this.clock = clock;
   }
 
   /**
    * Performs a deep copy on <i>other</i>.
    */
   public Deletion(Deletion other) {
-    __isset_bit_vector.clear();
-    __isset_bit_vector.or(other.__isset_bit_vector);
-    this.timestamp = other.timestamp;
+    if (other.isSetClock()) {
+      this.clock = new Clock(other.clock);
+    }
     if (other.isSetSuper_column()) {
       this.super_column = new byte[other.super_column.length];
       System.arraycopy(other.super_column, 0, super_column, 0, other.super_column.length);
@@ -144,27 +162,28 @@ public class Deletion implements TBase<D
     return new Deletion(this);
   }
 
-  public long getTimestamp() {
-    return this.timestamp;
+  public Clock getClock() {
+    return this.clock;
   }
 
-  public Deletion setTimestamp(long timestamp) {
-    this.timestamp = timestamp;
-    setTimestampIsSet(true);
+  public Deletion setClock(Clock clock) {
+    this.clock = clock;
     return this;
   }
 
-  public void unsetTimestamp() {
-    __isset_bit_vector.clear(__TIMESTAMP_ISSET_ID);
+  public void unsetClock() {
+    this.clock = null;
   }
 
-  /** Returns true if field timestamp is set (has been asigned a value) and false otherwise */
-  public boolean isSetTimestamp() {
-    return __isset_bit_vector.get(__TIMESTAMP_ISSET_ID);
+  /** Returns true if field clock is set (has been asigned a value) and false otherwise */
+  public boolean isSetClock() {
+    return this.clock != null;
   }
 
-  public void setTimestampIsSet(boolean value) {
-    __isset_bit_vector.set(__TIMESTAMP_ISSET_ID, value);
+  public void setClockIsSet(boolean value) {
+    if (!value) {
+      this.clock = null;
+    }
   }
 
   public byte[] getSuper_column() {
@@ -217,11 +236,11 @@ public class Deletion implements TBase<D
 
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
-    case TIMESTAMP:
+    case CLOCK:
       if (value == null) {
-        unsetTimestamp();
+        unsetClock();
       } else {
-        setTimestamp((Long)value);
+        setClock((Clock)value);
       }
       break;
 
@@ -250,8 +269,8 @@ public class Deletion implements TBase<D
 
   public Object getFieldValue(_Fields field) {
     switch (field) {
-    case TIMESTAMP:
-      return new Long(getTimestamp());
+    case CLOCK:
+      return getClock();
 
     case SUPER_COLUMN:
       return getSuper_column();
@@ -270,8 +289,8 @@ public class Deletion implements TBase<D
   /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
   public boolean isSet(_Fields field) {
     switch (field) {
-    case TIMESTAMP:
-      return isSetTimestamp();
+    case CLOCK:
+      return isSetClock();
     case SUPER_COLUMN:
       return isSetSuper_column();
     case PREDICATE:
@@ -297,12 +316,12 @@ public class Deletion implements TBase<D
     if (that == null)
       return false;
 
-    boolean this_present_timestamp = true;
-    boolean that_present_timestamp = true;
-    if (this_present_timestamp || that_present_timestamp) {
-      if (!(this_present_timestamp && that_present_timestamp))
+    boolean this_present_clock = true && this.isSetClock();
+    boolean that_present_clock = true && that.isSetClock();
+    if (this_present_clock || that_present_clock) {
+      if (!(this_present_clock && that_present_clock))
         return false;
-      if (this.timestamp != that.timestamp)
+      if (!this.clock.equals(that.clock))
         return false;
     }
 
@@ -340,11 +359,11 @@ public class Deletion implements TBase<D
     int lastComparison = 0;
     Deletion typedOther = (Deletion)other;
 
-    lastComparison = Boolean.valueOf(isSetTimestamp()).compareTo(typedOther.isSetTimestamp());
+    lastComparison = Boolean.valueOf(isSetClock()).compareTo(typedOther.isSetClock());
     if (lastComparison != 0) {
       return lastComparison;
     }
-    if (isSetTimestamp()) {      lastComparison = TBaseHelper.compareTo(timestamp, typedOther.timestamp);
+    if (isSetClock()) {      lastComparison = TBaseHelper.compareTo(clock, typedOther.clock);
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -380,10 +399,10 @@ public class Deletion implements TBase<D
         break;
       }
       switch (field.id) {
-        case 1: // TIMESTAMP
-          if (field.type == TType.I64) {
-            this.timestamp = iprot.readI64();
-            setTimestampIsSet(true);
+        case 1: // CLOCK
+          if (field.type == TType.STRUCT) {
+            this.clock = new Clock();
+            this.clock.read(iprot);
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
@@ -411,9 +430,6 @@ public class Deletion implements TBase<D
     iprot.readStructEnd();
 
     // check for required fields of primitive type, which can't be checked in the validate method
-    if (!isSetTimestamp()) {
-      throw new TProtocolException("Required field 'timestamp' was not found in serialized data! Struct: " + toString());
-    }
     validate();
   }
 
@@ -421,9 +437,11 @@ public class Deletion implements TBase<D
     validate();
 
     oprot.writeStructBegin(STRUCT_DESC);
-    oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
-    oprot.writeI64(this.timestamp);
-    oprot.writeFieldEnd();
+    if (this.clock != null) {
+      oprot.writeFieldBegin(CLOCK_FIELD_DESC);
+      this.clock.write(oprot);
+      oprot.writeFieldEnd();
+    }
     if (this.super_column != null) {
       if (isSetSuper_column()) {
         oprot.writeFieldBegin(SUPER_COLUMN_FIELD_DESC);
@@ -447,8 +465,12 @@ public class Deletion implements TBase<D
     StringBuilder sb = new StringBuilder("Deletion(");
     boolean first = true;
 
-    sb.append("timestamp:");
-    sb.append(this.timestamp);
+    sb.append("clock:");
+    if (this.clock == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.clock);
+    }
     first = false;
     if (isSetSuper_column()) {
       if (!first) sb.append(", ");
@@ -481,7 +503,9 @@ public class Deletion implements TBase<D
 
   public void validate() throws TException {
     // check for required fields
-    // alas, we cannot check 'timestamp' because it's a primitive and you chose the non-beans generator.
+    if (clock == null) {
+      throw new TProtocolException("Required field 'clock' was not present! Struct: " + toString());
+    }
   }
 
 }

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KeyRange.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KeyRange.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KeyRange.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KeyRange.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KeySlice.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KeySlice.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KeySlice.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KeySlice.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Mutation.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Mutation.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Mutation.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Mutation.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SlicePredicate.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SlicePredicate.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SlicePredicate.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SlicePredicate.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SliceRange.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SliceRange.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SliceRange.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SliceRange.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/TimedOutException.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/TimedOutException.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/TimedOutException.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/TimedOutException.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/TokenRange.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/TokenRange.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/TokenRange.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/TokenRange.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/UnavailableException.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/UnavailableException.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/UnavailableException.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/UnavailableException.java Wed May 26 04:45:44 2010
@@ -4,6 +4,27 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  */
 package org.apache.cassandra.thrift;
+/*
+ * 
+ * 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.
+ * 
+ */
+
 
 import java.util.List;
 import java.util.ArrayList;

Modified: cassandra/trunk/src/java/org/apache/cassandra/avro/AvroRecordFactory.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/avro/AvroRecordFactory.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/avro/AvroRecordFactory.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/avro/AvroRecordFactory.java Wed May 26 04:45:44 2010
@@ -27,18 +27,25 @@ import org.apache.avro.util.Utf8;
 
 public class AvroRecordFactory
 {
-    public static Column newColumn(ByteBuffer name, ByteBuffer value, long timestamp)
+    public static Column newColumn(ByteBuffer name, ByteBuffer value, Clock clock)
     {
         Column column = new Column();
         column.name = name;
         column.value = value;
-        column.timestamp = timestamp;
+        column.clock = clock;
         return column;
     }
+
+    public static Clock newClock(long timestamp)
+    {
+        Clock clock = new Clock();
+        clock.timestamp = timestamp;
+        return clock;
+    }
     
-    public static Column newColumn(byte[] name, byte[] value, long timestamp)
+    public static Column newColumn(byte[] name, byte[] value, Clock clock)
     {
-        return newColumn(ByteBuffer.wrap(name), ByteBuffer.wrap(value), timestamp);
+        return newColumn(ByteBuffer.wrap(name), ByteBuffer.wrap(value), clock);
     }
     
     public static SuperColumn newSuperColumn(ByteBuffer name, GenericArray<Column> columns)

Modified: cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java Wed May 26 04:45:44 2010
@@ -67,6 +67,7 @@ public class CassandraServer implements 
     
     // CfDef default values
     private final static String D_CF_CFTYPE = "Standard";
+    private final static String D_CF_CFCLOCKTYPE = "Timestamp";
     private final static String D_CF_COMPTYPE = "BytesType";
     private final static String D_CF_SUBCOMPTYPE = "";
     private final static String D_CF_COMMENT = "";
@@ -172,13 +173,18 @@ public class CassandraServer implements 
             if (column.isMarkedForDelete())
                 continue;
             
-            Column avroColumn = newColumn(column.name(), column.value(), column.timestamp());
+            Column avroColumn = newColumn(column.name(), column.value(), avronateIClock(column.clock()));
             avroColumns.add(avroColumn);
         }
         
         return avroColumns;
     }
-    
+
+    private static Clock avronateIClock(IClock clock)
+    {
+        return newClock(((org.apache.cassandra.db.TimestampClock) clock).timestamp());
+    }
+
     private GenericArray<ColumnOrSuperColumn> avronateColumns(Collection<IColumn> columns, boolean reverseOrder)
     {
         ArrayList<ColumnOrSuperColumn> avroColumns = new ArrayList<ColumnOrSuperColumn>(columns.size());
@@ -187,7 +193,7 @@ public class CassandraServer implements 
             if (column.isMarkedForDelete())
                 continue;
             
-            Column avroColumn = newColumn(column.name(), column.value(), column.timestamp());
+            Column avroColumn = newColumn(column.name(), column.value(), avronateIClock(column.clock()));
             
             if (column instanceof ExpiringColumn)
                 avroColumn.ttl = ((ExpiringColumn)column).getTimeToLive();
@@ -268,7 +274,7 @@ public class CassandraServer implements 
                    parent.super_column == null ? null : parent.super_column.array(),
                    column.name.array()),
                    column.value.array(),
-                   column.timestamp,
+                   unavronateClock(column.clock),
                    column.ttl == null ? 0 : column.ttl);
         }
         catch (MarshalException e)
@@ -339,14 +345,14 @@ public class CassandraServer implements 
                     for (Column column : cosc.super_column.columns)
                     {
                         QueryPath path = new QueryPath(cfName, cosc.super_column.name.array(), column.name.array());
-                        rm.add(path, column.value.array(), column.timestamp);
+                        rm.add(path, column.value.array(), unavronateClock(column.clock), column.ttl == null ? 0 : column.ttl);
                     }
                 }
                 else
                 {
                     assert cosc.super_column == null;
                     QueryPath path = new QueryPath(cfName, null, cosc.column.name.array());
-                    rm.add(path, cosc.column.value.array(), cosc.column.timestamp);
+                    rm.add(path, cosc.column.value.array(), unavronateClock(cosc.column.clock), cosc.column.ttl == null ? 0 : cosc.column.ttl);
                 }
             }
         }
@@ -401,6 +407,11 @@ public class CassandraServer implements 
         
         return null;
     }
+
+    private static IClock unavronateClock(Clock clock)
+    {
+        return new org.apache.cassandra.db.TimestampClock(clock.timestamp);
+    }
     
     // FIXME: This is copypasta from o.a.c.db.RowMutation, (RowMutation.getRowMutation uses Thrift types directly).
     private static RowMutation getRowMutationFromMutations(String keyspace, String key, Map<Utf8, GenericArray<Mutation>> cfMap)
@@ -430,11 +441,11 @@ public class CassandraServer implements 
         if (cosc.column == null)
         {
             for (Column column : cosc.super_column.columns)
-                rm.add(new QueryPath(cfName, cosc.super_column.name.array(), column.name.array()), column.value.array(), column.timestamp);
+                rm.add(new QueryPath(cfName, cosc.super_column.name.array(), column.name.array()), column.value.array(), unavronateClock(column.clock));
         }
         else
         {
-            rm.add(new QueryPath(cfName, null, cosc.column.name.array()), cosc.column.value.array(), cosc.column.timestamp);
+            rm.add(new QueryPath(cfName, null, cosc.column.name.array()), cosc.column.value.array(), unavronateClock(cosc.column.clock));
         }
     }
     
@@ -446,14 +457,14 @@ public class CassandraServer implements 
             for (ByteBuffer col : del.predicate.column_names)
             {
                 if (del.super_column == null && DatabaseDescriptor.getColumnFamilyType(rm.getTable(), cfName) == ColumnFamilyType.Super)
-                    rm.delete(new QueryPath(cfName, col.array()), del.timestamp);
+                    rm.delete(new QueryPath(cfName, col.array()), unavronateClock(del.clock));
                 else
-                    rm.delete(new QueryPath(cfName, del.super_column.array(), col.array()), del.timestamp);
+                    rm.delete(new QueryPath(cfName, del.super_column.array(), col.array()), unavronateClock(del.clock));
             }
         }
         else
         {
-            rm.delete(new QueryPath(cfName, del.super_column.array()), del.timestamp);
+            rm.delete(new QueryPath(cfName, del.super_column.array()), unavronateClock(del.clock));
         }
     }
     
@@ -501,8 +512,9 @@ public class CassandraServer implements 
             Collection<CFMetaData> cfDefs = new ArrayList<CFMetaData>((int)ksDef.cf_defs.size());
             for (CfDef cfDef : ksDef.cf_defs)
             {
-                String cfType, compare, subCompare;
+                String cfType, clockType, compare, subCompare;
                 cfType = cfDef.column_type == null ? D_CF_CFTYPE : cfDef.column_type.toString();
+                clockType = cfDef.clock_type == null ? D_CF_CFCLOCKTYPE : cfDef.clock_type.toString();
                 compare = cfDef.comparator_type == null ? D_CF_COMPTYPE : cfDef.comparator_type.toString();
                 subCompare = cfDef.subcomparator_type == null ? D_CF_SUBCOMPTYPE : cfDef.subcomparator_type.toString();
                 
@@ -510,6 +522,7 @@ public class CassandraServer implements 
                         cfDef.keyspace.toString(),
                         cfDef.name.toString(),
                         ColumnFamilyType.create(cfType),
+                        ClockType.create(clockType),
                         DatabaseDescriptor.getComparator(compare),
                         subCompare.length() == 0 ? null : DatabaseDescriptor.getComparator(subCompare),
                         cfDef.comment == null ? D_CF_COMMENT : cfDef.comment.toString(), 

Modified: cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java Wed May 26 04:45:44 2010
@@ -21,6 +21,7 @@ import org.apache.cassandra.auth.SimpleA
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.BytesType;
 import org.apache.cassandra.thrift.*;
+
 import org.apache.thrift.*;
 
 import org.antlr.runtime.tree.*;
@@ -228,8 +229,9 @@ public class CliClient 
             columnName = CliCompiler.getColumn(columnFamilySpec, 1).getBytes("UTF-8");
         }
 
+        Clock thrift_clock = new Clock().setTimestamp(timestampMicros());
         thriftClient_.remove(key.getBytes(), new ColumnPath(columnFamily).setSuper_column(superColumnName).setColumn(columnName),
-                             timestampMicros(), ConsistencyLevel.ONE);
+                             thrift_clock, ConsistencyLevel.ONE);
         css_.out.println(String.format("%s removed.", (columnSpecCnt == 0) ? "row" : "column"));
     }
 
@@ -259,7 +261,7 @@ public class CliClient 
                 css_.out.printf("=> (super_column=%s,", formatSuperColumnName(keyspace, columnFamily, superColumn));
                 for (Column col : superColumn.getColumns())
                     css_.out.printf("\n     (column=%s, value=%s, timestamp=%d)", formatSubcolumnName(keyspace, columnFamily, col),
-                                    new String(col.value, "UTF-8"), col.timestamp);
+                                    new String(col.value, "UTF-8"), col.clock.timestamp);
                 
                 css_.out.println(")"); 
             }
@@ -267,7 +269,7 @@ public class CliClient 
             {
                 Column column = cosc.column;
                 css_.out.printf("=> (column=%s, value=%s, timestamp=%d)\n", formatColumnName(keyspace, columnFamily, column),
-                                new String(column.value, "UTF-8"), column.timestamp);
+                                new String(column.value, "UTF-8"), column.clock.timestamp);
             }
         }
         
@@ -365,7 +367,7 @@ public class CliClient 
         ColumnPath path = new ColumnPath(columnFamily).setSuper_column(superColumnName).setColumn(columnName);
         Column column = thriftClient_.get(key.getBytes(), path, ConsistencyLevel.ONE).column;
         css_.out.printf("=> (column=%s, value=%s, timestamp=%d)\n", formatColumnName(keySpace, columnFamily, column),
-                        new String(column.value, "UTF-8"), column.timestamp);
+                        new String(column.value, "UTF-8"), column.clock.timestamp);
     }
 
     // Execute SET statement
@@ -410,8 +412,9 @@ public class CliClient 
         }
         
         // do the insert
+        Clock thrift_clock = new Clock().setTimestamp(timestampMicros());
         thriftClient_.insert(key.getBytes(), new ColumnParent(columnFamily).setSuper_column(superColumnName),
-                             new Column(columnName, value.getBytes(), timestampMicros()), ConsistencyLevel.ONE);
+                             new Column(columnName, value.getBytes(), thrift_clock), ConsistencyLevel.ONE);
         
         css_.out.println("Value inserted.");
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java Wed May 26 04:45:44 2010
@@ -35,6 +35,7 @@ import org.apache.commons.lang.builder.E
 import org.apache.commons.lang.builder.HashCodeBuilder;
 
 import org.apache.cassandra.db.ColumnFamilyType;
+import org.apache.cassandra.db.ClockType;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.utils.Pair;
 
@@ -54,10 +55,10 @@ public final class CFMetaData
     
     private static final BiMap<Pair<String, String>, Integer> cfIdMap = HashBiMap.<Pair<String, String>, Integer>create();
     
-    public static final CFMetaData StatusCf = new CFMetaData(Table.SYSTEM_TABLE, SystemTable.STATUS_CF, ColumnFamilyType.Standard, new UTF8Type(), null, "persistent metadata for the local node", 0, false, 0.01, 0);
-    public static final CFMetaData HintsCf = new CFMetaData(Table.SYSTEM_TABLE, HintedHandOffManager.HINTS_CF, ColumnFamilyType.Super, new UTF8Type(), new BytesType(), "hinted handoff data", 0, false, 0.01, 1);
-    public static final CFMetaData MigrationsCf = new CFMetaData(Table.SYSTEM_TABLE, Migration.MIGRATIONS_CF, ColumnFamilyType.Standard, new TimeUUIDType(), null, "individual schema mutations", 0, false, 2);
-    public static final CFMetaData SchemaCf = new CFMetaData(Table.SYSTEM_TABLE, Migration.SCHEMA_CF, ColumnFamilyType.Standard, new UTF8Type(), null, "current state of the schema", 0, false, 3);
+    public static final CFMetaData StatusCf = new CFMetaData(Table.SYSTEM_TABLE, SystemTable.STATUS_CF, ColumnFamilyType.Standard, ClockType.Timestamp, new UTF8Type(), null, "persistent metadata for the local node", 0, false, 0.01, 0);
+    public static final CFMetaData HintsCf = new CFMetaData(Table.SYSTEM_TABLE, HintedHandOffManager.HINTS_CF, ColumnFamilyType.Super, ClockType.Timestamp, new UTF8Type(), new BytesType(), "hinted handoff data", 0, false, 0.01, 1);
+    public static final CFMetaData MigrationsCf = new CFMetaData(Table.SYSTEM_TABLE, Migration.MIGRATIONS_CF, ColumnFamilyType.Standard, ClockType.Timestamp, new TimeUUIDType(), null, "individual schema mutations", 0, false, 2);
+    public static final CFMetaData SchemaCf = new CFMetaData(Table.SYSTEM_TABLE, Migration.SCHEMA_CF, ColumnFamilyType.Standard, ClockType.Timestamp, new UTF8Type(), null, "current state of the schema", 0, false, 3);
 
     /**
      * @return An immutable mapping of (ksname,cfname) to id.
@@ -101,6 +102,7 @@ public final class CFMetaData
     public final String tableName;            // name of table which has this column family
     public final String cfName;               // name of the column family
     public final ColumnFamilyType cfType;     // type: super, standard, etc.
+    public final ClockType clockType;         // clock type: timestamp, etc.
     public final AbstractType comparator;       // name sorted, time stamp sorted etc.
     public final AbstractType subcolumnComparator; // like comparator, for supercolumns
     public final String comment; // for humans only
@@ -111,11 +113,12 @@ public final class CFMetaData
     public boolean preloadRowCache;
 
 
-    private CFMetaData(String tableName, String cfName, ColumnFamilyType cfType, AbstractType comparator, AbstractType subcolumnComparator, String comment, double rowCacheSize, boolean preloadRowCache, double keyCacheSize, double readRepairChance, int cfId)
+    private CFMetaData(String tableName, String cfName, ColumnFamilyType cfType, ClockType clockType, AbstractType comparator, AbstractType subcolumnComparator, String comment, double rowCacheSize, boolean preloadRowCache, double keyCacheSize, double readRepairChance, int cfId)
     {
         this.tableName = tableName;
         this.cfName = cfName;
         this.cfType = cfType;
+        this.clockType = clockType;
         this.comparator = comparator;
         this.subcolumnComparator = subcolumnComparator;
         this.comment = comment;
@@ -139,27 +142,27 @@ public final class CFMetaData
         }
     }
     
-    public CFMetaData(String tableName, String cfName, ColumnFamilyType cfType, AbstractType comparator, AbstractType subcolumnComparator, String comment, double rowCacheSize, boolean preloadRowCache, double keyCacheSize)
+    public CFMetaData(String tableName, String cfName, ColumnFamilyType cfType, ClockType clockType, AbstractType comparator, AbstractType subcolumnComparator, String comment, double rowCacheSize, boolean preloadRowCache, double keyCacheSize)
     {
-        this(tableName, cfName, cfType, comparator, subcolumnComparator, comment, rowCacheSize, preloadRowCache, keyCacheSize, DEFAULT_READ_REPAIR_CHANCE, nextId());
+        this(tableName, cfName, cfType, clockType, comparator, subcolumnComparator, comment, rowCacheSize, preloadRowCache, keyCacheSize, DEFAULT_READ_REPAIR_CHANCE, nextId());
     }
 
-    public CFMetaData(String tableName, String cfName, ColumnFamilyType cfType, AbstractType comparator, AbstractType subcolumnComparator, String comment, double rowCacheSize, boolean preloadRowCache, double keyCacheSize, double readRepairChance)
+    public CFMetaData(String tableName, String cfName, ColumnFamilyType cfType, ClockType clockType, AbstractType comparator, AbstractType subcolumnComparator, String comment, double rowCacheSize, boolean preloadRowCache, double keyCacheSize, double readRepairChance)
     {
-        this(tableName, cfName, cfType, comparator, subcolumnComparator, comment, rowCacheSize, preloadRowCache, keyCacheSize, readRepairChance, nextId());
+        this(tableName, cfName, cfType, clockType, comparator, subcolumnComparator, comment, rowCacheSize, preloadRowCache, keyCacheSize, readRepairChance, nextId());
     }
 
     /** clones an existing CFMetaData using the same id. */
     public static CFMetaData rename(CFMetaData cfm, String newName)
     {
-        CFMetaData newCfm = new CFMetaData(cfm.tableName, newName, cfm.cfType, cfm.comparator, cfm.subcolumnComparator, cfm.comment, cfm.rowCacheSize, cfm.preloadRowCache, cfm.keyCacheSize, cfm.readRepairChance, cfm.cfId);
+        CFMetaData newCfm = new CFMetaData(cfm.tableName, newName, cfm.cfType, cfm.clockType, cfm.comparator, cfm.subcolumnComparator, cfm.comment, cfm.rowCacheSize, cfm.preloadRowCache, cfm.keyCacheSize, cfm.readRepairChance, cfm.cfId);
         return newCfm;
     }
     
     /** clones existing CFMetaData. keeps the id but changes the table name.*/
     public static CFMetaData renameTable(CFMetaData cfm, String tableName)
     {
-        return new CFMetaData(tableName, cfm.cfName, cfm.cfType, cfm.comparator, cfm.subcolumnComparator, cfm.comment, cfm.rowCacheSize, cfm.preloadRowCache, cfm.keyCacheSize, cfm.readRepairChance, cfm.cfId);
+        return new CFMetaData(tableName, cfm.cfName, cfm.cfType, cfm.clockType, cfm.comparator, cfm.subcolumnComparator, cfm.comment, cfm.rowCacheSize, cfm.preloadRowCache, cfm.keyCacheSize, cfm.readRepairChance, cfm.cfId);
     }
     
     /** used for evicting cf data out of static tracking collections. */
@@ -174,6 +177,7 @@ public final class CFMetaData
     {
         return tableName + "." + cfName + "\n"
                + "Column Family Type: " + cfType + "\n"
+               + "Column Family Clock Type: " + clockType + "\n"
                + "Columns Sorted By: " + comparator + "\n";
     }
 
@@ -184,6 +188,7 @@ public final class CFMetaData
         dout.writeUTF(cfm.tableName);
         dout.writeUTF(cfm.cfName);
         dout.writeUTF(cfm.cfType.name());
+        dout.writeUTF(cfm.clockType.name());
         dout.writeUTF(cfm.comparator.getClass().getName());
         dout.writeBoolean(cfm.subcolumnComparator != null);
         if (cfm.subcolumnComparator != null)
@@ -206,6 +211,7 @@ public final class CFMetaData
         String tableName = din.readUTF();
         String cfName = din.readUTF();
         ColumnFamilyType cfType = ColumnFamilyType.create(din.readUTF());
+        ClockType clockType = ClockType.create(din.readUTF());
         AbstractType comparator = null;
         try
         {
@@ -230,7 +236,7 @@ public final class CFMetaData
         double keyCacheSize = din.readDouble();
         double readRepairChance = din.readDouble();
         int cfId = din.readInt();
-        return new CFMetaData(tableName, cfName, cfType, comparator, subcolumnComparator, comment, rowCacheSize, preloadRowCache, keyCacheSize, readRepairChance, cfId);
+        return new CFMetaData(tableName, cfName, cfType, clockType, comparator, subcolumnComparator, comment, rowCacheSize, preloadRowCache, keyCacheSize, readRepairChance, cfId);
     }
     
 
@@ -250,6 +256,7 @@ public final class CFMetaData
             .append(tableName, rhs.tableName)
             .append(cfName, rhs.cfName)
             .append(cfType, rhs.cfType)
+            .append(clockType, rhs.clockType)
             .append(comparator, rhs.comparator)
             .append(subcolumnComparator, rhs.subcolumnComparator)
             .append(comment, rhs.comment)
@@ -266,6 +273,7 @@ public final class CFMetaData
             .append(tableName)
             .append(cfName)
             .append(cfType)
+            .append(clockType)
             .append(comparator)
             .append(subcolumnComparator)
             .append(comment)

Modified: cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java Wed May 26 04:45:44 2010
@@ -511,7 +511,7 @@ public class DatabaseDescriptor
                 {                        
                     throw new ConfigurationException("read_repair_chance must be between 0.0 and 1.0");
                 }
-                cfDefs[j++] = new CFMetaData(keyspace.name, cf.name, cfType, comparator, subcolumnComparator, cf.comment, cf.rows_cached, cf.preload_row_cache, cf.keys_cached, cf.read_repair_chance);
+                cfDefs[j++] = new CFMetaData(keyspace.name, cf.name, cfType, ClockType.Timestamp, comparator, subcolumnComparator, cf.comment, cf.rows_cached, cf.preload_row_cache, cf.keys_cached, cf.read_repair_chance);
             }
             defs.add(new KSMetaData(keyspace.name, strategyClass, keyspace.replication_factor, cfDefs));
             
@@ -714,6 +714,15 @@ public class DatabaseDescriptor
         return cfMetaData.cfType;
     }
 
+    public static ClockType getClockType(String tableName, String cfName)
+    {
+        assert tableName != null && cfName != null;
+        CFMetaData cfMetaData = getCFMetaData(tableName, cfName);
+
+        assert (cfMetaData != null);
+        return cfMetaData.clockType;
+    }
+
     public static Set<String> getTables()
     {
         return tables.keySet();

Copied: cassandra/trunk/src/java/org/apache/cassandra/db/ClockType.java (from r948100, cassandra/trunk/src/java/org/apache/cassandra/db/DeletedColumn.java)
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ClockType.java?p2=cassandra/trunk/src/java/org/apache/cassandra/db/ClockType.java&p1=cassandra/trunk/src/java/org/apache/cassandra/db/DeletedColumn.java&r1=948100&r2=948316&rev=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/DeletedColumn.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ClockType.java Wed May 26 04:45:44 2010
@@ -15,44 +15,34 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.cassandra.db;
 
-import java.nio.ByteBuffer;
-
-import org.apache.cassandra.utils.FBUtilities;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.cassandra.io.ICompactSerializer2;
 
-public class DeletedColumn extends Column
+public enum ClockType
 {
-    private static Logger logger = LoggerFactory.getLogger(DeletedColumn.class);
-    
-    public DeletedColumn(byte[] name, int localDeletionTime, long timestamp)
-    {
-        this(name, FBUtilities.toByteArray(localDeletionTime), timestamp);
-    }
-
-    public DeletedColumn(byte[] name, byte[] value, long ts)
-    {
-        super(name, value, ts);
-    }
+    Timestamp;
 
-    @Override
-    public boolean isMarkedForDelete()
+    public final static ClockType create(String name)
     {
-        return true;
+        assert name != null;
+        try
+        {
+            return ClockType.valueOf(name);
+        }
+        catch (IllegalArgumentException e)
+        {
+            return null;
+        }
     }
 
-    @Override
-    public long getMarkedForDeleteAt()
+    public final IClock minClock()
     {
-        return timestamp;
+        return TimestampClock.MIN_VALUE;
     }
 
-    @Override
-    public int getLocalDeletionTime()
+    public final ICompactSerializer2<IClock> serializer()
     {
-        return ByteBuffer.wrap(value()).getInt();
+        return TimestampClock.SERIALIZER;
     }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Column.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Column.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Column.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Column.java Wed May 26 04:45:44 2010
@@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
 import org.apache.commons.lang.ArrayUtils;
 
 import org.apache.cassandra.db.marshal.AbstractType;
+import org.apache.cassandra.db.IClock.ClockRelationship;
 import org.apache.cassandra.io.util.DataOutputBuffer;
 import org.apache.cassandra.utils.FBUtilities;
 
@@ -41,16 +42,14 @@ public class Column implements IColumn
 {
     private static Logger logger = LoggerFactory.getLogger(Column.class);
 
-    private static ColumnSerializer serializer = new ColumnSerializer();
-
-    public static ColumnSerializer serializer()
+    public static ColumnSerializer serializer(ClockType clockType)
     {
-        return serializer;
+        return new ColumnSerializer(clockType);
     }
 
     protected final byte[] name;
     protected final byte[] value;
-    protected final long timestamp;
+    protected final IClock clock;
 
     Column(byte[] name)
     {
@@ -59,17 +58,18 @@ public class Column implements IColumn
 
     public Column(byte[] name, byte[] value)
     {
-        this(name, value, 0);
+        // safe to set to null, only used for filter comparisons
+        this(name, value, null);
     }
 
-    public Column(byte[] name, byte[] value, long timestamp)
+    public Column(byte[] name, byte[] value, IClock clock)
     {
         assert name != null;
         assert value != null;
         assert name.length <= IColumn.MAX_NAME_LENGTH;
         this.name = name;
         this.value = value;
-        this.timestamp = timestamp;
+        this.clock = clock;
     }
 
     public byte[] name()
@@ -97,9 +97,9 @@ public class Column implements IColumn
         return 1;
     }
 
-    public long timestamp()
+    public IClock clock()
     {
-        return timestamp;
+        return clock;
     }
 
     public boolean isMarkedForDelete()
@@ -107,14 +107,14 @@ public class Column implements IColumn
         return false;
     }
 
-    public long getMarkedForDeleteAt()
+    public IClock getMarkedForDeleteAt()
     {
         throw new IllegalStateException("column is not marked for delete");
     }
 
-    public long mostRecentLiveChangeAt()
+    public IClock mostRecentLiveChangeAt()
     {
-        return timestamp;
+        return clock;
     }
 
     public int size()
@@ -123,11 +123,11 @@ public class Column implements IColumn
          * Size of a column is =
          *   size of a name (short + length of the string)
          * + 1 byte to indicate if the column has been deleted
-         * + 8 bytes for timestamp
+         * + x bytes depending on IClock size
          * + 4 bytes which basically indicates the size of the byte array
          * + entire byte array.
         */
-        return DBConstants.shortSize_ + name.length + DBConstants.boolSize_ + DBConstants.tsSize_ + DBConstants.intSize_ + value.length;
+        return DBConstants.shortSize_ + name.length + DBConstants.boolSize_ + clock.size() + DBConstants.intSize_ + value.length;
     }
 
     /*
@@ -146,7 +146,7 @@ public class Column implements IColumn
 
     public IColumn diff(IColumn column)
     {
-        if (timestamp() < column.timestamp())
+        if (ClockRelationship.GREATER_THAN == column.clock().compare(clock))
         {
             return column;
         }
@@ -160,7 +160,7 @@ public class Column implements IColumn
         DataOutputBuffer buffer = new DataOutputBuffer();
         try
         {
-            buffer.writeLong(timestamp);
+            clock.serialize(buffer);
             buffer.writeByte((isMarkedForDelete()) ? ColumnSerializer.DELETION_MASK : 0);
         }
         catch (IOException e)
@@ -176,20 +176,46 @@ public class Column implements IColumn
     }
 
     // note that we do not call this simply compareTo since it also makes sense to compare Columns by name
-    public long comparePriority(Column o)
+    public ClockRelationship comparePriority(Column o)
     {
+        ClockRelationship rel = clock.compare(o.clock());
+
         // tombstone always wins ties.
         if (isMarkedForDelete())
-            return timestamp < o.timestamp ? -1 : 1;
+        {
+            switch (rel)
+            {
+                case EQUAL:
+                    return ClockRelationship.GREATER_THAN;
+                default:
+                    return rel;
+            }
+        }
         if (o.isMarkedForDelete())
-            return timestamp > o.timestamp ? 1 : -1;
-        
-        // compare value as tie-breaker for equal timestamps
-        if (timestamp == o.timestamp)
-            return FBUtilities.compareByteArrays(value, o.value);
+        {
+            switch (rel)
+            {
+                case EQUAL:
+                    return ClockRelationship.LESS_THAN;
+                default:
+                    return rel;
+            }
+        }
+
+        // compare value as tie-breaker for equal clocks
+        if (ClockRelationship.EQUAL == rel)
+        {
+            int valRel = FBUtilities.compareByteArrays(value, o.value);
+            if (1 == valRel)
+                return ClockRelationship.GREATER_THAN;
+            if (0 == valRel)
+                return ClockRelationship.EQUAL;
+            // -1 == valRel
+            return ClockRelationship.LESS_THAN;
+        }
 
-        // neither is tombstoned and timestamps are different
-        return timestamp - o.timestamp;
+        // neither is tombstoned and clocks are different
+        return rel;
     }
 
     public String getString(AbstractType comparator)
@@ -201,7 +227,7 @@ public class Column implements IColumn
         sb.append(":");
         sb.append(value.length);
         sb.append("@");
-        sb.append(timestamp());
+        sb.append(clock.toString());
         return sb.toString();
     }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java Wed May 26 04:45:44 2010
@@ -28,11 +28,13 @@ import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.cassandra.config.CFMetaData;
 
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.io.ICompactSerializer2;
+import org.apache.cassandra.db.IClock.ClockRelationship;
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.utils.FBUtilities;
@@ -62,28 +64,31 @@ public class ColumnFamily implements ICo
     {
         if (cfm == null)
             throw new IllegalArgumentException("Unknown column family.");
-        return new ColumnFamily(cfm.cfType, cfm.comparator, cfm.subcolumnComparator, cfm.cfId);
+        return new ColumnFamily(cfm.cfType, cfm.clockType, cfm.comparator, cfm.subcolumnComparator, cfm.cfId);
     }
 
     private final int cfid;
     private final ColumnFamilyType type;
+    private final ClockType clockType;
 
     private transient ICompactSerializer2<IColumn> columnSerializer;
-    final AtomicLong markedForDeleteAt = new AtomicLong(Long.MIN_VALUE);
+    final AtomicReference<IClock> markedForDeleteAt;
     final AtomicInteger localDeletionTime = new AtomicInteger(Integer.MIN_VALUE);
     private ConcurrentSkipListMap<byte[], IColumn> columns;
 
-    public ColumnFamily(ColumnFamilyType type, AbstractType comparator, AbstractType subcolumnComparator, int cfid)
+    public ColumnFamily(ColumnFamilyType type, ClockType clockType, AbstractType comparator, AbstractType subcolumnComparator, int cfid)
     {
         this.type = type;
-        columnSerializer = type == ColumnFamilyType.Standard ? Column.serializer() : SuperColumn.serializer(subcolumnComparator);
+        this.clockType = clockType;
+        this.markedForDeleteAt = new AtomicReference<IClock>(clockType.minClock());
+        columnSerializer = type == ColumnFamilyType.Standard ? Column.serializer(clockType) : SuperColumn.serializer(subcolumnComparator, clockType);
         columns = new ConcurrentSkipListMap<byte[], IColumn>(comparator);
         this.cfid = cfid;
      }
     
     public ColumnFamily cloneMeShallow()
     {
-        ColumnFamily cf = new ColumnFamily(type, getComparator(), getSubComparator(), cfid);
+        ColumnFamily cf = new ColumnFamily(type, clockType, getComparator(), getSubComparator(), cfid);
         cf.markedForDeleteAt.set(markedForDeleteAt.get());
         cf.localDeletionTime.set(localDeletionTime.get());
         return cf;
@@ -99,6 +104,11 @@ public class ColumnFamily implements ICo
         return type;
     }
 
+    public ClockType getClockType()
+    {
+        return clockType;
+    }
+
     public ColumnFamily cloneMe()
     {
         ColumnFamily cf = cloneMeShallow();
@@ -156,32 +166,32 @@ public class ColumnFamily implements ICo
         return type == ColumnFamilyType.Super;
     }
 
-    public void addColumn(QueryPath path, byte[] value, long timestamp)
+    public void addColumn(QueryPath path, byte[] value, IClock clock)
     {
         assert path.columnName != null : path;
-        addColumn(path.superColumnName, new Column(path.columnName, value, timestamp));
+        addColumn(path.superColumnName, new Column(path.columnName, value, clock));
     }
 
-    public void addTombstone(QueryPath path, byte[] localDeletionTime, long timestamp)
+    public void addTombstone(QueryPath path, byte[] localDeletionTime, IClock clock)
     {
-        addColumn(path.superColumnName, new DeletedColumn(path.columnName, localDeletionTime, timestamp));
+        addColumn(path.superColumnName, new DeletedColumn(path.columnName, localDeletionTime, clock));
     }
 
-    public void addColumn(QueryPath path, byte[] value, long timestamp, int timeToLive)
+    public void addColumn(QueryPath path, byte[] value, IClock clock, int timeToLive)
     {
         assert path.columnName != null : path;
         Column column;
         if (timeToLive > 0)
-            column = new ExpiringColumn(path.columnName, value, timestamp, timeToLive);
+            column = new ExpiringColumn(path.columnName, value, clock, timeToLive);
         else
-            column = new Column(path.columnName, value, timestamp);
+            column = new Column(path.columnName, value, clock);
         addColumn(path.superColumnName, column);
     }
 
-    public void deleteColumn(QueryPath path, int localDeletionTime, long timestamp)
+    public void deleteColumn(QueryPath path, int localDeletionTime, IClock clock)
     {
         assert path.columnName != null : path;
-        addColumn(path.superColumnName, new DeletedColumn(path.columnName, localDeletionTime, timestamp));
+        addColumn(path.superColumnName, new DeletedColumn(path.columnName, localDeletionTime, clock));
     }
 
     public void addColumn(byte[] superColumnName, Column column)
@@ -194,7 +204,7 @@ public class ColumnFamily implements ICo
         else
         {
             assert isSuper();
-            c = new SuperColumn(superColumnName, getSubComparator());
+            c = new SuperColumn(superColumnName, getSubComparator(), clockType);
             c.addColumn(column); // checks subcolumn name
         }
         addColumn(c);
@@ -221,7 +231,7 @@ public class ColumnFamily implements ICo
             }
             else
             {
-                while (((Column) oldColumn).comparePriority((Column)column) <= 0)
+                while (ClockRelationship.GREATER_THAN != ((Column) oldColumn).comparePriority((Column) column))
                 {
                     if (columns.replace(name, oldColumn, column))
                         break;
@@ -257,10 +267,10 @@ public class ColumnFamily implements ICo
     }
 
     @Deprecated // TODO this is a hack to set initial value outside constructor
-    public void delete(int localtime, long timestamp)
+    public void delete(int localtime, IClock clock)
     {
         localDeletionTime.set(localtime);
-        markedForDeleteAt.set(timestamp);
+        markedForDeleteAt.set(clock);
     }
 
     public void delete(ColumnFamily cf2)
@@ -271,7 +281,8 @@ public class ColumnFamily implements ICo
 
     public boolean isMarkedForDelete()
     {
-        return markedForDeleteAt.get() > Long.MIN_VALUE;
+        IClock _markedForDeleteAt = markedForDeleteAt.get();
+        return _markedForDeleteAt.compare(clockType.minClock()) == ClockRelationship.GREATER_THAN;
     }
 
     /*
@@ -280,8 +291,9 @@ public class ColumnFamily implements ICo
      */
     public ColumnFamily diff(ColumnFamily cfComposite)
     {
-        ColumnFamily cfDiff = new ColumnFamily(cfComposite.type, getComparator(), getSubComparator(), cfComposite.id());
-        if (cfComposite.getMarkedForDeleteAt() > getMarkedForDeleteAt())
+        ColumnFamily cfDiff = new ColumnFamily(cfComposite.type, cfComposite.clockType, getComparator(), getSubComparator(), cfComposite.id());
+        ClockRelationship rel = cfComposite.getMarkedForDeleteAt().compare(getMarkedForDeleteAt());
+        if (ClockRelationship.GREATER_THAN == rel)
         {
             cfDiff.delete(cfComposite.getLocalDeletionTime(), cfComposite.getMarkedForDeleteAt());
         }
@@ -346,7 +358,7 @@ public class ColumnFamily implements ICo
         sb.append(cfm == null ? "-deleted-" : cfm.cfName);
 
         if (isMarkedForDelete())
-            sb.append(" -deleted at " + getMarkedForDeleteAt() + "-");
+            sb.append(" -deleted at " + getMarkedForDeleteAt().toString() + "-");
 
         sb.append(" [").append(getComparator().getColumnsString(getSortedColumns())).append("])");
         return sb.toString();
@@ -375,7 +387,7 @@ public class ColumnFamily implements ICo
             column.updateDigest(digest);
     }
 
-    public long getMarkedForDeleteAt()
+    public IClock getMarkedForDeleteAt()
     {
         return markedForDeleteAt.get();
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilySerializer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilySerializer.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilySerializer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilySerializer.java Wed May 26 04:45:44 2010
@@ -74,7 +74,8 @@ public class ColumnFamilySerializer impl
         try
         {
             dos.writeInt(columnFamily.localDeletionTime.get());
-            dos.writeLong(columnFamily.markedForDeleteAt.get());
+            IClock _markedForDeleteAt = columnFamily.markedForDeleteAt.get();
+            columnFamily.getClockType().serializer().serialize(_markedForDeleteAt, dos);
 
             Collection<IColumn> columns = columnFamily.getSortedColumns();
             dos.writeInt(columns.size());
@@ -140,8 +141,8 @@ public class ColumnFamilySerializer impl
     }
 
     public ColumnFamily deserializeFromSSTableNoColumns(ColumnFamily cf, DataInput input) throws IOException
-    {
-        cf.delete(input.readInt(), input.readLong());
+    {        
+        cf.delete(input.readInt(), cf.getClockType().serializer().deserialize(input));
         return cf;
     }
 

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Wed May 26 04:45:44 2010
@@ -41,6 +41,8 @@ import org.apache.cassandra.concurrent.N
 import org.apache.cassandra.concurrent.StageManager;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.db.IClock;
+import org.apache.cassandra.db.IClock.ClockRelationship;
 import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.db.commitlog.CommitLogSegment;
 import org.apache.cassandra.db.filter.*;
@@ -484,11 +486,19 @@ public class ColumnFamilyStore implement
         for (byte[] cname : cf.getColumnNames())
         {
             IColumn c = cf.getColumnsMap().get(cname);
-            if ((c.isMarkedForDelete() && c.getLocalDeletionTime() <= gcBefore)
-                || c.timestamp() <= cf.getMarkedForDeleteAt())
+            // we split the test to avoid comparing if not necessary
+            if ((c.isMarkedForDelete() && c.getLocalDeletionTime() <= gcBefore))
             {
                 cf.remove(cname);
             }
+            else
+            {
+                ClockRelationship rel = c.clock().compare(cf.getMarkedForDeleteAt());
+                if ((ClockRelationship.LESS_THAN == rel) || (ClockRelationship.EQUAL == rel))
+                {
+                    cf.remove(cname);
+                }
+            }
         }
     }
 
@@ -500,14 +510,23 @@ public class ColumnFamilyStore implement
         for (byte[] cname : cf.getColumnNames())
         {
             IColumn c = cf.getColumnsMap().get(cname);
-            long minTimestamp = Math.max(c.getMarkedForDeleteAt(), cf.getMarkedForDeleteAt());
+            List<IClock> clocks = Arrays.asList(cf.getMarkedForDeleteAt());
+            IClock minClock = c.getMarkedForDeleteAt().getSuperset(clocks);
             for (IColumn subColumn : c.getSubColumns())
             {
-                if (subColumn.timestamp() <= minTimestamp
-                    || (subColumn.isMarkedForDelete() && subColumn.getLocalDeletionTime() <= gcBefore))
+                // we split the test to avoid comparing if not necessary
+                if (subColumn.isMarkedForDelete() && subColumn.getLocalDeletionTime() <= gcBefore)
                 {
                     ((SuperColumn)c).remove(subColumn.name());
                 }
+                else
+                {
+                    ClockRelationship subRel = subColumn.clock().compare(minClock);
+                    if ((ClockRelationship.LESS_THAN == subRel) || (ClockRelationship.EQUAL == subRel))
+                    {
+                        ((SuperColumn)c).remove(subColumn.name());
+                    }
+                }
             }
             if (c.getSubColumns().isEmpty() && c.getLocalDeletionTime() <= gcBefore)
             {

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnSerializer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnSerializer.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnSerializer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnSerializer.java Wed May 26 04:45:44 2010
@@ -33,6 +33,13 @@ public class ColumnSerializer implements
     public final static int DELETION_MASK = 0x01;
     public final static int EXPIRATION_MASK = 0x02;
 
+    private ClockType clockType;
+
+    public ColumnSerializer(ClockType clockType)
+    {
+        this.clockType = clockType;
+    }
+    
     public void serialize(IColumn column, DataOutput dos)
     {
         FBUtilities.writeShortByteArray(column.name(), dos);
@@ -45,7 +52,7 @@ public class ColumnSerializer implements
             } else {
               dos.writeByte((column.isMarkedForDelete()) ? DELETION_MASK : 0);
             }
-            dos.writeLong(column.timestamp());
+            clockType.serializer().serialize(column.clock(), dos);
             FBUtilities.writeByteArray(column.value(), dos);
         }
         catch (IOException e)
@@ -62,7 +69,7 @@ public class ColumnSerializer implements
         {
             int ttl = dis.readInt();
             int expiration = dis.readInt();
-            long ts = dis.readLong();
+            IClock clock = clockType.serializer().deserialize(dis);
             byte[] value = FBUtilities.readByteArray(dis);
             if ((int) (System.currentTimeMillis() / 1000 ) > expiration)
             {
@@ -70,22 +77,22 @@ public class ColumnSerializer implements
                 // tombstone
                 ByteBuffer bytes = ByteBuffer.allocate(4);
                 bytes.putInt(expiration);
-                return new DeletedColumn(name, bytes.array(), ts);
+                return new DeletedColumn(name, bytes.array(), clock);
             }
             else
             {
-                return new ExpiringColumn(name, value, ts, ttl, expiration);
+                return new ExpiringColumn(name, value, clock, ttl, expiration);
             }
         }
         else
         {
             boolean delete = FBUtilities.testBitUsingBitMask(b, DELETION_MASK);
-            long ts = dis.readLong();
+            IClock clock = clockType.serializer().deserialize(dis);
             byte[] value = FBUtilities.readByteArray(dis);
             if (FBUtilities.testBitUsingBitMask(b, DELETION_MASK)) {
-                return new DeletedColumn(name, value, ts);
+                return new DeletedColumn(name, value, clock);
             } else {
-                return new Column(name, value, ts);
+                return new Column(name, value, clock);
             }
         }
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java Wed May 26 04:45:44 2010
@@ -51,12 +51,12 @@ public class DefsTable
         for (String tableName : DatabaseDescriptor.getNonSystemTables())
         {
             KSMetaData ks = DatabaseDescriptor.getTableDefinition(tableName);
-            rm.add(new QueryPath(Migration.SCHEMA_CF, null, ks.name.getBytes()), KSMetaData.serialize(ks), now);
+            rm.add(new QueryPath(Migration.SCHEMA_CF, null, ks.name.getBytes()), KSMetaData.serialize(ks), new TimestampClock(now));
         }
         rm.apply();
         
         rm = new RowMutation(Table.SYSTEM_TABLE, Migration.LAST_MIGRATION_KEY);
-        rm.add(new QueryPath(Migration.SCHEMA_CF, null, Migration.LAST_MIGRATION_KEY), UUIDGen.decompose(version), now);
+        rm.add(new QueryPath(Migration.SCHEMA_CF, null, Migration.LAST_MIGRATION_KEY), UUIDGen.decompose(version), new TimestampClock(now));
         rm.apply();
     }
 

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/DeletedColumn.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/DeletedColumn.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/DeletedColumn.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/DeletedColumn.java Wed May 26 04:45:44 2010
@@ -28,14 +28,14 @@ public class DeletedColumn extends Colum
 {
     private static Logger logger = LoggerFactory.getLogger(DeletedColumn.class);
     
-    public DeletedColumn(byte[] name, int localDeletionTime, long timestamp)
+    public DeletedColumn(byte[] name, int localDeletionTime, IClock clock)
     {
-        this(name, FBUtilities.toByteArray(localDeletionTime), timestamp);
+        this(name, FBUtilities.toByteArray(localDeletionTime), clock);
     }
 
-    public DeletedColumn(byte[] name, byte[] value, long ts)
+    public DeletedColumn(byte[] name, byte[] value, IClock clock)
     {
-        super(name, value, ts);
+        super(name, value, clock);
     }
 
     @Override
@@ -45,9 +45,9 @@ public class DeletedColumn extends Colum
     }
 
     @Override
-    public long getMarkedForDeleteAt()
+    public IClock getMarkedForDeleteAt()
     {
-        return timestamp;
+        return clock;
     }
 
     @Override

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ExpiringColumn.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ExpiringColumn.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ExpiringColumn.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ExpiringColumn.java Wed May 26 04:45:44 2010
@@ -43,14 +43,14 @@ public class ExpiringColumn extends Colu
     private final int localExpirationTime;
     private final int timeToLive;
 
-    public ExpiringColumn(byte[] name, byte[] value, long timestamp, int timeToLive)
+    public ExpiringColumn(byte[] name, byte[] value, IClock clock, int timeToLive)
     {
-      this(name, value, timestamp, timeToLive, (int) (System.currentTimeMillis() / 1000) + timeToLive);
+      this(name, value, clock, timeToLive, (int) (System.currentTimeMillis() / 1000) + timeToLive);
     }
 
-    public ExpiringColumn(byte[] name, byte[] value, long timestamp, int timeToLive, int localExpirationTime)
+    public ExpiringColumn(byte[] name, byte[] value, IClock clock, int timeToLive, int localExpirationTime)
     {
-        super(name, value, timestamp);
+        super(name, value, clock);
         assert timeToLive > 0;
         assert localExpirationTime > 0;
         this.timeToLive = timeToLive;
@@ -87,7 +87,7 @@ public class ExpiringColumn extends Colu
         DataOutputBuffer buffer = new DataOutputBuffer();
         try
         {
-            buffer.writeLong(timestamp());
+            clock.serialize(buffer);
             buffer.writeByte(ColumnSerializer.EXPIRATION_MASK);
             buffer.writeInt(timeToLive);
         }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java Wed May 26 04:45:44 2010
@@ -143,14 +143,14 @@ public class HintedHandOffManager
     private static void deleteEndpoint(byte[] endpointAddress, String tableName, byte[] key, long timestamp) throws IOException
     {
         RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, tableName.getBytes(UTF8));
-        rm.delete(new QueryPath(HINTS_CF, key, endpointAddress), timestamp);
+        rm.delete(new QueryPath(HINTS_CF, key, endpointAddress), new TimestampClock(timestamp));
         rm.apply();
     }
 
     private static void deleteHintKey(String tableName, byte[] key) throws IOException
     {
         RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, tableName.getBytes(UTF8));
-        rm.delete(new QueryPath(HINTS_CF, key, null), System.currentTimeMillis());
+        rm.delete(new QueryPath(HINTS_CF, key, null), new TimestampClock(System.currentTimeMillis()));
         rm.apply();
     }
 
@@ -294,7 +294,7 @@ public class HintedHandOffManager
             RowMutation drop = new RowMutation(Table.SYSTEM_TABLE, oldTableKey.key);
             for (byte[] key : cf.getColumnNames())
             {
-                drop.delete(new QueryPath(HINTS_CF, key), now);
+                drop.delete(new QueryPath(HINTS_CF, key), new TimestampClock(now));
                 startCol = key;
             }
             drop.apply();

Added: cassandra/trunk/src/java/org/apache/cassandra/db/IClock.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/IClock.java?rev=948316&view=auto
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/IClock.java (added)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/IClock.java Wed May 26 04:45:44 2010
@@ -0,0 +1,72 @@
+/**
+ * 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.cassandra.db;
+
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * A clock used for conflict resolution.
+ */
+public interface IClock
+{
+    public static enum ClockRelationship
+    {
+        EQUAL,
+        GREATER_THAN,
+        LESS_THAN,
+        DISJOINT
+    };
+
+    /**
+     * @param other Compare these two clocks.
+     * @return The relationship between the two clocks,
+     * lets us know if reconciliation will have to take place.
+     */
+    public ClockRelationship compare(IClock other);
+
+    /**
+     * @param otherClocks The other clock to use when extracting the superset.
+     * @return The superset of the two clocks.
+     */
+    public IClock getSuperset(List<IClock> otherClocks);
+
+    /**
+     * @return number of bytes this type of clock
+     * uses up when serialized.
+     */
+    public int size();
+
+    /**
+     * @return the type of this clock.
+     */
+    public ClockType type();
+
+    /**
+     * @param out Write a serialized representation of this clock to the output.
+     * @throws IOException Thrown if writing failed.
+     */
+    public void serialize(DataOutput out) throws IOException;
+
+    /**
+     * @return a textual representation of this clock.
+     */
+    public String toString();
+}

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java Wed May 26 04:45:44 2010
@@ -29,12 +29,12 @@ public interface IColumn
     public static final int MAX_NAME_LENGTH = FBUtilities.MAX_UNSIGNED_SHORT;
 
     public boolean isMarkedForDelete();
-    public long getMarkedForDeleteAt();
-    public long mostRecentLiveChangeAt();
+    public IClock getMarkedForDeleteAt();
+    public IClock mostRecentLiveChangeAt();
     public byte[] name();
     public int size();
     public int serializedSize();
-    public long timestamp();
+    public IClock clock();
     public byte[] value();
     public Collection<IColumn> getSubColumns();
     public IColumn getSubColumn(byte[] columnName);

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/IColumnContainer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/IColumnContainer.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/IColumnContainer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/IColumnContainer.java Wed May 26 04:45:44 2010
@@ -28,7 +28,7 @@ public interface IColumnContainer
     public void addColumn(IColumn column);
 
     public boolean isMarkedForDelete();
-    public long getMarkedForDeleteAt();
+    public IClock getMarkedForDeleteAt();
 
     public AbstractType getComparator();
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java?rev=948316&r1=948315&r2=948316&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java Wed May 26 04:45:44 2010
@@ -219,7 +219,7 @@ public class Memtable implements Compara
         if (isStandard)
             startIColumn = new Column(filter.start);
         else
-            startIColumn = new SuperColumn(filter.start, null); // ok to not have subcolumnComparator since we won't be adding columns to this object
+            startIColumn = new SuperColumn(filter.start, null, cf.getClockType()); // ok to not have subcolumnComparator since we won't be adding columns to this object
 
         // can't use a ColumnComparatorFactory comparator since those compare on both name and time (and thus will fail to match
         // our dummy column, since the time there is arbitrary).



Mime
View raw message