• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RowIndexEntry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: firstKeyBeyond

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
/**
 * Finds and returns the first key beyond a given token in this SSTable or null if no such key exists.
 */
public DecoratedKey firstKeyBeyond(PartitionPosition token)
{
    if (token.compareTo(first) < 0)
        return first;

    long sampledPosition = getIndexScanPosition(token);

    if (ifile == null)
        return null;

    String path = null;
    try (FileDataInput in = ifile.createReader(sampledPosition))
    {
        path = in.getPath();
        while (!in.isEOF())
        {
            ByteBuffer indexKey = ByteBufferUtil.readWithShortLength(in);
            DecoratedKey indexDecoratedKey = decorateKey(indexKey);
            if (indexDecoratedKey.compareTo(token) > 0)
                return indexDecoratedKey;

            RowIndexEntry.Serializer.skip(in, descriptor.version);
        }
    }
    catch (IOException e)
    {
        markSuspect();
        throw new CorruptSSTableException(e, path);
    }

    return null;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:36,代码来源:SSTableReader.java


示例17: AbstractCType

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
protected AbstractCType(boolean isByteOrderComparable)
{
    reverseComparator = new Comparator<Composite>()
    {
        public int compare(Composite c1, Composite c2)
        {
            return AbstractCType.this.compare(c2, c1);
        }
    };
    indexComparator = new Comparator<IndexInfo>()
    {
        public int compare(IndexInfo o1, IndexInfo o2)
        {
            return AbstractCType.this.compare(o1.lastName, o2.lastName);
        }
    };
    indexReverseComparator = new Comparator<IndexInfo>()
    {
        public int compare(IndexInfo o1, IndexInfo o2)
        {
            return AbstractCType.this.compare(o1.firstName, o2.firstName);
        }
    };

    serializer = new Serializer(this);

    indexSerializer = new IndexInfo.Serializer(this);
    sliceSerializer = new ColumnSlice.Serializer(this);
    sliceQueryFilterSerializer = new SliceQueryFilter.Serializer(this);
    deletionInfoSerializer = new DeletionInfo.Serializer(this);
    rangeTombstoneSerializer = new RangeTombstone.Serializer(this);
    rowIndexEntrySerializer = new RowIndexEntry.Serializer(this);
    this.isByteOrderComparable = isByteOrderComparable;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:35,代码来源:AbstractCType.java


示例18: afterAppend

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

    if (logger.isTraceEnabled())
        logger.trace("wrote " + decoratedKey + " at " + dataEnd);
    iwriter.append(decoratedKey, index, dataEnd);
    dbuilder.addPotentialBoundary(dataEnd);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:14,代码来源:SSTableWriter.java


示例19: rawAppend

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
public static RowIndexEntry rawAppend(ColumnFamily cf, long startPosition, DecoratedKey key, DataOutputPlus out) throws IOException
{
    assert cf.hasColumns() || cf.isMarkedForDelete();

    ColumnIndex.Builder builder = new ColumnIndex.Builder(cf, key.getKey(), out);
    ColumnIndex index = builder.build(cf);

    out.writeShort(END_OF_ROW);
    return RowIndexEntry.create(startPosition, cf.deletionInfo().getTopLevelDeletion(), index);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:11,代码来源:SSTableWriter.java


示例20: firstKeyBeyond

import org.apache.cassandra.db.RowIndexEntry; //导入依赖的package包/类
/**
 * Finds and returns the first key beyond a given token in this SSTable or null if no such key exists.
 */
public DecoratedKey firstKeyBeyond(RowPosition token)
{
    if (token.compareTo(first) < 0)
        return first;

    long sampledPosition = getIndexScanPosition(token);

    Iterator<FileDataInput> segments = ifile.iterator(sampledPosition);
    while (segments.hasNext())
    {
        FileDataInput in = segments.next();
        try
        {
            while (!in.isEOF())
            {
                ByteBuffer indexKey = ByteBufferUtil.readWithShortLength(in);
                DecoratedKey indexDecoratedKey = partitioner.decorateKey(indexKey);
                if (indexDecoratedKey.compareTo(token) > 0)
                    return indexDecoratedKey;

                RowIndexEntry.Serializer.skip(in);
            }
        }
        catch (IOException e)
        {
            markSuspect();
            throw new CorruptSSTableException(e, in.getPath());
        }
        finally
        {
            FileUtils.closeQuietly(in);
        }
    }

    return null;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:40,代码来源:SSTableReader.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MessageNotWriteableException类代码示例发布时间:2022-05-22
下一篇:
Java NetworkUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap