Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 76EDA106B9 for ; Wed, 25 Dec 2013 13:12:06 +0000 (UTC) Received: (qmail 73497 invoked by uid 500); 25 Dec 2013 13:12:02 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 73203 invoked by uid 500); 25 Dec 2013 13:11:52 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 73183 invoked by uid 99); 25 Dec 2013 13:11:50 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Dec 2013 13:11:50 +0000 Date: Wed, 25 Dec 2013 13:11:50 +0000 (UTC) From: "Yariv Amar (JIRA)" To: commits@cassandra.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (CASSANDRA-6526) CQLSSTableWriter addRow(Map values) does not work as documented. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Yariv Amar created CASSANDRA-6526: ------------------------------------- Summary: CQLSSTableWriter addRow(Map values) does not work as documented. Key: CASSANDRA-6526 URL: https://issues.apache.org/jira/browse/CASSANDRA-6526 Project: Cassandra Issue Type: Bug Components: Core Reporter: Yariv Amar Fix For: 2.0.4 There are 2 bugs in the method {code} addRow(Map values) {code} First issue is that the map must contain all the column names as keys in the map otherwise the addRow fails (with InvalidRequestException "Invalid number of arguments, expecting %d values but got %d"). Second Issue is that the keys in the map must be in lower-case otherwise they may not be found in the map, which will result in a NPE during decompose. h6. SUGGESTED SOLUTION: Fix the addRow method with: {code} public CQLSSTableWriter addRow(Map values) throws InvalidRequestException, IOException { int size = boundNames.size(); Map rawValues = new HashMap<>(size); for (int i = 0; i < size; i++) { ColumnSpecification spec = boundNames.get(i); String colName = spec.name.toString(); rawValues.put(colName, values.get(colName) == null ? null : ((AbstractType)spec.type).decompose(values.get(colName))); } return rawAddRow(rawValues); } {code} When creating the new Map for the insert we need to go over all columns and apply null to missing columns. Fix the method documentation add this line: {code} *

* Keys in the map must be in lower case, otherwise their value will be null. * {code} -- This message was sent by Atlassian JIRA (v6.1.5#6160)