Search in sources :

Example 1 with RandomAccess

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);
        }
    }
}
Also used : RandomAccess(java.util.RandomAccess) Cell(org.apache.hadoop.hbase.Cell)

Example 2 with RandomAccess

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);
            }
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Get(org.apache.hadoop.hbase.client.Get) RandomAccess(java.util.RandomAccess) ArrayList(java.util.ArrayList) AbstractList(java.util.AbstractList) List(java.util.List) TreeMap(java.util.TreeMap) Map(java.util.Map) TreeMap(java.util.TreeMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) NavigableMap(java.util.NavigableMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) Cell(org.apache.hadoop.hbase.Cell)

Example 3 with RandomAccess

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);
}
Also used : RandomAccess(java.util.RandomAccess) Cell(org.apache.hadoop.hbase.Cell)

Example 4 with RandomAccess

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));
}
Also used : ArrayList(java.util.ArrayList) RandomAccess(java.util.RandomAccess) List(java.util.List) AbstractList(java.util.AbstractList) LinkedList(java.util.LinkedList) ArrayList(java.util.ArrayList) ListIterator(java.util.ListIterator) LinkedList(java.util.LinkedList)

Example 5 with 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) {
    }
}
Also used : TestingLoader(dagger.internal.TestingLoader) RandomAccess(java.util.RandomAccess) Test(org.junit.Test)

Aggregations

RandomAccess (java.util.RandomAccess)14 List (java.util.List)9 ArrayList (java.util.ArrayList)8 LinkedList (java.util.LinkedList)5 ListIterator (java.util.ListIterator)5 Cell (org.apache.hadoop.hbase.Cell)5 AbstractList (java.util.AbstractList)4 Iterator (java.util.Iterator)3 Map (java.util.Map)3 HashMap (java.util.HashMap)2 NavigableMap (java.util.NavigableMap)2 TreeMap (java.util.TreeMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)2 Support_UnmodifiableCollectionTest (tests.support.Support_UnmodifiableCollectionTest)2 XmlScanner (com.android.tools.klint.detector.api.Detector.XmlScanner)1 TestingLoader (dagger.internal.TestingLoader)1 Closure (groovy.lang.Closure)1 ArrayDeque (java.util.ArrayDeque)1