use of java.util.RandomAccess in project hbase by apache.
the class HRegion method addFamilyMapToWALEdit.
/**
* Append the given map of family->edits to a WALEdit data structure.
* This does not write to the WAL itself.
* @param familyMap map of family->edits
* @param walEdit the destination entry to append into
*/
private void addFamilyMapToWALEdit(Map<byte[], List<Cell>> familyMap, WALEdit walEdit) {
for (List<Cell> edits : familyMap.values()) {
assert edits instanceof RandomAccess;
int listSize = edits.size();
for (int i = 0; i < listSize; i++) {
Cell cell = edits.get(i);
walEdit.add(cell);
}
}
}
use of java.util.RandomAccess in project hbase by apache.
the class HRegion method prepareDeleteTimestamps.
@Override
public void prepareDeleteTimestamps(Mutation mutation, Map<byte[], List<Cell>> familyMap, byte[] byteNow) throws IOException {
for (Map.Entry<byte[], List<Cell>> e : familyMap.entrySet()) {
byte[] family = e.getKey();
List<Cell> cells = e.getValue();
assert cells instanceof RandomAccess;
Map<byte[], Integer> kvCount = new TreeMap<>(Bytes.BYTES_COMPARATOR);
int listSize = cells.size();
for (int i = 0; i < listSize; i++) {
Cell cell = cells.get(i);
// This is expensive.
if (cell.getTimestamp() == HConstants.LATEST_TIMESTAMP && CellUtil.isDeleteType(cell)) {
byte[] qual = CellUtil.cloneQualifier(cell);
if (qual == null)
qual = HConstants.EMPTY_BYTE_ARRAY;
Integer count = kvCount.get(qual);
if (count == null) {
kvCount.put(qual, 1);
} else {
kvCount.put(qual, count + 1);
}
count = kvCount.get(qual);
Get get = new Get(CellUtil.cloneRow(cell));
get.setMaxVersions(count);
get.addColumn(family, qual);
if (coprocessorHost != null) {
if (!coprocessorHost.prePrepareTimeStampForDeleteVersion(mutation, cell, byteNow, get)) {
updateDeleteLatestVersionTimeStamp(cell, get, count, byteNow);
}
} else {
updateDeleteLatestVersionTimeStamp(cell, get, count, byteNow);
}
} else {
CellUtil.updateLatestStamp(cell, byteNow, 0);
}
}
}
}
use of java.util.RandomAccess in project hbase by apache.
the class HRegion method recordMutationWithoutWal.
/**
* Update LongAdders for number of puts without wal and the size of possible data loss.
* These information are exposed by the region server metrics.
*/
private void recordMutationWithoutWal(final Map<byte[], List<Cell>> familyMap) {
numMutationsWithoutWAL.increment();
if (numMutationsWithoutWAL.sum() <= 1) {
LOG.info("writing data to region " + this + " with WAL disabled. Data may be lost in the event of a crash.");
}
long mutationSize = 0;
for (List<Cell> cells : familyMap.values()) {
assert cells instanceof RandomAccess;
int listSize = cells.size();
for (int i = 0; i < listSize; i++) {
Cell cell = cells.get(i);
mutationSize += KeyValueUtil.length(cell);
}
}
dataInMemoryWithoutWAL.add(mutationSize);
}
use of java.util.RandomAccess in project robovm by robovm.
the class AbstractListTest method test_subListII.
/**
* java.util.AbstractList#subList(int, int)
*/
public void test_subListII() {
// Test each of the SubList operations to ensure a
// ConcurrentModificationException does not occur on an AbstractList
// which does not update modCount
SimpleList mList = new SimpleList();
mList.add(new Object());
mList.add(new Object());
List sList = mList.subList(0, 2);
// calls add(int, Object)
sList.add(new Object());
sList.get(0);
sList.add(0, new Object());
sList.get(0);
sList.addAll(Arrays.asList(new String[] { "1", "2" }));
sList.get(0);
sList.addAll(0, Arrays.asList(new String[] { "3", "4" }));
sList.get(0);
sList.remove(0);
sList.get(0);
ListIterator lit = sList.listIterator();
lit.add(new Object());
lit.next();
lit.remove();
lit.next();
// calls removeRange()
sList.clear();
sList.add(new Object());
// test the type of sublist that is returned
List al = new ArrayList();
for (int i = 0; i < 10; i++) {
al.add(new Integer(i));
}
assertTrue("Sublist returned should have implemented Random Access interface", al.subList(3, 7) instanceof RandomAccess);
List ll = new LinkedList();
for (int i = 0; i < 10; i++) {
ll.add(new Integer(i));
}
assertTrue("Sublist returned should not have implemented Random Access interface", !(ll.subList(3, 7) instanceof RandomAccess));
}
use of java.util.RandomAccess in project dagger by square.
the class InjectionTest method noJitBindingsForInterfaces.
@Test
public void noJitBindingsForInterfaces() {
class TestEntryPoint {
@Inject
RandomAccess randomAccess;
}
@Module(injects = TestEntryPoint.class)
class TestModule {
}
ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
try {
graph.validate();
fail();
} catch (IllegalStateException expected) {
}
}
Aggregations