[ 
https://issues.apache.org/jira/browse/BEAM-9008?focusedWorklogId=370558&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-370558
 ]

ASF GitHub Bot logged work on BEAM-9008:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 13/Jan/20 02:24
            Start Date: 13/Jan/20 02:24
    Worklog Time Spent: 10m 
      Work Description: suztomo commented on issue #10546: [BEAM-9008] add 
CassandraIO readAll method
URL: https://github.com/apache/beam/pull/10546#issuecomment-573487705
 
 
   Would you ensure the change passes ` ./gradlew -p sdks/java check`? I see it 
fails with format violations:
   
   ```
   suztomo-macbookpro44:vmarquez-beam suztomo$ git log -1
   commit d85e6b95d64664af37148c792b35ff02abfd90f5 (HEAD -> 
feature/BEAM-9008/cassandraio_readall, 
origin/feature/BEAM-9008/cassandraio_readall)
   Author: Vincent Marquez <[email protected]>
   Date:   Wed Dec 18 16:48:52 2019 -0800
   
       implementing CassandraIO.readAll
   suztomo-macbookpro44:vmarquez-beam suztomo$ ./gradlew -p sdks/java check
   Configuration on demand is an incubating feature.
   
   ...
   
   * What went wrong:
   Execution failed for task ':sdks:java:io:cassandra:spotlessJava'.
   > The following files had format violations:
         
sdks/java/io/cassandra/src/test/java/org/apache/beam/sdk/io/cassandra/CassandraIOTest.java
             @@ -184,31 +184,33 @@
              
              ····LOGGER.info("Insert·records");
              ····String[][]·scientists·=·{
             -······new·String·[]·{"phys",·"Einstein"},
             -······new·String·[]·{"bio",·"Darwin"},
             -······new·String·[]·{"phys",·"Copernicus"},
             -······new·String·[]·{"bio",·"Pasteur"},
             -······new·String·[]·{"bio",·"Curie"},
             -······new·String·[]·{"phys",·"Faraday"},
             -······new·String·[]·{"math",·"Newton"},
             -······new·String·[]·{"phys",·"Bohr"},
             -······new·String·[]·{"phys",·"Galilei"},
             -······new·String·[]·{·"math",·"Maxwell"},
             +······new·String[]·{"phys",·"Einstein"},
             +······new·String[]·{"bio",·"Darwin"},
             +······new·String[]·{"phys",·"Copernicus"},
             +······new·String[]·{"bio",·"Pasteur"},
             +······new·String[]·{"bio",·"Curie"},
             +······new·String[]·{"phys",·"Faraday"},
             +······new·String[]·{"math",·"Newton"},
             +······new·String[]·{"phys",·"Bohr"},
             +······new·String[]·{"phys",·"Galilei"},
             +······new·String[]·{"math",·"Maxwell"},
              ····};
              ····for·(int·i·=·0;·i·<·NUM_ROWS;·i++)·{
              ······int·index·=·i·%·scientists.length;
             -······String·insertStr·=·String.format(
             
-··········"INSERT·INTO·%s.%s(person_department,·person_id,·person_name)·values("
             -··············+·"'"·+·scientists[index][0]·+·"',·"
             -··············+·i
             -··············+·",·'"
             -··············+·scientists[index][1]
             -··············+·"');",
             -··········CASSANDRA_KEYSPACE,
             -··········CASSANDRA_TABLE);
             -········LOGGER.error("Error·with·str·=·"·+·insertStr);
             -······session.execute(insertStr
             -··········);
             +······String·insertStr·=
             +··········String.format(
             
+··············"INSERT·INTO·%s.%s(person_department,·person_id,·person_name)·values("
             +··················+·"'"
             +··················+·scientists[index][0]
             +··················+·"',·"
             +··················+·i
             +··················+·",·'"
             +··················+·scientists[index][1]
             +··················+·"');",
         ... (102 more lines that didn't fit)
     Violations also present in:
         
sdks/java/io/cassandra/src/main/java/org/apache/beam/sdk/io/cassandra/QueryFn.java
         
sdks/java/io/cassandra/src/main/java/org/apache/beam/sdk/io/cassandra/CassandraConfig.java
         
sdks/java/io/cassandra/src/main/java/org/apache/beam/sdk/io/cassandra/CassandraIO.java
     Run 'gradlew spotlessApply' to fix these violations.
   ```
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 370558)
    Time Spent: 20m  (was: 10m)

> add readAll() method to CassandraIO
> -----------------------------------
>
>                 Key: BEAM-9008
>                 URL: https://issues.apache.org/jira/browse/BEAM-9008
>             Project: Beam
>          Issue Type: New Feature
>          Components: io-java-cassandra
>    Affects Versions: 2.16.0
>            Reporter: vincent marquez
>            Assignee: vincent marquez
>            Priority: Minor
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> 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:
> {code:java}
> public class Event { 
>    @PartitionKey(0) public UUID accountId;
>    @PartitionKey(1)public String yearMonthDay; 
>    @ClusteringKey public UUID eventId;  
>    //other data...
> }{code}
> 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. 
> {code:java}
> Set<UUID> accounts = getRelevantAccounts();
> Set<String> dateRange = generateDateRange("2018-01-01", "2019-01-01");
> PCollection<TokenRange> tokens = generateTokens(accounts, dateRange); 
> {code}
>  
>  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. 
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to