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


Java SSTableIdentityIterator类代码示例

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


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

示例1: getCompactedRow

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
/**
 * @return an AbstractCompactedRow implementation to write the merged rows in question.
 *
 * If there is a single source row, the data is from a current-version sstable, we don't
 * need to purge and we aren't forcing deserialization for scrub, write it unchanged.
 * Otherwise, we deserialize, purge tombstones, and reserialize in the latest version.
 */
public AbstractCompactedRow getCompactedRow(List<SSTableIdentityIterator> rows)
{
    long rowSize = 0;
    for (SSTableIdentityIterator row : rows)
        rowSize += row.dataSize;

    if (rowSize > DatabaseDescriptor.getInMemoryCompactionLimit())
    {
        String keyString = cfs.metadata.getKeyValidator().getString(rows.get(0).getKey().key);
        logger.info(String.format("Compacting large row %s/%s:%s (%d bytes) incrementally",
                                  cfs.keyspace.getName(), cfs.name, keyString, rowSize));
        return new LazilyCompactedRow(this, rows);
    }
    return new PrecompactedRow(this, rows);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:23,代码来源:CompactionController.java

示例2: merge

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
private static ColumnFamily merge(List<SSTableIdentityIterator> rows, CompactionController controller)
{
    assert !rows.isEmpty();

    final ColumnFamily returnCF = ArrayBackedSortedColumns.factory.create(controller.cfs.metadata);

    // transform into iterators that MergeIterator will like, and apply row-level tombstones
    List<CloseableIterator<Column>> data = new ArrayList<>(rows.size());
    for (SSTableIdentityIterator row : rows)
    {
        ColumnFamily cf = row.getColumnFamilyWithColumns(ArrayBackedSortedColumns.factory);
        returnCF.delete(cf);
        data.add(FBUtilities.closeableIterator(cf.iterator()));
    }

    merge(returnCF, data, controller.cfs.indexManager.updaterFor(rows.get(0).getKey()));

    return returnCF;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:PrecompactedRow.java

示例3: getCompactedRow

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
/**
 * @return an AbstractCompactedRow implementation to write the merged rows in question.
 *
 * If there is a single source row, the data is from a current-version sstable, we don't
 * need to purge and we aren't forcing deserialization for scrub, write it unchanged.
 * Otherwise, we deserialize, purge tombstones, and reserialize in the latest version.
 */
public AbstractCompactedRow getCompactedRow(List<SSTableIdentityIterator> rows)
{
    long rowSize = 0;
    for (SSTableIdentityIterator row : rows)
        rowSize += row.dataSize;

    if (rowSize > DatabaseDescriptor.getInMemoryCompactionLimit())
    {
        String keyString = cfs.metadata.getKeyValidator().getString(rows.get(0).getKey().key);
        logger.info(String.format("Compacting large row %s/%s:%s (%d bytes) incrementally",
                                  cfs.table.name, cfs.columnFamily, keyString, rowSize));
        return new LazilyCompactedRow(this, rows);
    }
    return new PrecompactedRow(this, rows);
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:23,代码来源:CompactionController.java

示例4: merge

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
private static ColumnFamily merge(List<SSTableIdentityIterator> rows, CompactionController controller)
{
    assert !rows.isEmpty();

    final ColumnFamily returnCF = ColumnFamily.create(controller.cfs.metadata, ArrayBackedSortedColumns.factory());

    // transform into iterators that MergeIterator will like, and apply row-level tombstones
    List<CloseableIterator<IColumn>> data = new ArrayList<CloseableIterator<IColumn>>(rows.size());
    for (SSTableIdentityIterator row : rows)
    {
        try
        {
            ColumnFamily cf = row.getColumnFamilyWithColumns(ArrayBackedSortedColumns.factory());
            returnCF.delete(cf);
            data.add(FBUtilities.closeableIterator(cf.iterator()));
        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
        }
    }

    merge(returnCF, data, controller.cfs.indexManager.updaterFor(rows.get(0).getKey()));

    return returnCF;
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:27,代码来源:PrecompactedRow.java

示例5: nextKeyValue

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
@Override
public boolean nextKeyValue() throws IOException, InterruptedException {

    if (!hasMore()) {
        return false;
    }

    // Read the key and set it.
    final ByteBuffer keyBytes = ByteBufferUtil.readWithShortLength(getReader());
    setCurrentKey(keyBytes);

    // Read the data size.
    // TODO: may have to take into account the fact that files can support long or int depending on Cassandra version.
    final long dataSize = getReader().readLong();

    // Read the value and set it.
    final SSTableIdentityIterator ssTableIdentityIterator = getIdentityIterator(keyBytes, dataSize);
    setCurrentValue(ssTableIdentityIterator);

    return true;
}
 
开发者ID:fullcontact,项目名称:hadoop-sstable,代码行数:22,代码来源:SSTableRowRecordReader.java

示例6: map

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void map(ByteBuffer key, SSTableIdentityIterator rowIter, Context context)
        throws IOException, InterruptedException {

    K1 mapKey = getMapperKey(key, context);
    if (mapKey == null) {
        return;
    }
    V1 mapValue = getMapperValue(rowIter, context);
    if (mapValue == null) {
        return;
    }
    this.rowIter = rowIter;
    this.key = key;
    performMapTask(mapKey, mapValue, context);
}
 
开发者ID:Knewton,项目名称:KassandraMRHelper,代码行数:20,代码来源:SSTableRowMapper.java

示例7: testMapWithNulls

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
/**
 * Tests to see that null keys and values do not make the mapper fail
 */
@Test
public void testMapWithNulls() throws Exception {
    underTest.map(null, null, null);
    assertNull(underTest.getCurrentKey());
    assertNull(underTest.getRowKey());
    assertNull(underTest.getCurrentRow());

    ByteBuffer key = ByteBuffer.wrap("testKey".getBytes());
    underTest.map(key, null, null);
    assertNull(underTest.getCurrentKey());
    assertNull(underTest.getRowKey());
    assertNull(underTest.getCurrentRow());

    SSTableIdentityIterator mockRowIter = mock(SSTableIdentityIterator.class);
    underTest.map(null, mockRowIter, null);
    assertNull(underTest.getCurrentKey());
    assertNull(underTest.getRowKey());
    assertNull(underTest.getCurrentRow());
}
 
开发者ID:Knewton,项目名称:KassandraMRHelper,代码行数:23,代码来源:SSTableRowMapperTest.java

示例8: getCompactedRow

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
/**
 * @return an AbstractCompactedRow implementation to write the merged rows in question.
 *
 * If there is a single source row, the data is from a current-version sstable, we don't
 * need to purge and we aren't forcing deserialization for scrub, write it unchanged.
 * Otherwise, we deserialize, purge tombstones, and reserialize in the latest version.
 */
public AbstractCompactedRow getCompactedRow(List<SSTableIdentityIterator> rows)
{
    if (rows.size() == 1 && !needDeserialize() && !shouldPurge(rows.get(0).getKey()))
        return new EchoedRow(this, rows.get(0));

    long rowSize = 0;
    for (SSTableIdentityIterator row : rows)
        rowSize += row.dataSize;

    if (rowSize > DatabaseDescriptor.getInMemoryCompactionLimit())
    {
        String keyString = cfs.metadata.getKeyValidator().getString(rows.get(0).getKey().key);
        logger.info(String.format("Compacting large row %s/%s:%s (%d bytes) incrementally",
                                  cfs.table.name, cfs.columnFamily, keyString, rowSize));
        return new LazilyCompactedRow(this, rows);
    }
    return new PrecompactedRow(this, rows);
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:26,代码来源:CompactionController.java

示例9: LazilyCompactedRow

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
public LazilyCompactedRow(CompactionController controller, List<SSTableIdentityIterator> rows)
{
    super(rows.get(0).getKey());
    this.rows = rows;
    this.controller = controller;
    this.shouldPurge = controller.shouldPurge(key);

    for (IColumnIterator row : rows)
    {
        ColumnFamily cf = row.getColumnFamily();

        if (emptyColumnFamily == null)
            emptyColumnFamily = cf;
        else
            emptyColumnFamily.delete(cf);
    }

    // initialize row header so isEmpty can be called
    headerBuffer = new DataOutputBuffer();
    ColumnIndexer.serialize(this, headerBuffer);
    // reach into iterator used by ColumnIndexer to get column count and size
    // (however, if there are zero columns, iterator() will not be called by ColumnIndexer and reducer will be null)
    columnCount = reducer == null ? 0 : reducer.size;
    columnSerializedSize = reducer == null ? 0 : reducer.serializedSize;
    reducer = null;
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:27,代码来源:LazilyCompactedRow.java

示例10: merge

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
private static ColumnFamily merge(List<SSTableIdentityIterator> rows)
{
    ColumnFamily cf = null;
    for (SSTableIdentityIterator row : rows)
    {
        ColumnFamily thisCF;
        try
        {
            thisCF = row.getColumnFamilyWithColumns();
        }
        catch (IOException e)
        {
            logger.error("Skipping row " + row.getKey() + " in " + row.getPath(), e);
            continue;
        }
        if (cf == null)
        {
            cf = thisCF;
        }
        else
        {
            cf.addAll(thisCF);
        }
    }
    return cf;
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:27,代码来源:PrecompactedRow.java

示例11: Deserializer

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
public Deserializer(ICompactionScanner ssts, final int maxInMemorySize)
{
    this.scanner = ssts;
    Runnable runnable = new WrappedRunnable()
    {
        protected void runMayThrow() throws Exception
        {
            SimpleCondition condition = null;
            while (true)
            {
                if (condition != null)
                {
                    condition.await();
                    condition = null;
                }
                if (!scanner.hasNext())
                {
                    queue.put(finished);
                    break;
                }

                SSTableIdentityIterator iter = (SSTableIdentityIterator) scanner.next();
                if (iter.dataSize > maxInMemorySize)
                {
                    logger.debug("parallel lazy deserialize from {}", iter.getPath());
                    condition = new SimpleCondition();
                    queue.put(new RowContainer(new NotifyingSSTableIdentityIterator(iter, condition)));
                }
                else
                {
                    logger.debug("parallel eager deserialize from {}", iter.getPath());
                    queue.put(new RowContainer(new Row(iter.getKey(), iter.getColumnFamilyWithColumns(ArrayBackedSortedColumns.factory))));
                }
            }
        }
    };
    new Thread(runnable, "Deserialize " + scanner.getBackingFiles()).start();
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:39,代码来源:ParallelCompactionIterable.java

示例12: cleanup

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
@Override
public SSTableIdentityIterator cleanup(SSTableIdentityIterator row)
{
    if (Range.isInRanges(row.getKey().getToken(), ranges))
        return row;

    cfs.invalidateCachedRow(row.getKey());

    if (indexedColumnsInRow != null)
        indexedColumnsInRow.clear();

    while (row.hasNext())
    {
        OnDiskAtom column = row.next();

        if (column instanceof Cell && cfs.indexManager.indexes((Cell) column))
        {
            if (indexedColumnsInRow == null)
                indexedColumnsInRow = new ArrayList<>();

            indexedColumnsInRow.add((Cell) column);
        }
    }

    if (indexedColumnsInRow != null && !indexedColumnsInRow.isEmpty())
    {
        // acquire memtable lock here because secondary index deletion may cause a race. See CASSANDRA-3712
        try (OpOrder.Group opGroup = cfs.keyspace.writeOrder.start())
        {
            cfs.indexManager.deleteFromIndexes(row.getKey(), indexedColumnsInRow, opGroup);
        }
    }
    return null;
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:35,代码来源:CompactionManager.java

示例13: Deserializer

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
public Deserializer(ICompactionScanner ssts, final int maxInMemorySize)
{
    this.scanner = ssts;
    Runnable runnable = new WrappedRunnable()
    {
        protected void runMayThrow() throws Exception
        {
            while (true)
            {
                if (condition != null)
                    condition.await();

                if (!scanner.hasNext())
                {
                    queue.put(finished);
                    break;
                }

                SSTableIdentityIterator iter = (SSTableIdentityIterator) scanner.next();
                if (iter.dataSize > maxInMemorySize)
                {
                    logger.debug("parallel lazy deserialize from " + iter.getPath());
                    condition = new SimpleCondition();
                    queue.put(new RowContainer(new NotifyingSSTableIdentityIterator(iter, condition)));
                }
                else
                {
                    logger.debug("parallel eager deserialize from " + iter.getPath());
                    queue.put(new RowContainer(new Row(iter.getKey(), iter.getColumnFamilyWithColumns(ArrayBackedSortedColumns.factory()))));
                }
            }
        }
    };
    new Thread(runnable, "Deserialize " + scanner.getBackingFiles()).start();
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:36,代码来源:ParallelCompactionIterable.java

示例14: cleanup

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
@Override
public SSTableIdentityIterator cleanup(SSTableIdentityIterator row)
{
    if (Range.isInRanges(row.getKey().token, ranges))
        return row;

    cfs.invalidateCachedRow(row.getKey());

    if (indexedColumnsInRow != null)
        indexedColumnsInRow.clear();

    while (row.hasNext())
    {
        OnDiskAtom column = row.next();

        if (column instanceof Cell && cfs.indexManager.indexes((Cell) column))
        {
            if (indexedColumnsInRow == null)
                indexedColumnsInRow = new ArrayList<>();

            indexedColumnsInRow.add((Cell) column);
        }
    }

    if (indexedColumnsInRow != null && !indexedColumnsInRow.isEmpty())
    {
        // acquire memtable lock here because secondary index deletion may cause a race. See CASSANDRA-3712
        try (OpOrder.Group opGroup = cfs.keyspace.writeOrder.start())
        {
            cfs.indexManager.deleteFromIndexes(row.getKey(), indexedColumnsInRow, opGroup);
        }
    }
    return null;
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:35,代码来源:CompactionManager.java

示例15: getJson

import org.apache.cassandra.io.sstable.SSTableIdentityIterator; //导入依赖的package包/类
protected Text getJson(SSTableIdentityIterator rowIterator, Mapper.Context context) {
    final StringBuilder sb = new StringBuilder();
    sb.append("{");
    insertKey(sb, rowIterator.getKey().toString());
    sb.append("{");
    insertKey(sb, "columns");
    sb.append("[");
    serializeColumns(sb, rowIterator, context);
    sb.append("]");
    sb.append("}}");
    return new Text(sb.toString());
}
 
开发者ID:fullcontact,项目名称:hadoop-sstable,代码行数:13,代码来源:JsonColumnParser.java


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