Created
February 27, 2012 21:25
-
-
Save jatrost/1927202 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package accumulo; | |
import java.util.Map.Entry; | |
import org.apache.accumulo.core.client.BatchWriter; | |
import org.apache.accumulo.core.client.Connector; | |
import org.apache.accumulo.core.client.Instance; | |
import org.apache.accumulo.core.client.Scanner; | |
import org.apache.accumulo.core.client.mock.MockInstance; | |
import org.apache.accumulo.core.data.Key; | |
import org.apache.accumulo.core.data.Mutation; | |
import org.apache.accumulo.core.data.Value; | |
import org.apache.accumulo.core.security.Authorizations; | |
public class Mock { | |
public static void main(String[] args) throws Exception { | |
String table = "data"; | |
String user = "root"; | |
Instance inst = new MockInstance("inst"); | |
Connector conn = inst.getConnector(user, "secret"); | |
conn.securityOperations().changeUserAuthorizations(user, new Authorizations("auth")); | |
Authorizations auths = conn.securityOperations().getUserAuthorizations(user); | |
conn.tableOperations().create(table); | |
System.out.println("Ingesting data ..."); | |
BatchWriter wr = conn.createBatchWriter(table, 10000000, 10000, 5); | |
for(int i = 0; i < 1000; ++i) | |
{ | |
Mutation m = new Mutation("row_"+i); | |
m.put("cf_"+i, "cq_"+1, "val_"+1); | |
wr.addMutation(m); | |
} | |
wr.close(); | |
System.out.println("Reading data ..."); | |
Scanner s = conn.createScanner(table, auths); | |
for(Entry<Key, Value> e : s) | |
{ | |
System.out.println(e); | |
} | |
System.out.println("Done"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment