private static void loadDataToRegion(HRegion region, byte[] additionalFamily) throws IOException { for (int i = 0; i < ROWSIZE; i++) { Put put = new Put(ROWS[i]); for (int j = 0; j < QUALSIZE; j++) { put.add(makeKV(i, j)); // put additional family put.add(makeKV(i, j, additionalFamily)); } region.put(put); if (i == ROWSIZE / 3 || i == ROWSIZE * 2 / 3) { region.flush(true); } } }
@Test public void testScanLimitAndOffset() throws Exception { int storeLimit = 3; for (int r = 0; r < ROWS.length; r++) { put = new Put(ROWS[r]); for (int c = 0; c < FAMILIES.length; c++) { for (int q = 0; q < QUALIFIERS.length; q++) { KeyValue kv = new KeyValue(ROWS[r], FAMILIES[c], QUALIFIERS[q], 1, HTestConst.DEFAULT_VALUE_BYTES); put.add(kv); if (storeOffset <= q && q < storeOffset + storeLimit) { kvListExp.add(kv); region.put(put);
Assert.assertEquals(FaultyFileSystem.class, fs.getClass()); FaultyFileSystem ffs = (FaultyFileSystem)fs; HRegion region = null; Durability.SYNC_WAL, wal, COLUMN_FAMILY_BYTES); long size = region.getMemStoreDataSize(); Assert.assertEquals(0, size); Put p1 = new Put(row); p1.add(new KeyValue(row, COLUMN_FAMILY_BYTES, qual1, 1, (byte[])null)); region.put(p1); storeFlushCtx.prepare(); Put p2 = new Put(row); p2.add(new KeyValue(row, COLUMN_FAMILY_BYTES, qual2, 2, (byte[])null)); p2.add(new KeyValue(row, COLUMN_FAMILY_BYTES, qual3, 3, (byte[])null)); region.put(p2);
private static void testDataInMemoryWithoutWAL(HRegion region, Put originalPut, final Put addPut, long delta) throws IOException { final long initSize = region.getDataInMemoryWithoutWAL(); // save normalCPHost and replaced by mockedCPHost RegionCoprocessorHost normalCPHost = region.getCoprocessorHost(); RegionCoprocessorHost mockedCPHost = Mockito.mock(RegionCoprocessorHost.class); // Because the preBatchMutate returns void, we can't do usual Mockito when...then form. Must // do below format (from Mockito doc). Mockito.doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { MiniBatchOperationInProgress<Mutation> mb = invocation.getArgument(0); mb.addOperationsFromCP(0, new Mutation[]{addPut}); return null; } }).when(mockedCPHost).preBatchMutate(Mockito.isA(MiniBatchOperationInProgress.class)); region.setCoprocessorHost(mockedCPHost); region.put(originalPut); region.setCoprocessorHost(normalCPHost); final long finalSize = region.getDataInMemoryWithoutWAL(); assertEquals("finalSize:" + finalSize + ", initSize:" + initSize + ", delta:" + delta,finalSize, initSize + delta); }
/** * Create a new hfile in the passed region * @param region region to operate on * @param columnFamily family for which to add data * @throws IOException */ private void createHFileInRegion(HRegion region, byte[] columnFamily) throws IOException { // put one row in the region Put p = new Put(Bytes.toBytes("row")); p.addColumn(columnFamily, Bytes.toBytes("Qual"), Bytes.toBytes("v1")); region.put(p); // flush the region to make a store file region.flush(true); }
Assert.assertEquals(FaultyFileSystem.class, fs.getClass()); FaultyFileSystem ffs = (FaultyFileSystem)fs; HRegion region = null; COLUMN_FAMILY_BYTES); long size = region.getMemStoreDataSize(); Assert.assertEquals(0, size); Put p1 = new Put(row); p1.add(new KeyValue(row, COLUMN_FAMILY_BYTES, qual1, 1, (byte[]) null)); region.put(p1); final long sizeOfOnePut = region.getMemStoreDataSize(); Assert.assertEquals(sizeOfOnePut, region.getMemStoreDataSize()); Put p2 = new Put(row); p2.add(new KeyValue(row, COLUMN_FAMILY_BYTES, qual2, 2, (byte[])null)); p2.add(new KeyValue(row, COLUMN_FAMILY_BYTES, qual3, 3, (byte[])null)); region.put(p2); long expectedSize = sizeOfOnePut * 3; Assert.assertEquals(expectedSize, region.getMemStoreDataSize());
private void createStoreFile(int[] colIds) throws IOException { Put p = new Put(ROW_BYTES); for (int colId : colIds) { long ts = Long.MAX_VALUE; String qual = qualFromId(colId); allColIds.add(colId); KeyValue kv = KeyValueTestUtil.create(ROW, FAMILY, qual, ts, TestMultiColumnScanner.createValue(ROW, qual, ts)); p.add(kv); } region.put(p); region.flush(true); }
@Before public void setUp() throws Exception { TableDescriptor htd = TableDescriptorBuilder .newBuilder(TableName.valueOf("TestQualifierFilter")) .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILY).build()).build(); RegionInfo info = RegionInfoBuilder.newBuilder(htd.getTableName()).build(); this.region = HBaseTestingUtility .createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), TEST_UTIL.getConfiguration(), htd); // Insert data for (byte[] ROW : ROWS) { Put p = new Put(ROW); p.setDurability(Durability.SKIP_WAL); for (byte[] QUALIFIER : QUALIFIERS) { p.addColumn(FAMILY, QUALIFIER, VALUE); } this.region.put(p); } // Flush this.region.flush(true); }
private void putRows(HRegion r, int numRows, String value, String key) throws IOException { for (int i = 0; i < numRows; i++) { String row = key + "_" + i/* UUID.randomUUID().toString() */; System.out.println(String.format("Saving row: %s, with value %s", row, value)); Put put = new Put(Bytes.toBytes(row)); put.setDurability(Durability.SKIP_WAL); put.addColumn(Bytes.toBytes("trans-blob"), null, Bytes.toBytes("value for blob")); put.addColumn(Bytes.toBytes("trans-type"), null, Bytes.toBytes("statement")); put.addColumn(Bytes.toBytes("trans-date"), null, Bytes.toBytes("20090921010101999")); put.addColumn(Bytes.toBytes("trans-tags"), Bytes.toBytes("qual2"), Bytes.toBytes(value)); put.addColumn(Bytes.toBytes("trans-group"), null, Bytes.toBytes("adhocTransactionGroupId")); r.put(put); } }
private void writeTestData(HRegion region) throws IOException { for (int i = 0; i < NUM_ROWS; ++i) { Put put = new Put(Bytes.toBytes("row" + i)); for (int j = 0; j < NUM_COLS_PER_ROW; ++j) { for (long ts = 1; ts < NUM_TIMESTAMPS_PER_COL; ++ts) { put.addColumn(CF_BYTES, Bytes.toBytes("col" + j), ts, Bytes.toBytes("value" + i + "_" + j + "_" + ts)); } } region.put(put); if ((i + 1) % ROWS_PER_HFILE == 0) { region.flush(true); } } } }
@SuppressWarnings("deprecation") private void abort(byte[] startId, Integer lockId) throws IOException { Put put = new Put(startId); long startIdLong = DominoConst.getTidFromTMetaKey(startId); put.add(DominoConst.TRANSACTION_META_FAMILY, DominoConst.TRANSACTION_STATUS, startIdLong, DominoConst.TRX_ABORTED_B); region.put(put, lockId, true); }
static void putData(HRegion region, Durability durability, 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); for (byte[] family : families) { put.addColumn(family, qf, null); } region.put(put); LOG.info(put.toString()); } }
private static void loadDataToRegion(HRegion region, byte[] additionalFamily) throws IOException { for (int i = 0; i < ROWSIZE; i++) { Put put = new Put(ROWS[i]); for (int j = 0; j < QUALSIZE; j++) { put.add(makeKV(i, j)); // put additional family put.add(makeKV(i, j, additionalFamily)); } region.put(put); if (i == ROWSIZE / 3 || i == ROWSIZE * 2 / 3) { region.flush(true); } } }
private void putData(byte[] cf, String row, String col, long versionStart, long versionEnd) throws IOException { byte columnBytes[] = Bytes.toBytes(col); Put put = new Put(Bytes.toBytes(row)); put.setDurability(Durability.SKIP_WAL); for (long version = versionStart; version <= versionEnd; version++) { put.addColumn(cf, columnBytes, version, genValue(row, col, version)); } region.put(put); }
private void createStoreFile(int[] colIds) throws IOException { Put p = new Put(ROW_BYTES); for (int colId : colIds) { long ts = Long.MAX_VALUE; String qual = qualFromId(colId); allColIds.add(colId); KeyValue kv = KeyValueTestUtil.create(ROW, FAMILY, qual, ts, TestMultiColumnScanner.createValue(ROW, qual, ts)); p.add(kv); } region.put(p); region.flush(true); }
private int addWideContent(HRegion region) throws IOException { int count = 0; for (char c = 'a'; c <= 'c'; c++) { byte[] row = Bytes.toBytes("ab" + c); int i, j; long ts = System.currentTimeMillis(); for (i = 0; i < 100; i++) { byte[] b = Bytes.toBytes(String.format("%10d", i)); for (j = 0; j < 100; j++) { Put put = new Put(row); put.setDurability(Durability.SKIP_WAL); long ts1 = ++ts; put.addColumn(COLUMNS[rng.nextInt(COLUMNS.length)], b, ts1, b); region.put(put); count++; } } } return count; }
/** * Test one put command. */ @Test public void testPut() throws IOException { LOG.info("Starting testPut"); this.region = initHRegion(tableName, getName(), fam1); long value = 1L; Put put = new Put(row); put.addColumn(fam1, qual1, Bytes.toBytes(value)); region.put(put); assertGet(this.region, row, fam1, qual1, Bytes.toBytes(value)); }