MCPcopy Create free account
hub / github.com/apache/impala / compare

Method compare

fe/src/main/java/org/apache/impala/util/AcidUtils.java:593–638  ·  view source on GitHub ↗
(Pair<String, ParsedDelta> o1, Pair<String, ParsedDelta> o2)

Source from the content-addressed store, hash-verified

591 // there's delta_N_M and delta_N_M_v001234 then delta_N_M_v001234 must be ordered
592 // before.
593 @Override
594 public int compare(Pair<String, ParsedDelta> o1, Pair<String, ParsedDelta> o2) {
595 ParsedDelta pd1 = o1.second;
596 ParsedDelta pd2 = o2.second;
597 if (pd1.minWriteId != pd2.minWriteId) {
598 if (pd1.minWriteId < pd2.minWriteId) {
599 return -1;
600 } else {
601 return 1;
602 }
603 } else if (pd1.maxWriteId != pd2.maxWriteId) {
604 if (pd1.maxWriteId < pd2.maxWriteId) {
605 return 1;
606 } else {
607 return -1;
608 }
609 } else if (pd1.statementId != pd2.statementId) {
610 /**
611 * We want deltas after minor compaction (w/o statementId) to sort earlier so
612 * that getAcidState() considers compacted files (into larger ones) obsolete
613 * Before compaction, include deltas with all statementIds for a given writeId.
614 */
615 if (pd1.statementId < pd2.statementId) {
616 return -1;
617 } else {
618 return 1;
619 }
620 } else if (pd1.visibilityTxnId != pd2.visibilityTxnId) {
621 // This is an alteration from Hive's algorithm. If everything is the same then
622 // the higher visibilityTxnId wins (since no visibiltyTxnId is -1).
623 // Currently this cannot happen since Hive doesn't minor compact standalone
624 // delta directories of streaming ingestion, i.e. the following cannot happen:
625 // delta_1_5 => delta_1_5_v01234
626 // However, it'd make sense because streaming ingested ORC files doesn't use
627 // advanced features like dictionary encoding or statistics. Hence Hive might
628 // do that in the future and that'd make Impala seeing duplicate rows.
629 // So I'd be cautious here in case they forget to tell us.
630 if (pd1.visibilityTxnId < pd2.visibilityTxnId) {
631 return 1;
632 } else {
633 return -1;
634 }
635 } else {
636 return o1.first.compareTo(o2.first);
637 }
638 }
639 });
640 return deltas;
641 }

Callers 4

getOrLoadTableMethod · 0.95

Calls 10

isTransactionalTableMethod · 0.95
getTableIdMethod · 0.95
allInvalidFromMethod · 0.95
minMethod · 0.80
getMetaStoreTableMethod · 0.65
getValidWriteIdsMethod · 0.65
getTableNameMethod · 0.65
getInvalidWriteIdsMethod · 0.65
getHighWatermarkMethod · 0.65
compareToMethod · 0.45

Tested by 2