Skip to content

Commit

Permalink
move null guard to where it's useful
Browse files Browse the repository at this point in the history
  • Loading branch information
mebigfatguy committed Dec 27, 2014
1 parent b53fefa commit 12b9691
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/java/org/apache/cassandra/hadoop/cql3/CqlRecordWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,27 @@ class CqlRecordWriter extends AbstractColumnFamilyRecordWriter<Map<String, ByteB
try
{
Cassandra.Client client = ConfigHelper.getClientFromOutputAddressList(conf);
client.set_keyspace(ConfigHelper.getOutputKeyspace(conf));
String user = ConfigHelper.getOutputKeyspaceUserName(conf);
String password = ConfigHelper.getOutputKeyspacePassword(conf);
if ((user != null) && (password != null))
AbstractColumnFamilyOutputFormat.login(user, password, client);
retrievePartitionKeyValidator(client);
String cqlQuery = CqlConfigHelper.getOutputCql(conf).trim();
if (cqlQuery.toLowerCase().startsWith("insert"))
throw new UnsupportedOperationException("INSERT with CqlRecordWriter is not supported, please use UPDATE/DELETE statement");
cql = appendKeyWhereClauses(cqlQuery);

if (client != null)
{
client.set_keyspace(ConfigHelper.getOutputKeyspace(conf));
String user = ConfigHelper.getOutputKeyspaceUserName(conf);
String password = ConfigHelper.getOutputKeyspacePassword(conf);
if ((user != null) && (password != null))
AbstractColumnFamilyOutputFormat.login(user, password, client);
retrievePartitionKeyValidator(client);
String cqlQuery = CqlConfigHelper.getOutputCql(conf).trim();
if (cqlQuery.toLowerCase().startsWith("insert"))
throw new UnsupportedOperationException("INSERT with CqlRecordWriter is not supported, please use UPDATE/DELETE statement");
cql = appendKeyWhereClauses(cqlQuery);

TTransport transport = client.getOutputProtocol().getTransport();
if (transport.isOpen())
transport.close();
}
else
{
throw new IllegalArgumentException("Invalid configuration specified " + conf);
}
}
catch (Exception e)
{
Expand Down

0 comments on commit 12b9691

Please sign in to comment.