本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例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());
}