本文整理汇总了Java中org.apache.cassandra.config.CFMetaData类的典型用法代码示例。如果您正苦于以下问题:Java CFMetaData类的具体用法?Java CFMetaData怎么用?Java CFMetaData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CFMetaData类属于org.apache.cassandra.config包,在下文中一共展示了CFMetaData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: internalOpen
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
/**
* Open a RowIndexedReader which already has its state initialized (by SSTableWriter).
*/
public static SSTableReader internalOpen(Descriptor desc,
Set<Component> components,
CFMetaData metadata,
FileHandle ifile,
FileHandle dfile,
IndexSummary isummary,
IFilter bf,
long maxDataAge,
StatsMetadata sstableMetadata,
OpenReason openReason,
SerializationHeader header)
{
assert desc != null && ifile != null && dfile != null && isummary != null && bf != null && sstableMetadata != null;
SSTableReader reader = internalOpen(desc, components, metadata, maxDataAge, sstableMetadata, openReason, header);
reader.bf = bf;
reader.ifile = ifile;
reader.dfile = dfile;
reader.indexSummary = isummary;
reader.setup(true);
return reader;
}
示例2: prepare
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
public Operation prepare(CFMetaData cfm, ColumnDefinition receiver) throws InvalidRequestException
{
Term v = value.prepare(cfm.ksName, receiver);
if (!(receiver.type instanceof CollectionType))
{
if (!(receiver.type instanceof CounterColumnType))
throw new InvalidRequestException(String.format("Invalid operation (%s) for non counter column %s", toString(receiver), receiver.name));
return new Constants.Adder(receiver, v);
}
else if (!(receiver.type.isMultiCell()))
throw new InvalidRequestException(String.format("Invalid operation (%s) for frozen collection column %s", toString(receiver), receiver.name));
switch (((CollectionType)receiver.type).kind)
{
case LIST:
return new Lists.Appender(receiver, v);
case SET:
return new Sets.Adder(receiver, v);
case MAP:
return new Maps.Putter(receiver, v);
}
throw new AssertionError();
}
示例3: deserializeForMessaging
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
public SerializationHeader deserializeForMessaging(DataInputPlus in, CFMetaData metadata, ColumnFilter selection, boolean hasStatic) throws IOException
{
EncodingStats stats = EncodingStats.serializer.deserialize(in);
AbstractType<?> keyType = metadata.getKeyValidator();
List<AbstractType<?>> clusteringTypes = metadata.comparator.subtypes();
Columns statics, regulars;
if (selection == null)
{
statics = hasStatic ? Columns.serializer.deserialize(in, metadata) : Columns.NONE;
regulars = Columns.serializer.deserialize(in, metadata);
}
else
{
statics = hasStatic ? Columns.serializer.deserializeSubset(selection.fetchedColumns().statics, in) : Columns.NONE;
regulars = Columns.serializer.deserializeSubset(selection.fetchedColumns().regulars, in);
}
return new SerializationHeader(false, keyType, clusteringTypes, new PartitionColumns(statics, regulars), stats, null);
}
示例4: UpdateParameters
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
public UpdateParameters(CFMetaData metadata,
PartitionColumns updatedColumns,
QueryOptions options,
long timestamp,
int ttl,
Map<DecoratedKey, Partition> prefetchedRows)
throws InvalidRequestException
{
this.metadata = metadata;
this.updatedColumns = updatedColumns;
this.options = options;
this.nowInSec = FBUtilities.nowInSeconds();
this.timestamp = timestamp;
this.ttl = ttl;
this.deletionTime = new DeletionTime(timestamp, nowInSec);
this.prefetchedRows = prefetchedRows;
// We use MIN_VALUE internally to mean the absence of of timestamp (in Selection, in sstable stats, ...), so exclude
// it to avoid potential confusion.
if (timestamp == Long.MIN_VALUE)
throw new InvalidRequestException(String.format("Out of bound timestamp, must be in [%d, %d]", Long.MIN_VALUE + 1, Long.MAX_VALUE));
}
示例5: getPartitionKeyBindIndexes
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
/**
* Returns an array with the same length as the number of partition key columns for the table corresponding
* to cfm. Each short in the array represents the bind index of the marker that holds the value for that
* partition key column. If there are no bind markers for any of the partition key columns, null is returned.
*
* Callers of this method should ensure that all statements operate on the same table.
*/
public short[] getPartitionKeyBindIndexes(CFMetaData cfm)
{
short[] partitionKeyPositions = new short[cfm.partitionKeyColumns().size()];
boolean[] set = new boolean[partitionKeyPositions.length];
for (int i = 0; i < targetColumns.length; i++)
{
ColumnDefinition targetColumn = targetColumns[i];
if (targetColumn != null && targetColumn.isPartitionKey())
{
assert targetColumn.ksName.equals(cfm.ksName) && targetColumn.cfName.equals(cfm.cfName);
partitionKeyPositions[targetColumn.position()] = (short) i;
set[targetColumn.position()] = true;
}
}
for (boolean b : set)
if (!b)
return null;
return partitionKeyPositions;
}
示例6: encodeBound
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
public static ByteBuffer encodeBound(CFMetaData metadata, ClusteringBound bound, boolean isStart)
{
if (bound == ClusteringBound.BOTTOM || bound == ClusteringBound.TOP || metadata.comparator.size() == 0)
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
ClusteringPrefix clustering = bound.clustering();
if (!metadata.isCompound())
{
assert clustering.size() == 1;
return clustering.get(0);
}
CompositeType ctype = CompositeType.getInstance(metadata.comparator.subtypes());
CompositeType.Builder builder = ctype.builder();
for (int i = 0; i < clustering.size(); i++)
builder.add(clustering.get(i));
if (isStart)
return bound.isInclusive() ? builder.build() : builder.buildAsEndOfRange();
else
return bound.isInclusive() ? builder.buildAsEndOfRange() : builder.build();
}
示例7: testParsingCompositeKey
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
/**
* Test on parsing out a ByteBuffer to a list of strings.
* @throws IOException
*/
@Test
public void testParsingCompositeKey() throws IOException {
final String inputSSTableFullPathFileName = CASS3_DATA_DIR + "keyspace1/compressed_bills/mc-2-big-Data.db";
final SSTableSingleReader SSTableSingleReader =
new SSTableSingleReader(inputSSTableFullPathFileName,
TestBaseSSTableFunSuite.HADOOP_CONF);
final CFMetaData cfMetaData = SSTableSingleReader.getCfMetaData();
final String user = "user2";
final String email = "[email protected]";
final AbstractType<?> keyDataType = cfMetaData.getKeyValidator();
Assert.assertTrue(keyDataType instanceof CompositeType);
final ByteBuffer keyInByteBuffer = ((CompositeType) keyDataType).decompose(user, email);
final List<Object> objects = SSTableUtils.parsePrimaryKey(cfMetaData, keyInByteBuffer);
Assert.assertEquals(2, objects.size());
Assert.assertEquals(user, objects.get(0));
Assert.assertEquals(email, objects.get(1));
}
示例8: legacyCellComparator
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
public static Comparator<LegacyCell> legacyCellComparator(final CFMetaData metadata, final boolean reversed)
{
final Comparator<LegacyCellName> cellNameComparator = legacyCellNameComparator(metadata, reversed);
return new Comparator<LegacyCell>()
{
public int compare(LegacyCell cell1, LegacyCell cell2)
{
LegacyCellName c1 = cell1.name;
LegacyCellName c2 = cell2.name;
int c = cellNameComparator.compare(c1, c2);
if (c != 0)
return c;
// The actual sorting when the cellname is equal doesn't matter, we just want to make
// sure the cells are not considered equal.
if (cell1.timestamp != cell2.timestamp)
return cell1.timestamp < cell2.timestamp ? -1 : 1;
if (cell1.localDeletionTime != cell2.localDeletionTime)
return cell1.localDeletionTime < cell2.localDeletionTime ? -1 : 1;
return cell1.value.compareTo(cell2.value);
}
};
}
示例9: readLegacyAtom
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
public static LegacyAtom readLegacyAtom(CFMetaData metadata, DataInputPlus in, boolean readAllAsDynamic) throws IOException
{
while (true)
{
ByteBuffer cellname = ByteBufferUtil.readWithShortLength(in);
if (!cellname.hasRemaining())
return null; // END_OF_ROW
try
{
int b = in.readUnsignedByte();
return (b & RANGE_TOMBSTONE_MASK) != 0
? readLegacyRangeTombstoneBody(metadata, in, cellname)
: readLegacyCellBody(metadata, in, cellname, b, SerializationHelper.Flag.LOCAL, readAllAsDynamic);
}
catch (UnknownColumnException e)
{
// We can get there if we read a cell for a dropped column, and ff that is the case,
// then simply ignore the cell is fine. But also not that we ignore if it's the
// system keyspace because for those table we actually remove columns without registering
// them in the dropped columns
assert metadata.ksName.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME) || metadata.getDroppedColumnDefinition(e.columnName) != null : e.getMessage();
}
}
}
示例10: deserialize
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
public Columns deserialize(DataInputPlus in, CFMetaData metadata) throws IOException
{
int length = (int)in.readUnsignedVInt();
BTree.Builder<ColumnDefinition> builder = BTree.builder(Comparator.naturalOrder());
builder.auto(false);
for (int i = 0; i < length; i++)
{
ByteBuffer name = ByteBufferUtil.readWithVIntLength(in);
ColumnDefinition column = metadata.getColumnDefinition(name);
if (column == null)
{
// If we don't find the definition, it could be we have data for a dropped column, and we shouldn't
// fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper
// deserialization. The column will be ignore later on anyway.
column = metadata.getDroppedColumnDefinition(name);
if (column == null)
throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization");
}
builder.add(column);
}
return new Columns(builder.build());
}
示例11: testCasspactorIterator
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
/**
* Test on the SSTableIterator.
* @throws IOException
*/
@Test
public void testCasspactorIterator() throws IOException {
final String inputSSTableFullPathFileName = CASS3_DATA_DIR + "keyspace1/bills_compress/mc-6-big-Data.db";
final SSTableSingleReader reader1 = new SSTableSingleReader(inputSSTableFullPathFileName,
TestBaseSSTableFunSuite.HADOOP_CONF);
final SSTableSingleReader reader2 = new SSTableSingleReader(inputSSTableFullPathFileName,
TestBaseSSTableFunSuite.HADOOP_CONF);
final CFMetaData cfMetaData = reader1.getCfMetaData();
final List<ISSTableScanner> scanners = new ArrayList<>();
final int nowInSecs = (int) (System.currentTimeMillis() / 1000);
scanners.add(reader1.getSSTableScanner());
scanners.add(reader2.getSSTableScanner());
int counter = 0;
try (SSTableIterator ci = new SSTableIterator(scanners, reader1.getCfMetaData(), nowInSecs)) {
while (ci.hasNext()) {
final RowIterator rowIterator = ci.next();
counter += printRowDetails(cfMetaData, rowIterator, false);
}
}
Assert.assertEquals(4, counter);
}
示例12: deserialize
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
public static LegacyDeletionInfo deserialize(CFMetaData metadata, DataInputPlus in) throws IOException
{
DeletionTime topLevel = DeletionTime.serializer.deserialize(in);
int rangeCount = in.readInt();
if (rangeCount == 0)
return new LegacyDeletionInfo(new MutableDeletionInfo(topLevel));
LegacyDeletionInfo delInfo = new LegacyDeletionInfo(new MutableDeletionInfo(topLevel));
for (int i = 0; i < rangeCount; i++)
{
LegacyBound start = decodeBound(metadata, ByteBufferUtil.readWithShortLength(in), true);
LegacyBound end = decodeBound(metadata, ByteBufferUtil.readWithShortLength(in), false);
int delTime = in.readInt();
long markedAt = in.readLong();
delInfo.add(metadata, new LegacyRangeTombstone(start, end, new DeletionTime(markedAt, delTime)));
}
return delInfo;
}
示例13: build
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
protected static Holder build(UnfilteredRowIterator iterator, int initialRowCapacity, boolean ordered)
{
CFMetaData metadata = iterator.metadata();
PartitionColumns columns = iterator.columns();
boolean reversed = iterator.isReverseOrder();
BTree.Builder<Row> builder = BTree.builder(metadata.comparator, initialRowCapacity);
builder.auto(!ordered);
MutableDeletionInfo.Builder deletionBuilder = MutableDeletionInfo.builder(iterator.partitionLevelDeletion(), metadata.comparator, reversed);
while (iterator.hasNext())
{
Unfiltered unfiltered = iterator.next();
if (unfiltered.kind() == Unfiltered.Kind.ROW)
builder.add((Row)unfiltered);
else
deletionBuilder.add((RangeTombstoneMarker)unfiltered);
}
if (reversed)
builder.reverse();
return new Holder(columns, builder.build(), deletionBuilder.build(), iterator.staticRow(), iterator.stats());
}
示例14: UnfilteredRowMergeIterator
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
private UnfilteredRowMergeIterator(CFMetaData metadata,
List<UnfilteredRowIterator> iterators,
PartitionColumns columns,
DeletionTime partitionDeletion,
int nowInSec,
boolean reversed,
MergeListener listener)
{
super(metadata,
iterators.get(0).partitionKey(),
partitionDeletion,
columns,
mergeStaticRows(iterators, columns.statics, nowInSec, listener, partitionDeletion),
reversed,
mergeStats(iterators));
this.mergeIterator = MergeIterator.get(iterators,
reversed ? metadata.comparator.reversed() : metadata.comparator,
new MergeReducer(iterators.size(), reversed, nowInSec, listener));
this.listener = listener;
}
示例15: testWritingToLocalSSTable
import org.apache.cassandra.config.CFMetaData; //导入依赖的package包/类
/******************************************************
* 1. Input data
* This is the schema definition of the table that is used to generate the non-compressed input data:
* <p>
* CREATE TABLE bills_nc (
* user text,
* balance int static,
* expense_id int,
* amount int,
* name text,
* PRIMARY KEY (user, expense_id))
* WITH compression = { 'sstable_compression' : '' };
* <p>
* <p>
* 2. Compressing and producing output data
* Running this main will convert data file under src/test/resources/data/bills_compress/mc-6-big-Data.db
* in to the corresponding compressed file, using LZ4 compression, along with auxiliary
* files (CompressionInfo.db, Index.db, etc).
* <p>
* The output is under cassanrda/compresseddata/cassandra/data directory
* <p>
* 3. Verification
* Since this is C* 3.0 format, you should use sstabledump command to dump out the json contents
* for both intput data and output data to verify.
* %>sstabledump cassandra/data/mc-1-big-Data.db
* and
* %>sstabledump cassandra/compresseddata/cassandra/data/mc-1-big-Data.db
*******************************************************/
@Test
public void testWritingToLocalSSTable() {
final String inputSSTableFullPathFileName = CASS3_DATA_DIR + "keyspace1/bills_compress/mc-6-big-Data.db";
LOGGER.info("Input file name: " + inputSSTableFullPathFileName);
final Descriptor inputSSTableDescriptor = Descriptor.fromFilename(inputSSTableFullPathFileName,
TestBaseSSTableFunSuite.HADOOP_CONF);
SSTableWriter writer = null;
try {
SSTableSingleReader reader = new SSTableSingleReader(inputSSTableFullPathFileName,
"casspactor",
"bills_nc",
TestBaseSSTableFunSuite.HADOOP_CONF);
final CFMetaData inputCFMetaData = reader.getCfMetaData();
final ISSTableScanner currentScanner = reader.getSSTableScanner();
final SSTableReader inputSStable = reader.getSstableReader();
//Create writer
final CFMetaData outputCFMetaData = SSTableUtils.createNewCFMetaData(inputSSTableDescriptor, inputCFMetaData);
writer = SSTableUtils.createSSTableWriter(inputSSTableDescriptor, outputCFMetaData, inputSStable);
while (currentScanner.hasNext()) {
final UnfilteredRowIterator row = currentScanner.next();
writer.append(row);
}
writer.finish(false);
} catch (IOException e) {
e.printStackTrace(System.err);
} finally {
FileUtils.closeQuietly(writer);
}
}