|
@@ -992,8 +992,8 @@ public class SequenceFile {
|
|
// Append the 'key'
|
|
// Append the 'key'
|
|
keySerializer.serialize(key);
|
|
keySerializer.serialize(key);
|
|
int keyLength = buffer.getLength();
|
|
int keyLength = buffer.getLength();
|
|
- if (keyLength == 0)
|
|
|
|
- throw new IOException("zero length keys not allowed: " + key);
|
|
|
|
|
|
+ if (keyLength < 0)
|
|
|
|
+ throw new IOException("negative length keys not allowed: " + key);
|
|
|
|
|
|
// Append the 'value'
|
|
// Append the 'value'
|
|
if (compress) {
|
|
if (compress) {
|
|
@@ -1014,8 +1014,8 @@ public class SequenceFile {
|
|
|
|
|
|
public synchronized void appendRaw(byte[] keyData, int keyOffset,
|
|
public synchronized void appendRaw(byte[] keyData, int keyOffset,
|
|
int keyLength, ValueBytes val) throws IOException {
|
|
int keyLength, ValueBytes val) throws IOException {
|
|
- if (keyLength == 0)
|
|
|
|
- throw new IOException("zero length keys not allowed: " + keyLength);
|
|
|
|
|
|
+ if (keyLength < 0)
|
|
|
|
+ throw new IOException("negative length keys not allowed: " + keyLength);
|
|
|
|
|
|
int valLength = val.getSize();
|
|
int valLength = val.getSize();
|
|
|
|
|
|
@@ -1119,8 +1119,8 @@ public class SequenceFile {
|
|
// Append the 'key'
|
|
// Append the 'key'
|
|
keySerializer.serialize(key);
|
|
keySerializer.serialize(key);
|
|
int keyLength = buffer.getLength();
|
|
int keyLength = buffer.getLength();
|
|
- if (keyLength == 0)
|
|
|
|
- throw new IOException("zero length keys not allowed: " + key);
|
|
|
|
|
|
+ if (keyLength < 0)
|
|
|
|
+ throw new IOException("negative length keys not allowed: " + key);
|
|
|
|
|
|
// Compress 'value' and append it
|
|
// Compress 'value' and append it
|
|
deflateFilter.resetState();
|
|
deflateFilter.resetState();
|
|
@@ -1139,8 +1139,8 @@ public class SequenceFile {
|
|
public synchronized void appendRaw(byte[] keyData, int keyOffset,
|
|
public synchronized void appendRaw(byte[] keyData, int keyOffset,
|
|
int keyLength, ValueBytes val) throws IOException {
|
|
int keyLength, ValueBytes val) throws IOException {
|
|
|
|
|
|
- if (keyLength == 0)
|
|
|
|
- throw new IOException("zero length keys not allowed");
|
|
|
|
|
|
+ if (keyLength < 0)
|
|
|
|
+ throw new IOException("negative length keys not allowed: " + keyLength);
|
|
|
|
|
|
int valLength = val.getSize();
|
|
int valLength = val.getSize();
|
|
|
|
|
|
@@ -1302,8 +1302,8 @@ public class SequenceFile {
|
|
int oldKeyLength = keyBuffer.getLength();
|
|
int oldKeyLength = keyBuffer.getLength();
|
|
keySerializer.serialize(key);
|
|
keySerializer.serialize(key);
|
|
int keyLength = keyBuffer.getLength() - oldKeyLength;
|
|
int keyLength = keyBuffer.getLength() - oldKeyLength;
|
|
- if (keyLength == 0)
|
|
|
|
- throw new IOException("zero length keys not allowed: " + key);
|
|
|
|
|
|
+ if (keyLength < 0)
|
|
|
|
+ throw new IOException("negative length keys not allowed: " + key);
|
|
WritableUtils.writeVInt(keyLenBuffer, keyLength);
|
|
WritableUtils.writeVInt(keyLenBuffer, keyLength);
|
|
|
|
|
|
int oldValLength = valBuffer.getLength();
|
|
int oldValLength = valBuffer.getLength();
|
|
@@ -1325,8 +1325,8 @@ public class SequenceFile {
|
|
public synchronized void appendRaw(byte[] keyData, int keyOffset,
|
|
public synchronized void appendRaw(byte[] keyData, int keyOffset,
|
|
int keyLength, ValueBytes val) throws IOException {
|
|
int keyLength, ValueBytes val) throws IOException {
|
|
|
|
|
|
- if (keyLength == 0)
|
|
|
|
- throw new IOException("zero length keys not allowed");
|
|
|
|
|
|
+ if (keyLength < 0)
|
|
|
|
+ throw new IOException("negative length keys not allowed");
|
|
|
|
|
|
int valLength = val.getSize();
|
|
int valLength = val.getSize();
|
|
|
|
|
|
@@ -2229,7 +2229,7 @@ public class SequenceFile {
|
|
|
|
|
|
/** Sort and merge files containing the named classes. */
|
|
/** Sort and merge files containing the named classes. */
|
|
public Sorter(FileSystem fs, Class keyClass, Class valClass, Configuration conf) {
|
|
public Sorter(FileSystem fs, Class keyClass, Class valClass, Configuration conf) {
|
|
- this(fs, new WritableComparator(keyClass), keyClass, valClass, conf);
|
|
|
|
|
|
+ this(fs, WritableComparator.get(keyClass), keyClass, valClass, conf);
|
|
}
|
|
}
|
|
|
|
|
|
/** Sort and merge using an arbitrary {@link RawComparator}. */
|
|
/** Sort and merge using an arbitrary {@link RawComparator}. */
|