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/df65b174 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/df65b174 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/df65b174 Branch: refs/heads/4.x-HBase-0.98 Commit: df65b174df641d920a0ff9f142eedd7a85bde3bc Parents: 8296b98 Author: Sergey Soldatov <[email protected]> Authored: Thu Jun 9 17:59:51 2016 -0700 Committer: Sergey Soldatov <[email protected]> Committed: Fri Jun 10 01:57:25 2016 -0700 ---------------------------------------------------------------------- .../phoenix/mapreduce/FormatToBytesWritableMapper.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/df65b174/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());
