Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-9008

Add readAll() method to CassandraIO

Details

    • New Feature
    • Status: Resolved
    • P3
    • Resolution: Fixed
    • 2.16.0
    • 2.34.0
    • io-java-cassandra
    • None

    Description

      When querying a large cassandra database, it's often much more useful to programatically generate the queries needed to to be run rather than reading all partitions and attempting some filtering.  

      As an example:

      public class Event { 
         @PartitionKey(0) public UUID accountId;
         @PartitionKey(1)public String yearMonthDay; 
         @ClusteringKey public UUID eventId;  
         //other data...
      }

      If there is ten years worth of data, you may want to only query one year's worth.  Here each token range would represent one 'token' but all events for the day. 

      Set<UUID> accounts = getRelevantAccounts();
      Set<String> dateRange = generateDateRange("2018-01-01", "2019-01-01");
      PCollection<TokenRange> tokens = generateTokens(accounts, dateRange); 
      

       

       I propose an additional readAll() PTransform that can take a PCollection of token ranges and can return a PCollection<T> of what the query would return. 

      Question: How much code should be in common between both methods? 
      Currently the read connector already groups all partitions into a List of Token Ranges, so it would be simple to refactor the current read() based method to a 'ParDo' based one and have them both share the same function.  Reasons against sharing code between read and readAll

      • Not having the read based method return a BoundedSource connector would mean losing the ability to know the size of the data returned
      • Currently the CassandraReader executes all the grouped TokenRange queries asynchronously which is (maybe?) fine when all that's happening is splitting up all the partition ranges but terrible for executing potentially millions of queries. 

       Reasons for sharing code would be simplified code base and that both of the above issues would most likely have a negligable performance impact. 

       

       

       

      Attachments

        Issue Links

          Activity

            People

              vmarquez vincent marquez
              vmarquez vincent marquez
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20h 50m
                  20h 50m