<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>DataStax Support Forums &#187; Topic: Mapping composite column names on Hive</title>
		<link>http://www.datastax.com/support-forums/topic/mapping-composite-column-names-on-hive</link>
		<description>Software, Support, and Training for Apache Cassandra</description>
		<language>en-US</language>
		<pubDate>Fri, 24 May 2013 20:51:08 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.3</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.datastax.com/support-forums/search.php</link>
		</textInput>
		<atom:link href="http://www.datastax.com/support-forums/rss/topic/mapping-composite-column-names-on-hive" rel="self" type="application/rss+xml" />

		<item>
			<title>dipesh on "Mapping composite column names on Hive"</title>
			<link>http://www.datastax.com/support-forums/topic/mapping-composite-column-names-on-hive#post-9018</link>
			<pubDate>Thu, 14 Feb 2013 11:45:49 +0000</pubDate>
			<dc:creator>dipesh</dc:creator>
			<guid isPermaLink="false">9018@http://www.datastax.com/support-forums/</guid>
			<description>&#60;p&#62;If possible, can you please share a sample code for serializer and deserializer?&#60;br /&#62;
And/or provide necessary pointers that could help in that regard.&#60;/p&#62;
&#60;p&#62;Here is what I have, but not working.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;package com.cisco.iep.hive.plugins;

import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;

import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;

public class WriteCompositeLongString extends UDF{

	public BytesWritable evaluate(final LongWritable l, final Text s) {

		List&#38;lt;byte[]&#38;gt; b = new ArrayList&#38;lt;byte[]&#38;gt;(2);
		b.add(longWritableToByteArray(l));
		b.add(textToByteArray(s));

		return new BytesWritable(makeComposite(b));
	}

	private byte[] textToByteArray(Text s){
		if(s==null){
			return null;
		}
		return s.getBytes();
	}

	private byte[] longWritableToByteArray(final LongWritable l){
		if(l==null){
			return null;
		}
		return ByteBuffer.allocate(Long.SIZE).putLong(l.get()).array();
	}

	private byte[] makeComposite(final List&#38;lt;byte[]&#38;gt; b) {
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		for (int i = 0; i &#38;lt; b.size(); i++) {
			bos.write((byte) ((b.get(i).length &#38;gt;&#38;gt; (7 + 1)) &#38;amp; 0xFF));
			bos.write((byte) (b.get(i).length &#38;amp; 0xFF));
			for (int j = 0; j &#38;lt; b.get(i).length; j++) {
				bos.write(b.get(i)[j] &#38;amp; 0xFF);
			}
			bos.write((byte) 0);
		}
		return bos.toByteArray();
	}

}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Thanks in advance!!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pierantonio.merlino on "Mapping composite column names on Hive"</title>
			<link>http://www.datastax.com/support-forums/topic/mapping-composite-column-names-on-hive#post-7442</link>
			<pubDate>Thu, 08 Nov 2012 14:07:24 +0000</pubDate>
			<dc:creator>pierantonio.merlino</dc:creator>
			<guid isPermaLink="false">7442@http://www.datastax.com/support-forums/</guid>
			<description>&#60;p&#62;Thank you for the answer.&#60;br /&#62;
I solved the problem mapping the composite columns in to a struct in Hive and writing a custom serializer/deserializer.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Piotr Kołaczkowski on "Mapping composite column names on Hive"</title>
			<link>http://www.datastax.com/support-forums/topic/mapping-composite-column-names-on-hive#post-7159</link>
			<pubDate>Mon, 29 Oct 2012 09:37:26 +0000</pubDate>
			<dc:creator>Piotr Kołaczkowski</dc:creator>
			<guid isPermaLink="false">7159@http://www.datastax.com/support-forums/</guid>
			<description>&#60;p&#62;There is no dedicated support in Hive for composite columns. In wide-row mode, it scans each row sequentially and fetches each column to produce a triple (row-key, column-name, value). Outputting as triples is hardcoded. Anyway, this could make a nice feature-request.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pierantonio.merlino on "Mapping composite column names on Hive"</title>
			<link>http://www.datastax.com/support-forums/topic/mapping-composite-column-names-on-hive#post-6763</link>
			<pubDate>Thu, 04 Oct 2012 10:00:30 +0000</pubDate>
			<dc:creator>pierantonio.merlino</dc:creator>
			<guid isPermaLink="false">6763@http://www.datastax.com/support-forums/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
I've to map Cassandra columns families on Hive tables.&#60;br /&#62;
Since I've dynamic fields in Cassandra, I use the following string&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;CREATE EXTERNAL TABLE Table1
(keyName string, columnName string, value string)
STORED BY &#38;#039;org.apache.hadoop.hive.cassandra.CassandraStorageHandler&#38;#039;
WITH SERDEPROPERTIES (&#38;quot;cassandra.columns.mapping&#38;quot; = &#38;quot;:key,:column,:value&#38;quot; );&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;in order to create the external table on Hive. The result is a table where each row is as follows:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;rowName1 columnName1 value1&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;rowName2 columnName2 value2&#60;/code&#62;&#60;br /&#62;
...&#60;/p&#62;
&#60;p&#62;Since I use composite column names in Cassandra (Composite(columnNameA, columnNameB)), is it possible to map them into two different columns on Hive?&#60;br /&#62;
What I want is as follows:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;rowName1 columnNameA1 columnNameB1 value1&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;How can I map these columns on Hive?&#60;/p&#62;
&#60;p&#62;Thanks in advance.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
