mirror of https://github.com/apache/cassandra
Fix NPE in Pig's widerow mode.
Patch by Sheetal Gorsani and Jeremy Hanna, reviewed by brandonwilliams for CASSANDRA-5488
This commit is contained in:
parent
c5dc0292e0
commit
7d2ce5f957
|
|
@ -4,6 +4,7 @@
|
|||
(CASSANDRA-5497)
|
||||
* fsync leveled manifest to avoid corruption (CASSANDRA-5535)
|
||||
* Fix Bound intersection computation (CASSANDRA-5551)
|
||||
* Fix NPE in Pig's widerow mode (CASSANDRA-5488)
|
||||
|
||||
1.1.11
|
||||
* Fix trying to load deleted row into row cache on startup (CASSANDRA-4463)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
rows = LOAD 'cassandra://PigTest/SomeApp' USING CassandraStorage();
|
||||
rows = LOAD 'cassandra://PigTest/SomeApp?widerows=true' USING CassandraStorage();
|
||||
-- full copy
|
||||
STORE rows INTO 'cassandra://PigTest/CopyOfSomeApp' USING CassandraStorage();
|
||||
-- single tuple
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ public class CassandraStorage extends LoadFunc implements StoreFuncInterface, Lo
|
|||
if (tuple.size() == 0) // lastRow is a new one
|
||||
{
|
||||
key = (ByteBuffer)reader.getCurrentKey();
|
||||
addKeyToTuple(tuple, key, cfDef, parseType(cfDef.getKey_validation_class()));
|
||||
tuple = addKeyToTuple(tuple, key, cfDef, parseType(cfDef.getKey_validation_class()));
|
||||
}
|
||||
for (Map.Entry<ByteBuffer, IColumn> entry : lastRow.entrySet())
|
||||
{
|
||||
|
|
@ -180,7 +180,7 @@ public class CassandraStorage extends LoadFunc implements StoreFuncInterface, Lo
|
|||
key = (ByteBuffer)reader.getCurrentKey();
|
||||
if (lastKey != null && !(key.equals(lastKey))) // last key only had one value
|
||||
{
|
||||
addKeyToTuple(tuple, lastKey, cfDef, parseType(cfDef.getKey_validation_class()));
|
||||
tuple = addKeyToTuple(tuple, lastKey, cfDef, parseType(cfDef.getKey_validation_class()));
|
||||
for (Map.Entry<ByteBuffer, IColumn> entry : lastRow.entrySet())
|
||||
{
|
||||
bag.add(columnToTuple(entry.getValue(), cfDef, parseType(cfDef.getComparator_type())));
|
||||
|
|
@ -190,7 +190,7 @@ public class CassandraStorage extends LoadFunc implements StoreFuncInterface, Lo
|
|||
lastRow = (SortedMap<ByteBuffer,IColumn>)reader.getCurrentValue();
|
||||
return tuple;
|
||||
}
|
||||
addKeyToTuple(tuple, lastKey, cfDef, parseType(cfDef.getKey_validation_class()));
|
||||
tuple = addKeyToTuple(tuple, lastKey, cfDef, parseType(cfDef.getKey_validation_class()));
|
||||
}
|
||||
SortedMap<ByteBuffer,IColumn> row = (SortedMap<ByteBuffer,IColumn>)reader.getCurrentValue();
|
||||
if (lastRow != null) // prepend what was read last time
|
||||
|
|
@ -233,7 +233,7 @@ public class CassandraStorage extends LoadFunc implements StoreFuncInterface, Lo
|
|||
// output tuple, will hold the key, each indexed column in a tuple, then a bag of the rest
|
||||
// NOTE: we're setting the tuple size here only for the key so we can use setTupleValue on it
|
||||
|
||||
Tuple tuple = keyToTuple(key, cfDef, parseType(cfDef.getKey_validation_class()));
|
||||
Tuple tuple = addKeyToTuple(null, key, cfDef, parseType(cfDef.getKey_validation_class()));
|
||||
DefaultDataBag bag = new DefaultDataBag();
|
||||
|
||||
// we must add all the indexed columns first to match the schema
|
||||
|
|
@ -292,15 +292,12 @@ public class CassandraStorage extends LoadFunc implements StoreFuncInterface, Lo
|
|||
return t;
|
||||
}
|
||||
|
||||
private Tuple keyToTuple(ByteBuffer key, CfDef cfDef, AbstractType comparator) throws IOException
|
||||
{
|
||||
Tuple tuple = TupleFactory.getInstance().newTuple(1);
|
||||
addKeyToTuple(tuple, key, cfDef, comparator);
|
||||
return tuple;
|
||||
}
|
||||
|
||||
private void addKeyToTuple(Tuple tuple, ByteBuffer key, CfDef cfDef, AbstractType comparator) throws IOException
|
||||
private Tuple addKeyToTuple(Tuple tuple, ByteBuffer key, CfDef cfDef, AbstractType comparator) throws IOException
|
||||
{
|
||||
if( tuple == null )
|
||||
{
|
||||
tuple = TupleFactory.getInstance().newTuple(1);
|
||||
}
|
||||
if( comparator instanceof AbstractCompositeType )
|
||||
{
|
||||
setTupleValue(tuple, 0, composeComposite((AbstractCompositeType)comparator,key));
|
||||
|
|
@ -309,7 +306,7 @@ public class CassandraStorage extends LoadFunc implements StoreFuncInterface, Lo
|
|||
{
|
||||
setTupleValue(tuple, 0, getDefaultMarshallers(cfDef).get(MarshallerType.KEY_VALIDATOR).compose(key));
|
||||
}
|
||||
|
||||
return tuple;
|
||||
}
|
||||
|
||||
private Tuple columnToTuple(IColumn col, CfDef cfDef, AbstractType comparator) throws IOException
|
||||
|
|
|
|||
Loading…
Reference in New Issue