PHOENIX-2975 CSVBulkLoad for local index only fails.
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/d0d6964a Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/d0d6964a Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/d0d6964a Branch: refs/heads/4.x-HBase-1.0 Commit: d0d6964af67002c9290d756656bb09944726494b Parents: 16810a8 Author: Sergey Soldatov <s...@apache.org> Authored: Thu Jun 9 17:59:51 2016 -0700 Committer: Sergey Soldatov <s...@apache.org> Committed: Fri Jun 10 01:57:43 2016 -0700 ---------------------------------------------------------------------- .../phoenix/mapreduce/FormatToBytesWritableMapper.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/d0d6964a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java index a736fc4..cacbce7 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java @@ -248,7 +248,7 @@ public abstract class FormatToBytesWritableMapper<RECORD> extends Mapper<LongWri if(columnIndexes.containsKey(cfn)) { return columnIndexes.get(cfn); } - throw new IOException("Unable to map cell to column index"); + return -1; } /** @@ -287,8 +287,14 @@ public abstract class FormatToBytesWritableMapper<RECORD> extends Mapper<LongWri /* The order of aggregation: type, index of column, length of value, value itself */ - outputStream.writeByte(cell.getTypeByte()); int i = findIndex(cell); + if(i == -1) { + //That may happen when we load only local indexes. Since KV pairs for both + // table and local index are going to the same physical table at that point + // we skip those KVs that are not belongs to loca index + continue; + } + outputStream.writeByte(cell.getTypeByte()); WritableUtils.writeVInt(outputStream, i); WritableUtils.writeVInt(outputStream, cell.getValueLength()); outputStream.write(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());