private void fillTable(Connector conn, String table) throws Exception { BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig()); for (String row : ROWS) { Mutation m = new Mutation(row); m.put("cf", "cq", "value"); bw.addMutation(m); } bw.close(); } }
public static void writeMutations(final Connector connector, final String tableName, final Collection<Mutation> mutations) throws TableNotFoundException, MutationsRejectedException { final BatchWriter bw = connector.createBatchWriter(tableName, 10000l, 10000l, 4); for(final Mutation mutation : mutations) { bw.addMutation(mutation); } bw.flush(); bw.close(); } }
private void writeSomeData(Connector conn, String table, int rows, int cols) throws Exception { BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig()); for (int row = 0; row < rows; row++) { Mutation m = new Mutation(Integer.toString(row)); for (int col = 0; col < cols; col++) { String value = Integer.toString(col); m.put(value, "", value); } bw.addMutation(m); } bw.close(); }
private static void update(Connector c, Mutation m) throws TableNotFoundException, MutationsRejectedException { BatchWriter bw = c.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig()); bw.addMutation(m); bw.close(); }
private void writeFlush(Connector conn, String tablename, String row) throws Exception { BatchWriter bw = conn.createBatchWriter(tablename, new BatchWriterConfig()); Mutation m = new Mutation(row); m.put("", "", ""); bw.addMutation(m); bw.close(); conn.tableOperations().flush(tablename, null, null, true); }
private void writeFile(Connector conn, String tableName) throws Exception { BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig()); Mutation m = new Mutation("row"); m.put("cf", "cq", "value"); bw.addMutation(m); bw.close(); conn.tableOperations().flush(tableName, null, null, true); }
private void writeFlush(Connector conn, String tablename, String row) throws Exception { BatchWriter bw = conn.createBatchWriter(tablename, new BatchWriterConfig()); Mutation m = new Mutation(row); m.put("", "", ""); bw.addMutation(m); bw.close(); conn.tableOperations().flush(tablename, null, null, true); } }
private void writeData(Connector c, String table) throws TableNotFoundException, MutationsRejectedException { BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig()); try { Random rand = new Random(); for (int i = 0; i < 1000; i++) { Mutation m = new Mutation(String.format("%09x", rand.nextInt(100000 * 1000))); m.put("m", "order", "" + i); bw.addMutation(m); } } finally { bw.close(); } } }
void writeRandomValue(Connector c, String tableName, int size) throws Exception { Random rand = new Random(); byte data1[] = new byte[size]; rand.nextBytes(data1); BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig()); Mutation m1 = new Mutation("r" + rand.nextInt(909090)); m1.put("data", "bl0b", new Value(data1)); bw.addMutation(m1); bw.close(); c.tableOperations().flush(tableName, null, null, true); }
private void makeFile(Connector conn, String tablename) throws Exception { BatchWriter bw = conn.createBatchWriter(tablename, new BatchWriterConfig()); byte[] empty = {}; byte[] row = new byte[10]; r.nextBytes(row); Mutation m = new Mutation(row, 0, 10); m.put(empty, empty, empty); bw.addMutation(m); bw.flush(); bw.close(); conn.tableOperations().flush(tablename, null, null, true); }
private void writeSomeData(Connector conn, String table, int startRow, int rowCount, int startCol, int colCount) throws Exception { BatchWriterConfig config = new BatchWriterConfig(); config.setMaxMemory(10 * 1024 * 1024); BatchWriter bw = conn.createBatchWriter(table, config); for (int r = startRow; r < startRow + rowCount; r++) { Mutation m = new Mutation(Integer.toHexString(r)); for (int c = startCol; c < startCol + colCount; c++) { m.put("", Integer.toHexString(c), ""); } bw.addMutation(m); } bw.close(); }
private void writeTestMutation(Connector userC) throws TableNotFoundException, MutationsRejectedException { BatchWriter batchWriter = userC.createBatchWriter(tableName, new BatchWriterConfig()); Mutation m = new Mutation("1"); m.put(new Text("2"), new Text("3"), new Value("".getBytes())); batchWriter.addMutation(m); batchWriter.flush(); batchWriter.close(); }
private void writeSome(String tableName, int n, BatchWriterConfig cfg) throws Exception { Connector c = getConnector(); BatchWriter bw = c.createBatchWriter(tableName, cfg); for (int i = 0; i < n; i++) { Mutation m = new Mutation(i + ""); m.put("", "", ""); bw.addMutation(m); } bw.close(); }
private BatchWriter writeData(String table1, Connector c) throws TableNotFoundException, MutationsRejectedException { BatchWriter bw = c.createBatchWriter(table1, new BatchWriterConfig()); Mutation m1 = new Mutation("001"); m1.put("data", "x", "9"); m1.put("data", "y", "7"); Mutation m2 = new Mutation("008"); m2.put("data", "x", "3"); m2.put("data", "y", "4"); bw.addMutation(m1); bw.addMutation(m2); bw.flush(); return bw; }
private void insertData(String tableName, long ts) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, MutationsRejectedException { BatchWriter bw = getConnector().createBatchWriter(tableName, null); for (int i = 0; i < 10000; i++) { String row = String.format("%09d", i); Mutation m = new Mutation(new Text(row)); m.put(new Text("cf1"), new Text("cq1"), ts, new Value(Integer.toString(i).getBytes(UTF_8))); bw.addMutation(m); } bw.close(); }
private void insertData(String tableName, long ts) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { BatchWriter bw = getConnector().createBatchWriter(tableName, null); for (int i = 0; i < 10000; i++) { String row = String.format("%09d", i); Mutation m = new Mutation(new Text(row)); m.put(new Text("cf1"), new Text("cq1"), ts, new Value(("" + i).getBytes())); bw.addMutation(m); } bw.close(); }
private String seedMetadataTable(Connector connector, long time, int keyVersionNum) throws TableNotFoundException, MutationsRejectedException { Value emptyVal = new Value(); BatchWriter recordWriter = connector.createBatchWriter(metadataTableName, new BatchWriterConfig()); SimpleDateFormat dateFormat = new SimpleDateFormat(DateNormalizer.ISO_8601_FORMAT_STRING); String normalizedVersionNum = NumericalEncoder.encode(Integer.toString(keyVersionNum)); String dateString = dateFormat.format(new Date(time)); String rowID = "edge_key"; String columnFamily = "version"; String columnQualifier = normalizedVersionNum + "/" + dateString; Mutation m = new Mutation(rowID); m.put(new Text(columnFamily), new Text(columnQualifier), emptyVal); recordWriter.addMutation(m); recordWriter.close(); return dateString; }
private void writeData(String tableName, Connector conn) throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, MutationsRejectedException { TreeSet<Text> splits = new TreeSet<>(); for (int i = 1; i < 100; i++) { splits.add(new Text(String.format("%06d", i * 100))); } conn.tableOperations().create(tableName); conn.tableOperations().addSplits(tableName, splits); BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig()); for (int i = 0; i < 100; i++) { String row = String.format("%06d", i * 100 + 3); Mutation m = new Mutation(row); m.put("cf1", "cq1", "1"); bw.addMutation(m); } bw.close(); }
@Test public void testRealWrite() throws Exception { Connector c = getConnector(); c.tableOperations().create(TEST_TABLE); BatchWriter bw = c.createBatchWriter(TEST_TABLE, new BatchWriterConfig()); Mutation m = new Mutation("Key"); m.put("", "", ""); bw.addMutation(m); bw.close(); handleWriteTests(true); }
private void insertDefaultData(Connector c, String tableName) throws Exception { BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig()); Mutation m1 = new Mutation(new Text("row1")); mput(m1, "cf1", "cq1", "BASE", "v1"); mput(m1, "cf1", "cq2", "DEFLABEL", "v2"); mput(m1, "cf1", "cq3", "", "v3"); bw.addMutation(m1); bw.close(); }