Hi there,
I have the requirement to use Hadoop with case-insensitivity and
case-preservation ala Windows.
Hadoop has such a clean class hierarchy it seems that the only change
needed is in INode.java,
(snippet below).
Can anyone help with the following question -
If I change only the methods below (to all work case-insensitively) is
this sufficient?
I.e. can I trust that all file/dir name comparison go through these
four methods.
Or will I get bitten by code elsewhere that does name comparisons or otherwise
requires case-sensitive behavior?
Many thanks for any comments.
-paul
=================
public abstract class INode implements Comparable<byte[]> {
.............
.............
//
// Comparable interface
//
public int compareTo(byte[] o) {
return compareBytes(name, o);
}
public boolean equals(Object o) {
if (!(o instanceof INode)) {
return false;
}
return Arrays.equals(this.name, ((INode)o).name);
}
public int hashCode() {
return Arrays.hashCode(this.name);
}
//
// static methods
//
/**
* Compare two byte arrays.
*
* @return a negative integer, zero, or a positive integer
* as defined by {...@link #compareTo(byte[])}.
*/
static int compareBytes(byte[] a1, byte[] a2) {
if (a1==a2)
return 0;
int len1 = (a1==null ? 0 : a1.length);
int len2 = (a2==null ? 0 : a2.length);
int n = Math.min(len1, len2);
byte b1, b2;
for (int i=0; i<n; i++) {
b1 = a1[i];
b2 = a2[i];
if (b1 != b2)
return b1 - b2;
}
return len1 - len2;
}
.............
.............
}