本文整理汇总了Java中org.apache.cassandra.db.composites.Composite.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Composite.isEmpty方法的具体用法?Java Composite.isEmpty怎么用?Java Composite.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.db.composites.Composite
的用法示例。
在下文中一共展示了Composite.isEmpty方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makePrefix
import org.apache.cassandra.db.composites.Composite; //导入方法依赖的package包/类
private Composite makePrefix(CompositesIndex index, ByteBuffer key, ExtendedFilter filter, boolean isStart)
{
if (key.remaining() == 0)
return Composites.EMPTY;
Composite prefix;
IDiskAtomFilter columnFilter = filter.columnFilter(key);
if (columnFilter instanceof SliceQueryFilter)
{
SliceQueryFilter sqf = (SliceQueryFilter)columnFilter;
Composite columnName = isStart ? sqf.start() : sqf.finish();
prefix = columnName.isEmpty() ? index.getIndexComparator().make(key) : index.makeIndexColumnPrefix(key, columnName);
}
else
{
prefix = index.getIndexComparator().make(key);
}
return isStart ? prefix.start() : prefix.end();
}
示例2: addUpdateForKey
import org.apache.cassandra.db.composites.Composite; //导入方法依赖的package包/类
public void addUpdateForKey(ColumnFamily cf, ByteBuffer key, Composite prefix, UpdateParameters params)
throws InvalidRequestException
{
List<Operation> deletions = getOperations();
if (prefix.size() < cfm.clusteringColumns().size() && !deletions.isEmpty())
{
// In general, we can't delete specific columns if not all clustering columns have been specified.
// However, if we delete only static colums, it's fine since we won't really use the prefix anyway.
for (Operation deletion : deletions)
if (!deletion.column.isStatic())
throw new InvalidRequestException(String.format("Primary key column '%s' must be specified in order to delete column '%s'", getFirstEmptyKey().name, deletion.column.name));
}
if (deletions.isEmpty())
{
// We delete the slice selected by the prefix.
// However, for performance reasons, we distinguish 2 cases:
// - It's a full internal row delete
// - It's a full cell name (i.e it's a dense layout and the prefix is full)
if (prefix.isEmpty())
{
// No columns specified, delete the row
cf.delete(new DeletionInfo(params.timestamp, params.localDeletionTime));
}
else if (cfm.comparator.isDense() && prefix.size() == cfm.clusteringColumns().size())
{
cf.addAtom(params.makeTombstone(cfm.comparator.create(prefix, null)));
}
else
{
cf.addAtom(params.makeRangeTombstone(prefix.slice()));
}
}
else
{
for (Operation op : deletions)
op.execute(key, cf, prefix, params);
}
}
示例3: validateSliceFilter
import org.apache.cassandra.db.composites.Composite; //导入方法依赖的package包/类
private static void validateSliceFilter(CFMetaData metadata, Composite start, Composite finish, boolean reversed)
throws InvalidRequestException
{
CellNameType comparator = metadata.comparator;
Comparator<Composite> orderedComparator = reversed ? comparator.reverseComparator(): comparator;
if (!start.isEmpty() && !finish.isEmpty() && orderedComparator.compare(start, finish) > 0)
throw new InvalidRequestException("range finish must come after start in traversal order");
}
示例4: deserializeFromSSTable
import org.apache.cassandra.db.composites.Composite; //导入方法依赖的package包/类
public OnDiskAtom deserializeFromSSTable(DataInput in, ColumnSerializer.Flag flag, int expireBefore, Descriptor.Version version) throws IOException
{
Composite name = type.serializer().deserialize(in);
if (name.isEmpty())
{
// SSTableWriter.END_OF_ROW
return null;
}
int b = in.readUnsignedByte();
if ((b & ColumnSerializer.RANGE_TOMBSTONE_MASK) != 0)
return type.rangeTombstoneSerializer().deserializeBody(in, name, version);
else
return type.columnSerializer().deserializeColumnBody(in, (CellName)name, b, flag, expireBefore);
}
示例5: iterator
import org.apache.cassandra.db.composites.Composite; //导入方法依赖的package包/类
public Iterator<RangeTombstone> iterator(Composite from, Composite till)
{
int startIdx = from.isEmpty() ? 0 : searchInternal(from, 0);
final int start = startIdx < 0 ? -startIdx-1 : startIdx;
if (start >= size)
return Iterators.<RangeTombstone>emptyIterator();
int finishIdx = till.isEmpty() ? size : searchInternal(till, start);
// if stopIdx is the first range after 'till' we care only until the previous range
final int finish = finishIdx < 0 ? -finishIdx-2 : finishIdx;
// Note: the following is true because we know 'from' is before 'till' in sorted order.
if (start > finish)
return Iterators.<RangeTombstone>emptyIterator();
else if (start == finish)
return Iterators.<RangeTombstone>singletonIterator(rangeTombstone(start));
return new AbstractIterator<RangeTombstone>()
{
private int idx = start;
protected RangeTombstone computeNext()
{
if (idx >= size || idx > finish)
return endOfData();
return rangeTombstone(idx++);
}
};
}
示例6: indexFor
import org.apache.cassandra.db.composites.Composite; //导入方法依赖的package包/类
/**
* The index of the IndexInfo in which a scan starting with @name should begin.
*
* @param name
* name of the index
*
* @param indexList
* list of the indexInfo objects
*
* @param comparator
* comparator type
*
* @param reversed
* is name reversed
*
* @return int index
*/
public static int indexFor(Composite name, List<IndexInfo> indexList, CType comparator, boolean reversed, int lastIndex)
{
if (name.isEmpty())
return lastIndex >= 0 ? lastIndex : reversed ? indexList.size() - 1 : 0;
if (lastIndex >= indexList.size())
return -1;
IndexInfo target = new IndexInfo(name, name, 0, 0);
/*
Take the example from the unit test, and say your index looks like this:
[0..5][10..15][20..25]
and you look for the slice [13..17].
When doing forward slice, we we doing a binary search comparing 13 (the start of the query)
to the lastName part of the index slot. You'll end up with the "first" slot, going from left to right,
that may contain the start.
When doing a reverse slice, we do the same thing, only using as a start column the end of the query,
i.e. 17 in this example, compared to the firstName part of the index slots. bsearch will give us the
first slot where firstName > start ([20..25] here), so we subtract an extra one to get the slot just before.
*/
int startIdx = 0;
List<IndexInfo> toSearch = indexList;
if (lastIndex >= 0)
{
if (reversed)
{
toSearch = indexList.subList(0, lastIndex + 1);
}
else
{
startIdx = lastIndex;
toSearch = indexList.subList(lastIndex, indexList.size());
}
}
int index = Collections.binarySearch(toSearch, target, getComparator(comparator, reversed));
return startIdx + (index < 0 ? -index - (reversed ? 2 : 1) : index);
}
示例7: isBeforeSliceStart
import org.apache.cassandra.db.composites.Composite; //导入方法依赖的package包/类
protected boolean isBeforeSliceStart(Composite name)
{
Composite start = currentStart();
return !start.isEmpty() && comparator.compare(name, start) < 0;
}
示例8: isColumnBeforeSliceFinish
import org.apache.cassandra.db.composites.Composite; //导入方法依赖的package包/类
protected boolean isColumnBeforeSliceFinish(OnDiskAtom column)
{
Composite finish = currentFinish();
return finish.isEmpty() || comparator.compare(column.name(), finish) <= 0;
}
示例9: isAfterSliceFinish
import org.apache.cassandra.db.composites.Composite; //导入方法依赖的package包/类
protected boolean isAfterSliceFinish(Composite name)
{
Composite finish = currentFinish();
return !finish.isEmpty() && comparator.compare(name, finish) > 0;
}
示例10: SimpleBlockFetcher
import org.apache.cassandra.db.composites.Composite; //导入方法依赖的package包/类
public SimpleBlockFetcher() throws IOException
{
// Since we have to deserialize in order and will read all slices might as well reverse the slices and
// behave as if it was not reversed
super(reversed ? slices.length - 1 : 0);
// We remenber when we are whithin a slice to avoid some comparison
boolean inSlice = false;
AtomDeserializer deserializer = emptyColumnFamily.metadata().getOnDiskDeserializer(file, sstable.descriptor.version);
while (deserializer.hasNext())
{
// col is before slice
// (If in slice, don't bother checking that until we change slice)
Composite start = currentStart();
if (!inSlice && !start.isEmpty() && deserializer.compareNextTo(start) < 0)
{
// If it's a rangeTombstone, then we need to read it and include it unless it's end
// stops before our slice start. Otherwise, we can skip it.
if (deserializer.nextIsRangeTombstone())
{
RangeTombstone rt = (RangeTombstone)deserializer.readNext();
if (comparator.compare(rt.max, start) >= 0)
addColumn(rt);
}
else
{
deserializer.skipNext();
}
continue;
}
// col is within slice
Composite finish = currentFinish();
if (finish.isEmpty() || deserializer.compareNextTo(finish) <= 0)
{
inSlice = true;
addColumn(deserializer.readNext());
}
// col is after slice. more slices?
else
{
inSlice = false;
if (!setNextSlice())
break;
}
}
}