Skip to content

Commit

Permalink
use different method of saving long (>64k) mappings
Browse files Browse the repository at this point in the history
fix #147
  • Loading branch information
costin committed Feb 22, 2014
1 parent c4a9362 commit 4d94f50
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/org/elasticsearch/hadoop/mr/EsInputFormat.java
Expand Up @@ -106,7 +106,10 @@ public void write(DataOutput out) throws IOException {
out.writeUTF(nodeId);
out.writeUTF(nodeName);
out.writeUTF(shardId);
out.writeUTF(mapping);
// avoid using writeUTF since the mapping can be longer than 65K
byte[] utf = StringUtils.toUTF(mapping);
out.writeInt(utf.length);
out.write(utf);
}

@Override
Expand All @@ -116,7 +119,10 @@ public void readFields(DataInput in) throws IOException {
nodeId = in.readUTF();
nodeName = in.readUTF();
shardId = in.readUTF();
mapping = in.readUTF();
int length = in.readInt();
byte[] utf = new byte[length];
in.readFully(utf);
mapping = StringUtils.asUTFString(utf);
}

@Override
Expand Down

0 comments on commit 4d94f50

Please sign in to comment.