Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am working on a project, using cassandra 1.2, hadoop 1.2

I have created my normal cassandra mapper and reducer, but I want to create my own Input format class, which will read the records from cassandra, and I'll get the desired column's value, by splitting that value using splitting and indexing , so, I planned to create custom Format class. but I'm confused and not able to know, how would I make it? What classes are to be extend and implement, and how I will able to fetch the row key, column name, columns value etc.

I have my Mapperclass as follow:

    public class MyMapper extends
            Mapper<ByteBuffer, SortedMap<ByteBuffer, IColumn>, Text, Text> {
        private Text word = new Text();
        MyJDBC db = new MyJDBC();

        public void map(ByteBuffer key, SortedMap<ByteBuffer, IColumn> columns,
                Context context) throws IOException, InterruptedException {

            long std_id = Long.parseLong(ByteBufferUtil.string(key));
            long newSavePoint = 0;
            if (columns.values().isEmpty()) {
            System.out.println("EMPTY ITERATOR");
            sb.append("column_N/A" + ":" + "N/A" + " , ");                  
            } else {
                for (IColumn cell : columns.values()) {
                    name = ByteBufferUtil.string(cell.name());
                    String value = null;
                    if (name.contains("int")) {
                    value = String.valueOf(ByteBufferUtil.toInt(cell.value()));
                    } else {
                    value = ByteBufferUtil.string(cell.value());
                    }
                String[] data = value.toString().split(",");
                // if (data[0].equalsIgnoreCase("login")) {
                    Long[] dif = getDateDiffe(d1, d2);

// logics i want to perform inside my custominput class , rather here, i just want a simple mapper class        
if (condition1 && condition2) {             
myhits++;
sb.append(":\t " + data[0] + "  " + data[2] + "  "+ data[1] /* + " " + data[3] */+ "\n");
newSavePoint = d2;
}
}
sb.append("~" + like + "~" + newSavePoint + "~");
word.set(sb.toString().replace("\t", ""));
}

db.setInterval(Long.parseLong(ByteBufferUtil.string(key)), newSavePoint);
db.setHits(Long.parseLong(ByteBufferUtil.string(key)), like + "");
context.write(new Text(ByteBufferUtil.string(key)), word);
}

I want to decrease my Mapper Class logics, and want to perform same calculations on my custom input class.

Please help, i wish for the positive r4esponse from stackies...

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.