Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.flipkart.hbaseobjectmapper;
 
 import  org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import  org.apache.hadoop.hbase.util.Bytes;
 
 import java.util.List;

Utility class
public class Util {
    
Converts a String to ImmutableBytesWritable object
    public static ImmutableBytesWritable strToIbw(String str) {
        return str == null ? null : new ImmutableBytesWritable(Bytes.toBytes(str));
    }

    
Converts a list of Strings to a list of ImmutableBytesWritable objects
    public static List<ImmutableBytesWritable> strToIbw(Iterable<StringstrList) {
        List<ImmutableBytesWritable> ibwList = new ArrayList<ImmutableBytesWritable>();
        for (String str : strList) {
            ibwList.add(strToIbw(str));
        }
        return ibwList;
    }

    
Converts an ImmutableBytesWritable object to String
    public static String ibwToStr(ImmutableBytesWritable ibw) {
        return ibw == null ? null : Bytes.toString(ibw.get());
    }
New to GrepCode? Check out our FAQ X