You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by GitBox <gi...@apache.org> on 2019/12/09 22:30:34 UTC

[GitHub] [incubator-gobblin] arekusuri commented on a change in pull request #2722: GOBBLIN-865: Add feature that enables PK-chunking in partition

arekusuri commented on a change in pull request #2722: GOBBLIN-865: Add feature that enables PK-chunking in partition
URL: https://github.com/apache/incubator-gobblin/pull/2722#discussion_r355721539
 
 

 ##########
 File path: gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceExtractor.java
 ##########
 @@ -588,16 +566,41 @@ public String getTimestampPredicateCondition(String column, long value, String v
     return dataTypeMap;
   }
 
+
+  private Boolean isPkChunkingFetchDone = false;
+
+  private Iterator<JsonElement> getRecordSetPkchunking(WorkUnit workUnit) throws RuntimeException {
+    if (isPkChunkingFetchDone) {
+      return null; // must return null to represent no more data.
+    }
+    isPkChunkingFetchDone = true; // set to true, never come here twice.
+    try {
+      if (!bulkApiLogin()) {
+        throw new IllegalArgumentException("Invalid Login");
+      }
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
+    String jobId = workUnit.getProp(PK_CHUNKING_JOB_ID);
+    String batchIdResultIdString = workUnit.getProp(PK_CHUNKING_BATCH_RESULT_IDS);
+    return new ResultIterator(bulkConnection, jobId, batchIdResultIdString, fetchRetryLimit);
+  }
+
   @Override
   public Iterator<JsonElement> getRecordSetFromSourceApi(String schema, String entity, WorkUnit workUnit,
       List<Predicate> predicateList) throws IOException {
     log.debug("Getting salesforce data using bulk api");
-    RecordSet<JsonElement> rs = null;
 
+    // new version of extractor: bulk api with pk-chunking in pre-partitioning of SalesforceSource
+    if (workUnit.contains(PK_CHUNKING_JOB_ID)) {
+      log.info("----pk-chunking get record set----" + workUnit.getProp(PK_CHUNKING_JOB_ID));
+      return getRecordSetPkchunking(workUnit);
 
 Review comment:
   It won't be an easy change.
   We need to change the dynamic-mode to execute all the sub-queries in one batch right after we spilt the giant query, and then we can use the fetching module which PK-Chunking is using and the `ResultIterator` is involved.
   
   However we don't have to do it.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services