Search in sources :

Example 6 with Predicate

use of org.apache.gobblin.source.extractor.watermark.Predicate in project incubator-gobblin by apache.

the class QueryBasedExtractor method getLatestWatermark.

/**
 * if snapshot extract, get latest watermark else return work unit high watermark
 *
 * @param watermark column
 * @param low watermark value
 * @param high watermark value
 * @param column format
 * @return letst watermark
 * @throws IOException
 */
private long getLatestWatermark(String watermarkColumn, WatermarkType watermarkType, long lwmValue, long hwmValue) throws HighWatermarkException, IOException {
    if (!Boolean.valueOf(this.workUnitState.getProp(ConfigurationKeys.SOURCE_QUERYBASED_SKIP_HIGH_WATERMARK_CALC))) {
        log.info("Getting high watermark");
        List<Predicate> list = new ArrayList<>();
        WatermarkPredicate watermark = new WatermarkPredicate(watermarkColumn, watermarkType);
        String lwmOperator = partition.isLowWatermarkInclusive() ? ">=" : ">";
        String hwmOperator = (partition.isLastPartition() || partition.isHighWatermarkInclusive()) ? "<=" : "<";
        Predicate lwmPredicate = watermark.getPredicate(this, lwmValue, lwmOperator, Predicate.PredicateType.LWM);
        Predicate hwmPredicate = watermark.getPredicate(this, hwmValue, hwmOperator, Predicate.PredicateType.HWM);
        if (lwmPredicate != null) {
            list.add(lwmPredicate);
        }
        if (hwmPredicate != null) {
            list.add(hwmPredicate);
        }
        return this.getMaxWatermark(this.schema, this.entity, watermarkColumn, list, watermark.getWatermarkSourceFormat(this));
    }
    return hwmValue;
}
Also used : ArrayList(java.util.ArrayList) WatermarkPredicate(org.apache.gobblin.source.extractor.watermark.WatermarkPredicate) WatermarkPredicate(org.apache.gobblin.source.extractor.watermark.WatermarkPredicate) Predicate(org.apache.gobblin.source.extractor.watermark.Predicate)

Aggregations

Predicate (org.apache.gobblin.source.extractor.watermark.Predicate)6 AsyncApiException (com.sforce.async.AsyncApiException)4 IOException (java.io.IOException)3 ParseException (java.text.ParseException)3 DataRecordException (org.apache.gobblin.source.extractor.DataRecordException)3 HighWatermarkException (org.apache.gobblin.source.extractor.exception.HighWatermarkException)3 RecordCountException (org.apache.gobblin.source.extractor.exception.RecordCountException)3 RestApiClientException (org.apache.gobblin.source.extractor.exception.RestApiClientException)3 RestApiConnectionException (org.apache.gobblin.source.extractor.exception.RestApiConnectionException)3 SchemaException (org.apache.gobblin.source.extractor.exception.SchemaException)3 WatermarkPredicate (org.apache.gobblin.source.extractor.watermark.WatermarkPredicate)2 BatchInfo (com.sforce.async.BatchInfo)1 BatchInfoList (com.sforce.async.BatchInfoList)1 QueryResultList (com.sforce.async.QueryResultList)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1