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


Java RowIndexEntry类代码示例

本文整理汇总了Java中org.apache.cassandra.db.RowIndexEntry的典型用法代码示例。如果您正苦于以下问题:Java RowIndexEntry类的具体用法?Java RowIndexEntry怎么用?Java RowIndexEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: append

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
public void append(DecoratedKey key, RowIndexEntry indexEntry, long dataEnd, ByteBuffer indexInfo) throws IOException
{
    bf.add(key);
    long indexStart = indexFile.position();
    try
    {
        ByteBufferUtil.writeWithShortLength(key.getKey(), indexFile);
        rowIndexEntrySerializer.serialize(indexEntry, indexFile, indexInfo);
    }
    catch (IOException e)
    {
        throw new FSWriteError(e, indexFile.getPath());
    }
    long indexEnd = indexFile.position();

    if (logger.isTraceEnabled())
        logger.trace("wrote index entry: {} at {}", indexEntry, indexStart);

    summary.maybeAddEntry(key, indexStart, indexEnd, dataEnd);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:21,代码来源:BigTableWriter.java

示例2: append

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
/**
 * @param row
 * @return null if the row was compacted away entirely; otherwise, the PK index entry for this row
 */
public RowIndexEntry append(AbstractCompactedRow row)
{
    long startPosition = beforeAppend(row.key);
    RowIndexEntry entry;
    try
    {
        entry = row.write(startPosition, dataFile.stream);
        if (entry == null)
            return null;
    }
    catch (IOException e)
    {
        throw new FSWriteError(e, dataFile.getPath());
    }
    long endPosition = dataFile.getFilePointer();
    sstableMetadataCollector.update(endPosition - startPosition, row.columnStats());
    afterAppend(row.key, endPosition, entry);
    return entry;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:24,代码来源:SSTableWriter.java

示例3: buildSummaryAtLevel

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
private IndexSummary buildSummaryAtLevel(int newSamplingLevel) throws IOException
{
    // we read the positions in a BRAF so we don't have to worry about an entry spanning a mmap boundary.
    RandomAccessReader primaryIndex = RandomAccessReader.open(new File(descriptor.filenameFor(Component.PRIMARY_INDEX)));
    try
    {
        long indexSize = primaryIndex.length();
        try (IndexSummaryBuilder summaryBuilder = new IndexSummaryBuilder(estimatedKeys(), metadata.getMinIndexInterval(), newSamplingLevel))
        {
            long indexPosition;
            while ((indexPosition = primaryIndex.getFilePointer()) != indexSize)
            {
                summaryBuilder.maybeAddEntry(partitioner.decorateKey(ByteBufferUtil.readWithShortLength(primaryIndex)), indexPosition);
                RowIndexEntry.Serializer.skip(primaryIndex);
            }

            return summaryBuilder.build(partitioner);
        }
    }
    finally
    {
        FileUtils.closeQuietly(primaryIndex);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:SSTableReader.java

示例4: getCachedPosition

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
private RowIndexEntry getCachedPosition(KeyCacheKey unifiedKey, boolean updateStats)
{
    if (keyCache != null && keyCache.getCapacity() > 0) {
        if (updateStats)
        {
            RowIndexEntry cachedEntry = keyCache.get(unifiedKey);
            keyCacheRequest.incrementAndGet();
            if (cachedEntry != null)
            {
                keyCacheHit.incrementAndGet();
                bloomFilterTracker.addTruePositive();
            }
            return cachedEntry;
        }
        else
        {
            return keyCache.getInternal(unifiedKey);
        }
    }
    return null;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:SSTableReader.java

示例5: initKeyCache

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
/**
 * @return auto saving cache object
 */
private AutoSavingCache<KeyCacheKey, RowIndexEntry> initKeyCache()
{
    logger.info("Initializing key cache with capacity of {} MBs.", DatabaseDescriptor.getKeyCacheSizeInMB());

    long keyCacheInMemoryCapacity = DatabaseDescriptor.getKeyCacheSizeInMB() * 1024 * 1024;

    // as values are constant size we can use singleton weigher
    // where 48 = 40 bytes (average size of the key) + 8 bytes (size of value)
    ICache<KeyCacheKey, RowIndexEntry> kc;
    kc = ConcurrentLinkedHashCache.create(keyCacheInMemoryCapacity);
    AutoSavingCache<KeyCacheKey, RowIndexEntry> keyCache = new AutoSavingCache<KeyCacheKey, RowIndexEntry>(kc, CacheType.KEY_CACHE, new KeyCacheSerializer());

    int keyCacheKeysToSave = DatabaseDescriptor.getKeyCacheKeysToSave();

    logger.info("Scheduling key cache save to each {} seconds (going to save {} keys).",
            DatabaseDescriptor.getKeyCacheSavePeriod(),
                keyCacheKeysToSave == Integer.MAX_VALUE ? "all" : keyCacheKeysToSave);

    keyCache.scheduleSaving(DatabaseDescriptor.getKeyCacheSavePeriod(), keyCacheKeysToSave);

    return keyCache;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:26,代码来源:CacheService.java

示例6: realAppend

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
@Override
@SuppressWarnings("resource")
public boolean realAppend(UnfilteredRowIterator partition)
{
    long posBefore = sstableWriter.currentWriter().getOnDiskFilePointer();
    RowIndexEntry rie = sstableWriter.append(partition);
    totalWrittenInLevel += sstableWriter.currentWriter().getOnDiskFilePointer() - posBefore;
    partitionsWritten++;
    if (sstableWriter.currentWriter().getOnDiskFilePointer() > maxSSTableSize)
    {
        if (totalWrittenInLevel > LeveledManifest.maxBytesForLevel(currentLevel, maxSSTableSize))
        {
            totalWrittenInLevel = 0;
            currentLevel++;
        }

        averageEstimatedKeysPerSSTable = Math.round(((double) averageEstimatedKeysPerSSTable * sstablesWritten + partitionsWritten) / (sstablesWritten + 1));
        switchCompactionLocation(getWriteDirectory(expectedWriteSize));
        partitionsWritten = 0;
        sstablesWritten++;
    }
    return rie != null;

}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:MajorLeveledCompactionWriter.java

示例7: append

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
public RowIndexEntry append(UnfilteredRowIterator partition)
{
    // we do this before appending to ensure we can resetAndTruncate() safely if the append fails
    DecoratedKey key = partition.partitionKey();
    maybeReopenEarly(key);
    RowIndexEntry index = writer.append(partition);
    if (!isOffline && index != null)
    {
        boolean save = false;
        for (SSTableReader reader : transaction.originals())
        {
            if (reader.getCachedPosition(key, false) != null)
            {
                save = true;
                break;
            }
        }
        if (save)
            cachedKeys.put(key, index);
    }
    return index;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:SSTableRewriter.java

示例8: computeNext

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
protected DecoratedKey computeNext()
{
    try
    {
        if (in.isEOF())
            return endOfData();

        DecoratedKey key = partitioner.decorateKey(ByteBufferUtil.readWithShortLength(in.get()));
        RowIndexEntry.Serializer.skip(in.get(), desc.version); // skip remainder of the entry
        return key;
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:KeyIterator.java

示例9: append

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
/**
 * @param row
 * @return null if the row was compacted away entirely; otherwise, the PK index entry for this row
 */
public RowIndexEntry append(AbstractCompactedRow row)
{
    long currentPosition = beforeAppend(row.key);
    RowIndexEntry entry;
    try
    {
        entry = row.write(currentPosition, dataFile.stream);
        if (entry == null)
            return null;
    }
    catch (IOException e)
    {
        throw new FSWriteError(e, dataFile.getPath());
    }
    sstableMetadataCollector.update(dataFile.getFilePointer() - currentPosition, row.columnStats());
    afterAppend(row.key, currentPosition, entry);
    return entry;
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:23,代码来源:SSTableWriter.java

示例10: buildSummaryAtLevel

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
private IndexSummary buildSummaryAtLevel(int newSamplingLevel) throws IOException
{
    // we read the positions in a BRAF so we don't have to worry about an entry spanning a mmap boundary.
    RandomAccessReader primaryIndex = RandomAccessReader.open(new File(descriptor.filenameFor(Component.PRIMARY_INDEX)));
    try
    {
        long indexSize = primaryIndex.length();
        IndexSummaryBuilder summaryBuilder = new IndexSummaryBuilder(estimatedKeys(), metadata.getMinIndexInterval(), newSamplingLevel);

        long indexPosition;
        while ((indexPosition = primaryIndex.getFilePointer()) != indexSize)
        {
            summaryBuilder.maybeAddEntry(partitioner.decorateKey(ByteBufferUtil.readWithShortLength(primaryIndex)), indexPosition);
            RowIndexEntry.Serializer.skip(primaryIndex);
        }

        return summaryBuilder.build(partitioner);
    }
    finally
    {
        FileUtils.closeQuietly(primaryIndex);
    }
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:24,代码来源:SSTableReader.java

示例11: getCachedPosition

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
private RowIndexEntry getCachedPosition(KeyCacheKey unifiedKey, boolean updateStats)
{
    if (keyCache != null && keyCache.getCapacity() > 0) {
        if (updateStats)
        {
            RowIndexEntry cachedEntry = keyCache.get(unifiedKey);
            keyCacheRequest.incrementAndGet();
            if (cachedEntry != null)
                keyCacheHit.incrementAndGet();
            return cachedEntry;
        }
        else
        {
            return keyCache.getInternal(unifiedKey);
        }
    }
    return null;
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:19,代码来源:SSTableReader.java

示例12: deserialize

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
public Future<Pair<KeyCacheKey, RowIndexEntry>> deserialize(DataInputStream input, ColumnFamilyStore cfs) throws IOException
{
    ByteBuffer key = ByteBufferUtil.readWithLength(input);
    int generation = input.readInt();
    SSTableReader reader = findDesc(generation, cfs.getSSTables());
    boolean promotedIndexes = input.readBoolean();
    if (reader == null)
    {
        if (promotedIndexes)
            RowIndexEntry.serializer.skip(input, Descriptor.Version.CURRENT);
        return null;
    }
    RowIndexEntry entry = promotedIndexes
                        ? RowIndexEntry.serializer.deserialize(input, reader.descriptor.version)
                        : reader.getPosition(reader.partitioner.decorateKey(key), Operator.EQ, false);
    return Futures.immediateFuture(Pair.create(new KeyCacheKey(reader.descriptor, key), entry));
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:18,代码来源:CacheService.java

示例13: preheat

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
public void preheat(Map<DecoratedKey, RowIndexEntry> cachedKeys) throws IOException
{
    RandomAccessFile f = new RandomAccessFile(getFilename(), "r");

    try
    {
        int fd = CLibrary.getfd(f.getFD());

        for (Map.Entry<DecoratedKey, RowIndexEntry> entry : cachedKeys.entrySet())
        {
            cacheKey(entry.getKey(), entry.getValue());

            // add to the cache but don't do actual preheating if we have it disabled in the config
            if (DatabaseDescriptor.shouldPreheatPageCache() && fd > 0)
                CLibrary.preheatPage(fd, entry.getValue().position);
        }
    }
    finally
    {
        FileUtils.closeQuietly(f);
    }
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:23,代码来源:SSTableReader.java

示例14: deserialize

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
public Future<Pair<KeyCacheKey, RowIndexEntry>> deserialize(DataInputStream input, ColumnFamilyStore cfs) throws IOException
{
    int keyLength = input.readInt();
    if (keyLength > FBUtilities.MAX_UNSIGNED_SHORT)
    {
        throw new IOException(String.format("Corrupted key cache. Key length of %d is longer than maximum of %d",
                                            keyLength, FBUtilities.MAX_UNSIGNED_SHORT));
    }
    ByteBuffer key = ByteBufferUtil.read(input, keyLength);
    int generation = input.readInt();
    SSTableReader reader = findDesc(generation, cfs.getSSTables());
    input.readBoolean(); // backwards compatibility for "promoted indexes" boolean
    if (reader == null)
    {
        RowIndexEntry.Serializer.skipPromotedIndex(input);
        return null;
    }
    RowIndexEntry entry = reader.metadata.comparator.rowIndexEntrySerializer().deserialize(input, reader.descriptor.version);
    return Futures.immediateFuture(Pair.create(new KeyCacheKey(cfs.metadata.cfId, reader.descriptor, key), entry));
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:21,代码来源:CacheService.java

示例15: afterAppend

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
private void afterAppend(DecoratedKey decoratedKey, long dataEnd, RowIndexEntry index, ByteBuffer indexInfo) throws IOException
{
    metadataCollector.addKey(decoratedKey.getKey());
    lastWrittenKey = decoratedKey;
    last = lastWrittenKey;
    if (first == null)
        first = lastWrittenKey;

    if (logger.isTraceEnabled())
        logger.trace("wrote {} at {}", decoratedKey, dataEnd);
    iwriter.append(decoratedKey, index, dataEnd, indexInfo);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:13,代码来源:BigTableWriter.java


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