当前位置: 首页>>代码示例>>Java>>正文


Java SSTableReader.estimatedKeys方法代码示例

本文整理汇总了Java中org.apache.cassandra.io.sstable.SSTableReader.estimatedKeys方法的典型用法代码示例。如果您正苦于以下问题:Java SSTableReader.estimatedKeys方法的具体用法?Java SSTableReader.estimatedKeys怎么用?Java SSTableReader.estimatedKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.io.sstable.SSTableReader的用法示例。


在下文中一共展示了SSTableReader.estimatedKeys方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSSTableMetadata

import org.apache.cassandra.io.sstable.SSTableReader; //导入方法依赖的package包/类
public List<SSTableMetadata> getSSTableMetadata(String ksName, String cfName) {
    ColumnFamilyStore cfStore = getStore(ksName, cfName);
    Collection<SSTableReader> tables = cfStore.getSSTables();
    List<SSTableMetadata> metaData = new ArrayList<>(tables.size());
    for (SSTableReader table : tables) {
        SSTableMetadata tableMetadata = new SSTableMetadata();
        File dataFile = new File(table.descriptor.filenameFor(Component.DATA));
        tableMetadata.filename = dataFile.getName();
        tableMetadata.generation = table.descriptor.generation;
        try {
            tableMetadata.fileTimestamp = Files.getLastModifiedTime(dataFile.toPath()).toMillis();
        } catch (IOException e) {
            tableMetadata.fileTimestamp = 0;
        }
        tableMetadata.minTimestamp = table.getMinTimestamp();
        tableMetadata.maxTimestamp = table.getMaxTimestamp();
        tableMetadata.diskLength = table.onDiskLength();
        tableMetadata.uncompressedLength = table.uncompressedLength();
        tableMetadata.keys = table.estimatedKeys();
        EstimatedHistogram rowSizeHistogram = table.getEstimatedRowSize();
        tableMetadata.maxRowSize = rowSizeHistogram.max();
        tableMetadata.avgRowSize = rowSizeHistogram.mean();
        EstimatedHistogram columnCountHistogram = table.getEstimatedColumnCount();
        tableMetadata.maxColumnCount = columnCountHistogram.max();
        tableMetadata.avgColumnCount = columnCountHistogram.mean();
        tableMetadata.droppableTombstones = table.getDroppableTombstonesBefore(Util.NOW_SECONDS - table.metadata.getGcGraceSeconds());
        tableMetadata.level = table.getSSTableLevel();
        tableMetadata.isRepaired = table.isRepaired();
        tableMetadata.repairedAt = table.getSSTableMetadata().repairedAt;
        metaData.add(tableMetadata);
    }
    return metaData;
}
 
开发者ID:instaclustr,项目名称:cassandra-sstable-tools,代码行数:34,代码来源:CassandraBackend.java

示例2: getSSTableMetadata

import org.apache.cassandra.io.sstable.SSTableReader; //导入方法依赖的package包/类
public List<SSTableMetadata> getSSTableMetadata(String ksName, String cfName) {
    ColumnFamilyStore cfStore = getStore(ksName, cfName);
    Collection<SSTableReader> tables = cfStore.getSSTables();
    List<SSTableMetadata> metaData = new ArrayList<>(tables.size());
    for (SSTableReader table : tables) {
        SSTableMetadata tableMetadata = new SSTableMetadata();
        File dataFile = new File(table.descriptor.filenameFor(Component.DATA));
        tableMetadata.filename = dataFile.getName();
        tableMetadata.generation = table.descriptor.generation;
        try {
            tableMetadata.fileTimestamp = Files.getLastModifiedTime(dataFile.toPath()).toMillis();
        } catch (IOException e) {
            tableMetadata.fileTimestamp = 0;
        }
        tableMetadata.minTimestamp = table.getMinTimestamp();
        tableMetadata.maxTimestamp = table.getMaxTimestamp();
        tableMetadata.diskLength = table.onDiskLength();
        tableMetadata.uncompressedLength = table.uncompressedLength();
        tableMetadata.keys = table.estimatedKeys();
        EstimatedHistogram rowSizeHistogram = table.getEstimatedRowSize();
        tableMetadata.maxRowSize = rowSizeHistogram.max();
        tableMetadata.avgRowSize = rowSizeHistogram.mean();
        EstimatedHistogram columnCountHistogram = table.getEstimatedColumnCount();
        tableMetadata.maxColumnCount = columnCountHistogram.max();
        tableMetadata.avgColumnCount = columnCountHistogram.mean();
        tableMetadata.droppableTombstones = table.getDroppableTombstonesBefore(Util.NOW_SECONDS - table.metadata.getGcGraceSeconds());
        tableMetadata.level = table.getSSTableLevel();
        tableMetadata.isRepaired = false;
        metaData.add(tableMetadata);
    }
    return metaData;
}
 
开发者ID:instaclustr,项目名称:cassandra-sstable-tools,代码行数:33,代码来源:CassandraBackend.java

示例3: estimatedKeys

import org.apache.cassandra.io.sstable.SSTableReader; //导入方法依赖的package包/类
public long estimatedKeys()
{
    long n = 0;
    for (SSTableReader sstable : getSSTables())
        n += sstable.estimatedKeys();
    return n;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:DataTracker.java

示例4: worthDroppingTombstones

import org.apache.cassandra.io.sstable.SSTableReader; //导入方法依赖的package包/类
/**
 * Check if given sstable is worth dropping tombstones at gcBefore.
 * Check is skipped if tombstone_compaction_interval time does not elapse since sstable creation and returns false.
 *
 * @param sstable SSTable to check
 * @param gcBefore time to drop tombstones
 * @return true if given sstable's tombstones are expected to be removed
 */
protected boolean worthDroppingTombstones(SSTableReader sstable, int gcBefore)
{
    // since we use estimations to calculate, there is a chance that compaction will not drop tombstones actually.
    // if that happens we will end up in infinite compaction loop, so first we check enough if enough time has
    // elapsed since SSTable created.
    if (System.currentTimeMillis() < sstable.getCreationTimeFor(Component.DATA) + tombstoneCompactionInterval * 1000)
       return false;

    double droppableRatio = sstable.getEstimatedDroppableTombstoneRatio(gcBefore);
    if (droppableRatio <= tombstoneThreshold)
        return false;

    //sstable range overlap check is disabled. See CASSANDRA-6563.
    if (uncheckedTombstoneCompaction)
        return true;

    Collection<SSTableReader> overlaps = cfs.getOverlappingSSTables(Collections.singleton(sstable));
    if (overlaps.isEmpty())
    {
        // there is no overlap, tombstones are safely droppable
        return true;
    }
    else if (CompactionController.getFullyExpiredSSTables(cfs, Collections.singleton(sstable), overlaps, gcBefore).size() > 0)
    {
        return true;
    }
    else
    {
        // what percentage of columns do we expect to compact outside of overlap?
        if (sstable.getIndexSummarySize() < 2)
        {
            // we have too few samples to estimate correct percentage
            return false;
        }
        // first, calculate estimated keys that do not overlap
        long keys = sstable.estimatedKeys();
        Set<Range<Token>> ranges = new HashSet<Range<Token>>(overlaps.size());
        for (SSTableReader overlap : overlaps)
            ranges.add(new Range<Token>(overlap.first.getToken(), overlap.last.getToken(), overlap.partitioner));
        long remainingKeys = keys - sstable.estimatedKeysForRanges(ranges);
        // next, calculate what percentage of columns we have within those keys
        long columns = sstable.getEstimatedColumnCount().mean() * remainingKeys;
        double remainingColumnsRatio = ((double) columns) / (sstable.getEstimatedColumnCount().count() * sstable.getEstimatedColumnCount().mean());

        // return if we still expect to have droppable tombstones in rest of columns
        return remainingColumnsRatio * droppableRatio > tombstoneThreshold;
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:57,代码来源:AbstractCompactionStrategy.java

示例5: hotness

import org.apache.cassandra.io.sstable.SSTableReader; //导入方法依赖的package包/类
/**
 * Returns the reads per second per key for this sstable, or 0.0 if the sstable has no read meter
 */
private static double hotness(SSTableReader sstr)
{
    // system tables don't have read meters, just use 0.0 for the hotness
    return sstr.getReadMeter() == null ? 0.0 : sstr.getReadMeter().twoHourRate() / sstr.estimatedKeys();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:9,代码来源:SizeTieredCompactionStrategy.java

示例6: worthDroppingTombstones

import org.apache.cassandra.io.sstable.SSTableReader; //导入方法依赖的package包/类
/**
 * Check if given sstable is worth dropping tombstones at gcBefore.
 * Check is skipped if tombstone_compaction_interval time does not elapse since sstable creation and returns false.
 *
 * @param sstable SSTable to check
 * @param gcBefore time to drop tombstones
 * @return true if given sstable's tombstones are expected to be removed
 */
protected boolean worthDroppingTombstones(SSTableReader sstable, int gcBefore)
{
    // since we use estimations to calculate, there is a chance that compaction will not drop tombstones actually.
    // if that happens we will end up in infinite compaction loop, so first we check enough if enough time has
    // elapsed since SSTable created.
    if (System.currentTimeMillis() < sstable.getCreationTimeFor(Component.DATA) + tombstoneCompactionInterval * 1000)
       return false;

    double droppableRatio = sstable.getEstimatedDroppableTombstoneRatio(gcBefore);
    if (droppableRatio <= tombstoneThreshold)
        return false;

    Set<SSTableReader> overlaps = cfs.getOverlappingSSTables(Collections.singleton(sstable));
    if (overlaps.isEmpty())
    {
        // there is no overlap, tombstones are safely droppable
        return true;
    }
    else if (CompactionController.getFullyExpiredSSTables(cfs, Collections.singleton(sstable), overlaps, gcBefore).size() > 0)
    {
        return true;
    }
    else
    {
        // what percentage of columns do we expect to compact outside of overlap?
        if (sstable.getKeySampleSize() < 2)
        {
            // we have too few samples to estimate correct percentage
            return false;
        }
        // first, calculate estimated keys that do not overlap
        long keys = sstable.estimatedKeys();
        Set<Range<Token>> ranges = new HashSet<Range<Token>>(overlaps.size());
        for (SSTableReader overlap : overlaps)
            ranges.add(new Range<Token>(overlap.first.token, overlap.last.token, overlap.partitioner));
        long remainingKeys = keys - sstable.estimatedKeysForRanges(ranges);
        // next, calculate what percentage of columns we have within those keys
        long columns = sstable.getEstimatedColumnCount().mean() * remainingKeys;
        double remainingColumnsRatio = ((double) columns) / (sstable.getEstimatedColumnCount().count() * sstable.getEstimatedColumnCount().mean());

        // return if we still expect to have droppable tombstones in rest of columns
        return remainingColumnsRatio * droppableRatio > tombstoneThreshold;
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:53,代码来源:AbstractCompactionStrategy.java


注:本文中的org.apache.cassandra.io.sstable.SSTableReader.estimatedKeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。