2
嗨,我正在使用Voldemort來存儲我的數據。我的關鍵字是一個單詞,值是單詞和URL的出現次數。例如:如何在voldemort中傳遞sting數組
key :question
value: 10, www.stackoverflow.com
我正在使用string[]
來傳遞值。但是當我試圖使用client.put ("xxxx", valuePair);
時,我得到java.lang.ClassCastException:[Ljava.lang.String;不能轉換爲java.lang.String。 我的代碼看起來像這樣
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");
}
}
請幫我解決這個問題。提前致謝。