alex-ninja commented on a change in pull request #1117:
URL: https://github.com/apache/cassandra/pull/1117#discussion_r701294712



##########
File path: 
src/java/org/apache/cassandra/db/virtual/AbstractWritableVirtualTable.java
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.virtual;
+
+import java.nio.ByteBuffer;
+import java.util.SortedMap;
+import javax.annotation.Nullable;
+
+import org.apache.cassandra.db.Clustering;
+import org.apache.cassandra.db.ClusteringBound;
+import org.apache.cassandra.db.ClusteringPrefix;
+import org.apache.cassandra.db.DecoratedKey;
+import org.apache.cassandra.db.Slice;
+import org.apache.cassandra.db.marshal.CompositeType;
+import org.apache.cassandra.db.partitions.PartitionUpdate;
+import org.apache.cassandra.db.rows.Cell;
+import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.schema.TableMetadata;
+
+/**
+ * An abstract virtual table implementation that builds the resultset on 
demand and allows fine-grained source modification.
+ */
+public abstract class AbstractWritableVirtualTable extends AbstractVirtualTable
+{
+
+    protected AbstractWritableVirtualTable(TableMetadata metadata)
+    {
+        super(metadata);
+    }
+
+    @Override
+    public void apply(PartitionUpdate update)
+    {
+        DecoratedKey partitionKey = update.partitionKey();
+
+        if (update.deletionInfo().isLive())
+            update.forEach(row ->
+            {
+                Clustering<?> clusteringColumns = row.clustering();
+
+                if (row.deletion().isLive())
+                    row.forEach(columnMetadata ->
+                    {
+                        if (columnMetadata.column().isComplex())
+                            throw new InvalidRequestException("Complex type 
column deletes are not supported by table " + metadata);
+
+                        Cell<?> cell = (Cell<?>) columnMetadata;
+
+                        if (cell.isTombstone())
+                            applyColumnDelete(partitionKey, clusteringColumns, 
cell);
+                        else
+                            applyColumnUpdate(partitionKey, clusteringColumns, 
cell);
+                    });
+                else
+                    applyRowDelete(partitionKey, clusteringColumns);
+            });
+        else
+        {
+            // MutableDeletionInfo may have partition delete or range 
tombstone list or both
+            if (update.deletionInfo().hasRanges())
+                update.deletionInfo()
+                        .rangeIterator(false)
+                        .forEachRemaining(rt -> 
applyRangeTombstone(partitionKey, rt.deletedSlice()));
+
+            if (!update.deletionInfo().getPartitionDeletion().isLive())
+                applyPartitionDelete(partitionKey);
+        }
+    }
+
+    protected void applyPartitionDelete(DecoratedKey partitionKey)

Review comment:
       In fact I assumed it to be a noun, like "a delete" similarly to "an 
update". However, I feel `Deletion` makes more sense because this term is used 
in other classes and sounds more coherent to the project's vocabulary.
   
   Fixed.




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

To unsubscribe, e-mail: [email protected]

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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to