private void storeData() { services.getTransactionManager().runTaskThrowOnConflict(txn -> { Map<Cell, byte[]> values = new HashMap<>(NUM_ROWS * NUM_COLS_PER_ROW); for (int i = 0; i < NUM_ROWS; i++) { for (int j = 0; j < NUM_COLS_PER_ROW; j++) { values.put(cell(i, j), Ints.toByteArray(i * NUM_COLS_PER_ROW + j)); } } txn.put(this.tableRef, values); return null; }); }
protected void storeData() { services.getTransactionManager().runTaskThrowOnConflict(txn -> { Map<Cell, byte[]> values = Maps.newHashMap(); allCellsAtMaxTimestamp = Maps.newHashMap(); firstCellAtMaxTimestamp = Maps.newHashMap(); firstCellAtMaxTimestamp.put(cell(0), Long.MAX_VALUE); for (int i = 0; i < getNumCols(); i++) { Cell curCell = cell(i); values.put(curCell, Ints.toByteArray(i)); allCellsAtMaxTimestamp.put(curCell, Long.MAX_VALUE); } txn.put(this.tableRef, values); return null; }); }
private void writeCommittedValues() { List<Cell> committedCells = getCells(getNumColsCommitted(), CellType.COMMITTED); List<Cell> committedWithNewerUncommitted = getCells(getNumColsCommittedAndNewerUncommitted(), CellType.COMMITTED_AND_NEWER_UNCOMMITTED); services.getTransactionManager().runTaskThrowOnConflict(txn -> { Map<Cell, byte[]> values = Maps.newHashMap(); allCellsAtMaxTimestamp = Maps.newHashMap(); for (Cell cell : Iterables.concat(committedCells, committedWithNewerUncommitted)) { allCellsAtMaxTimestamp.put(cell, Long.MAX_VALUE); values.put(cell, DUMMY_VALUE); } txn.put(this.tableRef, values); return null; }); }
private void storeData() { services.getTransactionManager().runTaskThrowOnConflict(txn -> { Map<Cell, byte[]> values = new HashMap<>(numRows * numColumnsPerRow); for (int i = 0; i < numRows; i++) { for (int j = 0; j < numColumnsPerRow; j++) { values.put(cell(i, j), Ints.toByteArray(i * numColumnsPerRow + j)); } } txn.put(getTableRef(), values); return null; }); }
private void checkKvs(AtlasDbServices services, int numTables, int numEntriesPerTable) { for (int i = 0; i < numTables; i++) { TableReference table = getTableRef(i); services.getTransactionManager().runTaskThrowOnConflict(t -> { ImmutableSet.Builder<Cell> toRead = ImmutableSet.builder(); ImmutableMap.Builder<Cell, byte[]> expectedBuilder = ImmutableMap.builder(); for (int j = 0; j < numEntriesPerTable; j++) { Cell cell = Cell.create(PtBytes.toBytes("row" + j), PtBytes.toBytes("col")); toRead.add(cell); expectedBuilder.put(cell, PtBytes.toBytes("val" + j)); } Map<Cell, byte[]> expected = expectedBuilder.build(); Map<Cell, byte[]> result = t.get(table, expected.keySet()); Assert.assertEquals(expected.keySet(), result.keySet()); for (Entry<Cell, byte[]> e : result.entrySet()) { Assert.assertArrayEquals(expected.get(e.getKey()), e.getValue()); } return null; }); } }
private void seedKvs(AtlasDbServices services, int numTables, int numEntriesPerTable) { for (int i = 0; i < numTables; i++) { TableReference table = getTableRef(i); services.getKeyValueService().createTable(table, AtlasDbConstants.GENERIC_TABLE_METADATA); services.getTransactionManager().runTaskThrowOnConflict(t -> { ImmutableMap.Builder<Cell, byte[]> toWrite = ImmutableMap.builder(); for (int j = 0; j < numEntriesPerTable; j++) { Cell cell = Cell.create(PtBytes.toBytes("row" + j), PtBytes.toBytes("col")); toWrite.put(cell, PtBytes.toBytes("val" + j)); } t.put(table, toWrite.build()); return null; }); } }