Refine search
public void write(ImmutableBytesWritable key, Object value) throws IOException { Put put; if (value instanceof Put){ put = (Put)value; } else if (value instanceof PutWritable) { put = new Put(((PutWritable)value).getPut()); } else { throw new IllegalArgumentException("Illegal Argument " + (value == null ? "null" : value.getClass().getName())); } if(m_walEnabled) { put.setDurability(Durability.SYNC_WAL); } else { put.setDurability(Durability.SKIP_WAL); } m_table.mutate(put); }
private Put newPut(Durability durability) { Put p = new Put(ROW); p.addColumn(FAMILY, COL, COL); if (durability != null) { p.setDurability(durability); } return p; }
private static Put createPut(final byte[][] families, final byte[] key, final byte[] value) { byte[] q = Bytes.toBytes("q"); Put put = new Put(key); put.setDurability(Durability.SKIP_WAL); for (byte[] family: families) { put.addColumn(family, q, value); } return put; }
Put put = new Put(rowKey); put.setDurability(durability); for (ColumnList.Column col : cols.getColumns()) { if (col.getTs() > 0) { put.add( col.getFamily(), col.getQualifier(), ); } else { put.add( col.getFamily(), col.getQualifier(), mutations.add(new Put(rowKey));
private static Put createPut(final byte[][] families, final byte[] key, final byte[] value) { byte[] q = Bytes.toBytes("q"); Put put = new Put(key); put.setDurability(Durability.SKIP_WAL); for (byte[] family: families) { put.addColumn(family, q, value); } return put; }
Delete delete = new Delete(row); addAttributes(delete, attributes); Put put = new Put(row, timestamp); addAttributes(put, attributes); for (Mutation m : mutations) { put.add(builder.clear() .setRow(put.getRow()) .setFamily(famAndQf[0]) throw new IllegalArgumentException("Invalid famAndQf provided."); put.setDurability(m.writeToWAL ? Durability.SYNC_WAL : Durability.SKIP_WAL);
public static void put(final Table loader, final byte [] bytes, final long ts) throws IOException { Put put = new Put(ROW, ts); put.setDurability(Durability.SKIP_WAL); put.addColumn(FAMILY_NAME, QUALIFIER_NAME, bytes); loader.put(put); }
/** * Writes an action (Put or Delete) to the specified table. * * @param tableName * the table being updated. * @param action * the update, either a put or a delete. * @throws IllegalArgumentException * if the action is not a put or a delete. */ @Override public void write(ImmutableBytesWritable tableName, Mutation action) throws IOException { BufferedMutator mutator = getBufferedMutator(tableName); // The actions are not immutable, so we defensively copy them if (action instanceof Put) { Put put = new Put((Put) action); put.setDurability(useWriteAheadLogging ? Durability.SYNC_WAL : Durability.SKIP_WAL); mutator.mutate(put); } else if (action instanceof Delete) { Delete delete = new Delete((Delete) action); mutator.mutate(delete); } else throw new IllegalArgumentException( "action must be either Delete or Put"); } }
private Put newPutWithSkipWAL() { Put put = new Put(Bytes.toBytes("row")); put.addColumn(CF, CQ, Bytes.toBytes("value")); put.setDurability(Durability.SKIP_WAL); return put; }
static int replayEdit(HRegion region, WAL.Entry entry) throws IOException { if (WALEdit.isMetaEditFamily(entry.getEdit().getCells().get(0))) { return 0; // handled elsewhere } Put put = new Put(CellUtil.cloneRow(entry.getEdit().getCells().get(0))); for (Cell cell : entry.getEdit().getCells()) put.add(cell); put.setDurability(Durability.SKIP_WAL); MutationReplay mutation = new MutationReplay(MutationType.PUT, put, 0, 0); region.batchReplay(new MutationReplay[] {mutation}, entry.getKey().getSequenceId()); return Integer.parseInt(Bytes.toString(put.getRow())); }
/** * Load table of multiple column families with rows from 'aaa' to 'zzz'. * @param t Table * @param f Array of Families to load * @param value the values of the cells. If null is passed, the row key is used as value * @return Count of rows loaded. * @throws IOException */ public int loadTable(final Table t, final byte[][] f, byte[] value, boolean writeToWAL) throws IOException { List<Put> puts = new ArrayList<>(); for (byte[] row : HBaseTestingUtility.ROWS) { Put put = new Put(row); put.setDurability(writeToWAL ? Durability.USE_DEFAULT : Durability.SKIP_WAL); for (int i = 0; i < f.length; i++) { byte[] value1 = value != null ? value : row; put.addColumn(f[i], f[i], value1); } puts.add(put); } t.put(puts); return puts.size(); }
public void loadTable(final Table table, int numRows) throws IOException { List<Put> puts = new ArrayList<>(numRows); for (int i = 0; i < numRows; ++i) { byte[] row = Bytes.toBytes(String.format("%09d", i)); Put put = new Put(row); put.setDurability(Durability.SKIP_WAL); put.addColumn(FAMILY_NAME, null, row); table.put(put); } }
try { table = getTable(tableName); Put put = new Put(getBytes(row), timestamp); addAttributes(put, attributes); + "over the whole column family."); } else { put.add(builder.clear() .setRow(put.getRow()) .setFamily(famAndQf[0]) .build()); put.setDurability(m.writeToWAL ? Durability.SYNC_WAL : Durability.SKIP_WAL);
static void writeTestDataBatch(TableName tableName, int batchId) throws Exception { LOG.debug("Writing test data batch " + batchId); List<Put> puts = new ArrayList<>(); for (int i = 0; i < NUM_ROWS_PER_BATCH; ++i) { Put put = new Put(getRowKey(batchId, i)); for (int j = 0; j < NUM_COLS_PER_ROW; ++j) { put.addColumn(CF_BYTES, getQualifier(j), getValue(batchId, i, j)); } put.setDurability(Durability.SKIP_WAL); puts.add(put); } try (Connection conn = ConnectionFactory.createConnection(conf); Table table = conn.getTable(tableName)) { table.put(puts); } }
protected static void loadTable(Table table) throws Exception { Put p; // 100 + 1 row to t1_syncup for (int i = 0; i < NB_ROWS_IN_BATCH; i++) { p = new Put(Bytes.toBytes("row" + i)); p.setDurability(Durability.SKIP_WAL); p.addColumn(famName, qualName, Bytes.toBytes("val" + i)); table.put(p); } }
Put put; try { put = new Put(getBytes(row), HConstants.LATEST_TIMESTAMP); addAttributes(put, attributes); put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY) .setRow(put.getRow()) .setFamily(famAndQf[0]) : HConstants.EMPTY_BYTE_ARRAY) .build()); put.setDurability(mput.writeToWAL ? Durability.SYNC_WAL : Durability.SKIP_WAL); } catch (IOException | IllegalArgumentException e) { LOG.warn(e.getMessage(), e);
@Test public void testMutationsWithoutWal() throws Exception { Put p = new Put(row).addColumn(cf, qualifier, val) .setDurability(Durability.SKIP_WAL); table.put(p); metricsRegionServer.getRegionServerWrapper().forceRecompute(); assertGauge("mutationsWithoutWALCount", 1); long minLength = row.length + cf.length + qualifier.length + val.length; metricsHelper.assertGaugeGt("mutationsWithoutWALSize", minLength, serverSource); }
private void putData(Region region, int startRow, int numRows, byte[] qf, byte[]... families) throws IOException { for (int i = startRow; i < startRow + numRows; i++) { Put put = new Put(Bytes.toBytes("" + i)); put.setDurability(Durability.SKIP_WAL); for (byte[] family : families) { put.addColumn(family, qf, null); } region.put(put); } }
assert type == MutationType.PUT: type.name(); long timestamp = proto.hasTimestamp()? proto.getTimestamp(): HConstants.LATEST_TIMESTAMP; Put put = proto.hasRow() ? new Put(proto.getRow().toByteArray(), timestamp) : null; int cellCount = proto.hasAssociatedCellCount()? proto.getAssociatedCellCount(): 0; if (cellCount > 0) { put = new Put(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), timestamp); put.add(cell); allTagsBytes = qv.getTags().toByteArray(); if(qv.hasDeleteType()) { put.add(cellBuilder.clear() .setRow(put.getRow()) .setFamily(family) .build()); } else { put.add(cellBuilder.clear() .setRow(put.getRow()) .setFamily(family) put.setDurability(toDurability(proto.getDurability())); for (NameBytesPair attribute: proto.getAttributeList()) { put.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
@Test public void testCheckAndMutateTimestampsAreMonotonic() throws IOException { region = initHRegion(tableName, method, CONF, fam1); ManualEnvironmentEdge edge = new ManualEnvironmentEdge(); EnvironmentEdgeManager.injectEdge(edge); edge.setValue(10); Put p = new Put(row); p.setDurability(Durability.SKIP_WAL); p.addColumn(fam1, qual1, qual1); region.put(p); Result result = region.get(new Get(row)); Cell c = result.getColumnLatestCell(fam1, qual1); assertNotNull(c); assertEquals(10L, c.getTimestamp()); edge.setValue(1); // clock goes back p = new Put(row); p.setDurability(Durability.SKIP_WAL); p.addColumn(fam1, qual1, qual2); region.checkAndMutate(row, fam1, qual1, CompareOperator.EQUAL, new BinaryComparator(qual1), p); result = region.get(new Get(row)); c = result.getColumnLatestCell(fam1, qual1); assertEquals(10L, c.getTimestamp()); assertTrue(Bytes.equals(c.getValueArray(), c.getValueOffset(), c.getValueLength(), qual2, 0, qual2.length)); }