HADOOP-16196. Path Parameterize Comparable.
Author: David Mollitor <david.mollitor@cloudera.com>
(cherry picked from commit 246ab77f28
)
This commit is contained in:
parent
39f60faa60
commit
9a449ac075
|
@ -40,7 +40,8 @@ import org.apache.hadoop.conf.Configuration;
|
||||||
@Stringable
|
@Stringable
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Stable
|
@InterfaceStability.Stable
|
||||||
public class Path implements Comparable, Serializable, ObjectInputValidation {
|
public class Path
|
||||||
|
implements Comparable<Path>, Serializable, ObjectInputValidation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The directory separator, a slash.
|
* The directory separator, a slash.
|
||||||
|
@ -490,9 +491,8 @@ public class Path implements Comparable, Serializable, ObjectInputValidation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Object o) {
|
public int compareTo(Path o) {
|
||||||
Path that = (Path)o;
|
return this.uri.compareTo(o.uri);
|
||||||
return this.uri.compareTo(that.uri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -860,16 +860,15 @@ public class MergeManagerImpl<K, V> implements MergeManager<K, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Object obj) {
|
public int compareTo(Path obj) {
|
||||||
if (obj instanceof CompressAwarePath) {
|
if (obj instanceof CompressAwarePath) {
|
||||||
CompressAwarePath compPath = (CompressAwarePath) obj;
|
CompressAwarePath compPath = (CompressAwarePath) obj;
|
||||||
if(this.compressedSize < compPath.getCompressedSize()) {
|
int c = Long.compare(this.compressedSize, compPath.compressedSize);
|
||||||
return -1;
|
|
||||||
} else if (this.getCompressedSize() > compPath.getCompressedSize()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
// Not returning 0 here so that objects with the same size (but
|
// Not returning 0 here so that objects with the same size (but
|
||||||
// different paths) are still added to the TreeSet.
|
// different paths) are still added to the TreeSet.
|
||||||
|
if (c != 0) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.compareTo(obj);
|
return super.compareTo(obj);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue