[ https://issues.apache.org/jira/browse/GOBBLIN-865?focusedWorklogId=353630&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-353630 ]
ASF GitHub Bot logged work on GOBBLIN-865: ------------------------------------------ Author: ASF GitHub Bot Created on: 04/Dec/19 18:35 Start Date: 04/Dec/19 18:35 Worklog Time Spent: 10m Work Description: htran1 commented on pull request #2722: GOBBLIN-865: Add feature that enables PK-chunking in partition URL: https://github.com/apache/incubator-gobblin/pull/2722#discussion_r353379037 ########## File path: gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/ResultIterator.java ########## @@ -0,0 +1,166 @@ +/* + * 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.gobblin.salesforce; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.sforce.async.BulkConnection; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.gobblin.configuration.ConfigurationKeys; +import org.apache.gobblin.source.extractor.utils.InputStreamCSVReader; +import org.apache.gobblin.source.extractor.utils.Utils; + + +/** + * Result Iterator. + * Take jobId and 'batchId:resultId,batchId2:resultId2' as input build a result record iterator. + */ +@Slf4j +public class ResultIterator implements Iterator { + private Iterator<ResultStruct> batchIdResultIdIterator; + private BulkConnection bulkConnection; + private InputStreamCSVReader csvReader; + private List<String> csvHeader; + private int columnSize; + private int urlLoadRetryLimit; + private ResultStruct resultStruct; + private List<String> currentRecord = null; + private Boolean isLoadedCurrentRecord = false; + private int currentFileRowCount = 0; + private int totalRowCount = 0; + + /** + * constructor + * need to initiate the reader and currentRecord + */ + public ResultIterator(BulkConnection bulkConnection, String jobId, String batchIdResultIdString, int urlLoadRetryLimit) { + this.urlLoadRetryLimit = urlLoadRetryLimit; + this.bulkConnection = bulkConnection; + this.batchIdResultIdIterator = this.parsebatchIdResultIdString(jobId, batchIdResultIdString); + if (this.batchIdResultIdIterator.hasNext()) { + this.resultStruct = this.batchIdResultIdIterator.next(); + this.csvReader = this.fetchResultsetAsCsvReader(this.resultStruct); // first file reader + } else { + throw new RuntimeException("No batch-result id found."); + } + this.fulfilCurrentRecord(); + this.csvHeader = this.currentRecord; + this.columnSize = this.csvHeader.size(); + // after fetching cvs header, clean up status + this.resetCurrentRecordStatus(); + } + + /** + * call reader.next and set up currentRecord + */ + private void fulfilCurrentRecord() { Review comment: fulfilCurrentRecord -> fulfillCurrentRecord ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 353630) Time Spent: 9.5h (was: 9h 20m) > Add feature that enables PK-chunking in partition > -------------------------------------------------- > > Key: GOBBLIN-865 > URL: https://issues.apache.org/jira/browse/GOBBLIN-865 > Project: Apache Gobblin > Issue Type: Task > Reporter: Alex Li > Priority: Major > Labels: salesforce > Time Spent: 9.5h > Remaining Estimate: 0h > > In SFDC(salesforce) connector, we have partitioning mechanisms to split a > giant query to multiple sub queries. There are 3 mechanisms: > * simple partition (equally split by time) > * dynamic pre-partition (generate histogram and split by row numbers) > * user specified partition (set up time range in job file) > However there are tables like Task and Contract are failing time to time to > fetch full data. > We may want to utilize PK-chunking to partition the query. > > The pk-chunking doc from SFDC - > [https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/async_api_headers_enable_pk_chunking.htm] -- This message was sent by Atlassian Jira (v8.3.4#803005)