I am using Voldemort to store my data. My key is a word and values are number of occurrence of the word and the URL. For example:
key :question
value: 10, www.stackoverflow.com
I am using string[]
to pass the values. But while I was trying to use client.put ("xxxx", valuePair);
, I am getting java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String.
My code looks like this
public class ClientExample {
public static void main (String [] args) {
String bootstrapUrl = "tcp://localhost:6666";
ClientConfig cc = new ClientConfig ();
cc.setBootstrapUrls (bootstrapUrl);
String[] valuePair = new String[2];
int val = 1;
String value = new Integer(val).toString();
valuePair[0]=value;
valuePair[1] = "www.cnn.com";
System.out.println("Executed one");
StoreClientFactory factory = new SocketStoreClientFactory (cc);
StoreClient <String, String[]> client = factory.getStoreClient ("test");
System.out.println("Executed two");
client.put ("xxxx", valuePair);
System.out.println("Executed three");
String[] ans = client.getValue("key");
System.out.println("Executed four");
System.out.println ("value " +ans[0] +ans[1]);
System.out.println("Executed 5");
}
}