yifan-c commented on code in PR #155:
URL: 
https://github.com/apache/cassandra-analytics/pull/155#discussion_r2540039005


##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/data/DataLayer.java:
##########
@@ -198,6 +199,17 @@ public SparkRangeFilter sparkRangeFilter(int partitionId)
         return null;
     }
 
+    /**
+     * Returns a list of {@link SSTableTimeRangeFilter} to filter out SSTables 
based on min and max timestamp.
+     *
+     * @return list of {@link SSTableTimeRangeFilter} for filtering SSTables 
based on max and min timestamps. When
+     * the list is empty, all SSTables are included for bulk reading.
+     */
+    public List<SSTableTimeRangeFilter> sstableTimeRangeFilters()

Review Comment:
   Please update the return type. Just return the filter, instead of a list of 
filters. 



##########
cassandra-analytics-common/src/main/java/org/apache/cassandra/spark/sparksql/filters/SSTableTimeRangeFilter.java:
##########
@@ -0,0 +1,127 @@
+/*
+ * 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.spark.sparksql.filters;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+import com.google.common.collect.Range;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * {@link SSTableTimeRangeFilter} to filter out based on timestamp in 
microseconds.
+ * Uses Google Guava's Range internally for storing time range.
+ */
+public class SSTableTimeRangeFilter implements Serializable
+{
+    public static final SSTableTimeRangeFilter EMPTY = new 
SSTableTimeRangeFilter(Range.closed(0L, 0L))
+    {
+        @Override
+        public boolean overlaps(long startMicros, long endMicros)
+        {
+            return true; // accepts all SSTables
+        }
+    };

Review Comment:
   When I originally suggested, the empty filter was with range 
`Range.openClosed(0L, 0L)`. The filter does _not_ overlap with any sstables, 
hence it is named `EMPTY`. It is to replace the usage of `null`. 
   The code here creates a filter that overlaps with all SSTables. Now I 
realize that this is probably the behavior you want. Could you rename the 
filter? It is not really `EMPTY`, but `ALL`. The code can be simplified to 
   ```suggestion
       public static final SSTableTimeRangeFilter ALL = new 
SSTableTimeRangeFilter(Range.all());
   ```



-- 
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