Search in sources :

Example 1 with IntegerInterval

use of org.apache.cassandra.utils.IntegerInterval in project cassandra by apache.

the class CommitLogSegment method removeCleanFromDirty.

private void removeCleanFromDirty() {
    // if we're still allocating from this segment, don't touch anything since it can't be done thread-safely
    if (isStillAllocating())
        return;
    Iterator<Map.Entry<TableId, IntegerInterval.Set>> iter = tableClean.entrySet().iterator();
    while (iter.hasNext()) {
        Map.Entry<TableId, IntegerInterval.Set> clean = iter.next();
        TableId tableId = clean.getKey();
        IntegerInterval.Set cleanSet = clean.getValue();
        IntegerInterval dirtyInterval = tableDirty.get(tableId);
        if (dirtyInterval != null && cleanSet.covers(dirtyInterval)) {
            tableDirty.remove(tableId);
            iter.remove();
        }
    }
}
Also used : TableId(org.apache.cassandra.schema.TableId) IntegerInterval(org.apache.cassandra.utils.IntegerInterval) ConcurrentMap(java.util.concurrent.ConcurrentMap) NonBlockingHashMap(org.cliffc.high_scale_lib.NonBlockingHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 2 with IntegerInterval

use of org.apache.cassandra.utils.IntegerInterval in project cassandra by apache.

the class CommitLogSegment method getDirtyTableIds.

/**
     * @return a collection of dirty CFIDs for this segment file.
     */
public synchronized Collection<TableId> getDirtyTableIds() {
    if (tableClean.isEmpty() || tableDirty.isEmpty())
        return tableDirty.keySet();
    List<TableId> r = new ArrayList<>(tableDirty.size());
    for (Map.Entry<TableId, IntegerInterval> dirty : tableDirty.entrySet()) {
        TableId tableId = dirty.getKey();
        IntegerInterval dirtyInterval = dirty.getValue();
        IntegerInterval.Set cleanSet = tableClean.get(tableId);
        if (cleanSet == null || !cleanSet.covers(dirtyInterval))
            r.add(dirty.getKey());
    }
    return r;
}
Also used : TableId(org.apache.cassandra.schema.TableId) IntegerInterval(org.apache.cassandra.utils.IntegerInterval) ConcurrentMap(java.util.concurrent.ConcurrentMap) NonBlockingHashMap(org.cliffc.high_scale_lib.NonBlockingHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 3 with IntegerInterval

use of org.apache.cassandra.utils.IntegerInterval in project cassandra by apache.

the class CommitLogSegment method coverInMap.

public static <K> void coverInMap(ConcurrentMap<K, IntegerInterval> map, K key, int value) {
    IntegerInterval i = map.get(key);
    if (i == null) {
        i = map.putIfAbsent(key, new IntegerInterval(value, value));
        if (i == null)
            // success
            return;
    }
    i.expandToCover(value);
}
Also used : IntegerInterval(org.apache.cassandra.utils.IntegerInterval)

Aggregations

IntegerInterval (org.apache.cassandra.utils.IntegerInterval)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 TableId (org.apache.cassandra.schema.TableId)2 NonBlockingHashMap (org.cliffc.high_scale_lib.NonBlockingHashMap)2