Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,10 @@ public class TestCompactingMemStore extends TestDefaultMemStore {
protected RegionServicesForStores regionServicesForStores;
protected HStore store;

//////////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////////
protected static byte[] makeQualifier(final int i1, final int i2) {
return Bytes.toBytes(Integer.toString(i1) + ";" + Integer.toString(i2));
}

@After
public void tearDown() throws Exception {
chunkCreator.clearChunksInPool();
super.tearDown();
}

@Override
Expand Down Expand Up @@ -851,6 +845,12 @@ public void testMagicCompaction3Buckets() throws IOException {
memstore.clearSnapshot(snapshot.getId());
}

@Override
@Test
public void testScan() throws IOException {
scanMemStore(memstore, 6635);
}

protected int addRowsByKeys(final AbstractMemStore hmc, String[] keys) {
byte[] fam = Bytes.toBytes("testfamily");
byte[] qf = Bytes.toBytes("testqualifier");
Expand Down Expand Up @@ -925,6 +925,5 @@ void initiateType(MemoryCompactionPolicy compactionType, Configuration conf)
throws IllegalArgumentIOException {
compactor.initiateCompactionStrategy(compactionType, conf, "CF_TEST");
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,17 @@ public static Object[] data() {
// Helpers
//////////////////////////////////////////////////////////////////////////////
public TestCompactingToCellFlatMapMemStore(String type) {
if (type == "CHUNK_MAP") {
toCellChunkMap = true;
} else {
toCellChunkMap = false;
}
toCellChunkMap = "CHUNK_MAP".equals(type);
}

@Override
public void tearDown() throws Exception {
chunkCreator.clearChunksInPool();
super.tearDown();
}

@Override
public void setUp() throws Exception {

compactingSetUp();
this.conf = HBaseConfiguration.create();

Expand Down Expand Up @@ -924,6 +920,12 @@ public void testBigCellSizeAfterInMemoryCompaction() throws IOException {
}
}

@Override
@Test
public void testScan() throws IOException {
scanMemStore(memstore, 915);
}

private long addRowsByKeysDataSize(final AbstractMemStore hmc, String[] keys) {
byte[] fam = Bytes.toBytes("testfamily");
byte[] qf = Bytes.toBytes("testqualifier");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.NavigableMap;
import java.util.Objects;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
Expand Down Expand Up @@ -63,6 +62,7 @@
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.FSTableDescriptors;
import org.apache.hadoop.hbase.wal.WALFactory;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
Expand Down Expand Up @@ -91,10 +91,10 @@ public class TestDefaultMemStore {
public TestName name = new TestName();
protected AbstractMemStore memstore;
protected static final int ROW_COUNT = 10;
protected static final int SCAN_ROW_COUNT = 25000;
protected static final int QUALIFIER_COUNT = ROW_COUNT;
protected static final byte[] FAMILY = Bytes.toBytes("column");
protected MultiVersionConcurrencyControl mvcc;
protected AtomicLong startSeqNum = new AtomicLong(0);
protected ChunkCreator chunkCreator;

private String getName() {
Expand All @@ -110,6 +110,11 @@ public void setUp() throws Exception {
this.memstore = new DefaultMemStore();
}

@After
public void tearDown() throws Exception {
this.memstore.close();
}

@AfterClass
public static void tearDownClass() throws Exception {
ChunkCreator.getInstance().clearChunkIds();
Expand Down Expand Up @@ -855,8 +860,8 @@ public void testRetainsDeleteFamily() throws IOException {
//////////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////////
private static byte[] makeQualifier(final int i1, final int i2) {
return Bytes.toBytes(Integer.toString(i1) + ";" + Integer.toString(i2));
protected static byte[] makeQualifier(final int i1, final int i2) {
return Bytes.toBytes(i1 + ";" + i2);
}

/**
Expand Down Expand Up @@ -1101,15 +1106,13 @@ private void isExpectedRowWithoutTimestamps(final int rowIndex, List<Cell> kvs)

private static void addRows(int count, final MemStore mem) {
long nanos = System.nanoTime();

for (int i = 0; i < count; i++) {
if (i % 1000 == 0) {

System.out.println(i + " Took for 1k usec: " + (System.nanoTime() - nanos) / 1000);
LOG.info("{} Took for 1k usec: {}", i, (System.nanoTime() - nanos) / 1000);
nanos = System.nanoTime();
}
long timestamp = System.currentTimeMillis();

long timestamp = System.currentTimeMillis();
for (int ii = 0; ii < QUALIFIER_COUNT; ii++) {
byte[] row = Bytes.toBytes(i);
byte[] qf = makeQualifier(i, ii);
Expand All @@ -1118,31 +1121,34 @@ private static void addRows(int count, final MemStore mem) {
}
}

static void doScan(MemStore ms, int iteration) throws IOException {
private static int doScan(MemStore ms, int iteration) throws IOException {
long nanos = System.nanoTime();
KeyValueScanner s = ms.getScanners(0).get(0);
s.seek(KeyValueUtil.createFirstOnRow(new byte[] {}));

System.out.println(iteration + " create/seek took: " + (System.nanoTime() - nanos) / 1000);
LOG.info("Iteration {} create/seek took: {}", iteration, (System.nanoTime() - nanos) / 1000);
int cnt = 0;
while (s.next() != null)
while (s.next() != null) {
++cnt;

System.out
.println(iteration + " took usec: " + (System.nanoTime() - nanos) / 1000 + " for: " + cnt);

}
LOG.info("Iteration {} took usec: {} for: {}", iteration, (System.nanoTime() - nanos) / 1000,
cnt);
return cnt;
}

public static void main(String[] args) throws IOException {
MemStore ms = new DefaultMemStore();

protected void scanMemStore(MemStore ms, int expectedCount) throws IOException {
long n1 = System.nanoTime();
addRows(25000, ms);
System.out.println("Took for insert: " + (System.nanoTime() - n1) / 1000);
addRows(SCAN_ROW_COUNT, ms);
LOG.info("Took for insert: {}", (System.nanoTime() - n1) / 1000);

System.out.println("foo");
for (int i = 0; i < 50; i++) {
int cnt = doScan(ms, i);
assertEquals(expectedCount, cnt);
}
}

for (int i = 0; i < 50; i++)
doScan(ms, i);
@Test
public void testScan() throws IOException {
scanMemStore(memstore, SCAN_ROW_COUNT * QUALIFIER_COUNT);
}
}