本文整理汇总了Java中org.apache.cassandra.cql3.ColumnIdentifier类的典型用法代码示例。如果您正苦于以下问题:Java ColumnIdentifier类的具体用法?Java ColumnIdentifier怎么用?Java ColumnIdentifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColumnIdentifier类属于org.apache.cassandra.cql3包,在下文中一共展示了ColumnIdentifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypeAndRemove
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
private AbstractType<?> getTypeAndRemove(Map<ColumnIdentifier, AbstractType> columns, ColumnIdentifier t) throws InvalidRequestException
{
AbstractType type = columns.get(t);
if (type == null)
throw new InvalidRequestException(String.format("Unknown definition %s referenced in PRIMARY KEY", t));
if (type.isMultiCell())
{
if (type.isCollection())
throw new InvalidRequestException(String.format("Invalid non-frozen collection type for PRIMARY KEY component %s", t));
else
throw new InvalidRequestException(String.format("Invalid non-frozen user-defined type for PRIMARY KEY component %s", t));
}
columns.remove(t);
Boolean isReversed = properties.definedOrdering.get(t);
return isReversed != null && isReversed ? ReversedType.getInstance(type) : type;
}
示例2: build
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
public ColumnFilter build()
{
boolean isFetchAll = metadata != null;
PartitionColumns queried = queriedBuilder == null ? null : queriedBuilder.build();
// It's only ok to have queried == null in ColumnFilter if isFetchAll. So deal with the case of a selectionBuilder
// with nothing selected (we can at least happen on some backward compatible queries - CASSANDRA-10471).
if (!isFetchAll && queried == null)
queried = PartitionColumns.NONE;
SortedSetMultimap<ColumnIdentifier, ColumnSubselection> s = null;
if (subSelections != null)
{
s = TreeMultimap.create(Comparator.<ColumnIdentifier>naturalOrder(), Comparator.<ColumnSubselection>naturalOrder());
for (ColumnSubselection subSelection : subSelections)
s.put(subSelection.column().name, subSelection);
}
return new ColumnFilter(isFetchAll, metadata, queried, s);
}
示例3: ColumnDefinition
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
@VisibleForTesting
public ColumnDefinition(String ksName,
String cfName,
ColumnIdentifier name,
AbstractType<?> type,
int position,
Kind kind)
{
super(ksName, cfName, name, type);
assert name != null && type != null && kind != null;
assert name.isInterned();
assert (position == NO_POSITION) == !kind.isPrimaryKeyKind(); // The position really only make sense for partition and clustering columns (and those must have one),
// so make sure we don't sneak it for something else since it'd breaks equals()
this.kind = kind;
this.position = position;
this.cellPathComparator = makeCellPathComparator(kind, type);
this.cellComparator = cellPathComparator == null ? ColumnData.comparator : (a, b) -> cellPathComparator.compare(a.path(), b.path());
this.asymmetricCellPathComparator = cellPathComparator == null ? null : (a, b) -> cellPathComparator.compare(((Cell)a).path(), (CellPath) b);
this.comparisonOrder = comparisonOrder(kind, isComplex(), Math.max(0, position), name);
}
示例4: getIdentifier
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
public ColumnIdentifier getIdentifier(CFMetaData cfm)
{
if (!cfm.isStaticCompactTable())
return ColumnIdentifier.getInterned(text, true);
AbstractType<?> thriftColumnNameType = cfm.thriftColumnNameType();
if (thriftColumnNameType instanceof UTF8Type)
return ColumnIdentifier.getInterned(text, true);
// We have a Thrift-created table with a non-text comparator. Check if we have a match column, otherwise assume we should use
// thriftColumnNameType
ByteBuffer bufferName = ByteBufferUtil.bytes(text);
for (ColumnDefinition def : cfm.allColumns())
{
if (def.name.bytes.equals(bufferName))
return def.name;
}
return ColumnIdentifier.getInterned(thriftColumnNameType, thriftColumnNameType.fromString(text), text);
}
示例5: add
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
void add(Cell cell)
{
CellName cellName = cell.name();
ColumnIdentifier columnName = cellName.cql3ColumnName(cfMetaData);
if (cellName.isCollectionCell())
{
if (collections == null)
collections = new HashMap<>();
List<Cell> values = collections.get(columnName);
if (values == null)
{
values = new ArrayList<Cell>();
collections.put(columnName, values);
}
values.add(cell);
}
else
{
if (columns == null)
columns = new HashMap<>();
columns.put(columnName, cell);
}
}
示例6: testComplexCellReconcile
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
@Test
public void testComplexCellReconcile()
{
ColumnDefinition m = cfm2.getColumnDefinition(new ColumnIdentifier("m", false));
int now1 = FBUtilities.nowInSeconds();
long ts1 = now1*1000000;
Cell r1m1 = BufferCell.live(cfm2, m, ts1, bb(1), CellPath.create(bb(1)));
Cell r1m2 = BufferCell.live(cfm2, m, ts1, bb(2), CellPath.create(bb(2)));
List<Cell> cells1 = Lists.newArrayList(r1m1, r1m2);
int now2 = now1 + 1;
long ts2 = now2*1000000;
Cell r2m2 = BufferCell.live(cfm2, m, ts2, bb(1), CellPath.create(bb(2)));
Cell r2m3 = BufferCell.live(cfm2, m, ts2, bb(2), CellPath.create(bb(3)));
Cell r2m4 = BufferCell.live(cfm2, m, ts2, bb(3), CellPath.create(bb(4)));
List<Cell> cells2 = Lists.newArrayList(r2m2, r2m3, r2m4);
RowBuilder builder = new RowBuilder();
Cells.reconcileComplex(m, cells1.iterator(), cells2.iterator(), DeletionTime.LIVE, builder, now2 + 1);
Assert.assertEquals(Lists.newArrayList(r1m1, r2m2, r2m3, r2m4), builder.cells);
}
示例7: assertRowsInResult
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
private static void assertRowsInResult(ColumnFamilyStore cfs, SinglePartitionReadCommand command, int ... columnValues)
{
try (ReadOrderGroup orderGroup = command.startOrderGroup(); PartitionIterator iterator = command.executeInternal(orderGroup))
{
if (columnValues.length == 0)
{
if (iterator.hasNext())
fail("Didn't expect any results, but got rows starting with: " + iterator.next().next().toString(cfs.metadata));
return;
}
try (RowIterator rowIterator = iterator.next())
{
for (int expected : columnValues)
{
Row row = rowIterator.next();
Cell cell = row.getCell(cfs.metadata.getColumnDefinition(new ColumnIdentifier("c", false)));
assertEquals(
String.format("Expected %s, but got %s", ByteBufferUtil.bytesToHex(ByteBufferUtil.bytes(expected)), ByteBufferUtil.bytesToHex(cell.value())),
ByteBufferUtil.bytes(expected), cell.value());
}
assertFalse(rowIterator.hasNext());
}
}
}
示例8: testResolve
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
@Test
public void testResolve()
{
ColumnDefinition defA = cfm.getColumnDefinition(new ColumnIdentifier("a", true));
ColumnDefinition defB = cfm.getColumnDefinition(new ColumnIdentifier("b", true));
Row.Builder builder = BTreeRow.unsortedBuilder(nowInSeconds);
builder.newRow(cfm.comparator.make("c1"));
writeSimpleCellValue(builder, cfm, defA, "a1", 0);
writeSimpleCellValue(builder, cfm, defA, "a2", 1);
writeSimpleCellValue(builder, cfm, defB, "b1", 1);
Row row = builder.build();
PartitionUpdate update = PartitionUpdate.singleRowUpdate(cfm, dk, row);
Unfiltered unfiltered = update.unfilteredIterator().next();
assertTrue(unfiltered.kind() == Unfiltered.Kind.ROW);
row = (Row) unfiltered;
assertEquals("a2", defA.cellValueType().getString(row.getCell(defA).value()));
assertEquals("b1", defB.cellValueType().getString(row.getCell(defB).value()));
assertEquals(2, row.columns().size());
}
示例9: testExpiringColumnExpiration
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
@Test
public void testExpiringColumnExpiration() throws IOException
{
int ttl = 1;
ColumnDefinition def = cfm.getColumnDefinition(new ColumnIdentifier("a", true));
Cell cell = BufferCell.expiring(def, 0, ttl, nowInSeconds, ((AbstractType) def.cellValueType()).decompose("a1"));
PartitionUpdate update = PartitionUpdate.singleRowUpdate(cfm, dk, BTreeRow.singleCellRow(cfm.comparator.make("c1"), cell));
new Mutation(update).applyUnsafe();
// when we read with a nowInSeconds before the cell has expired,
// the PartitionIterator includes the row we just wrote
Row row = Util.getOnlyRow(Util.cmd(cfs, dk).includeRow("c1").withNowInSeconds(nowInSeconds).build());
assertEquals("a1", ByteBufferUtil.string(row.getCell(def).value()));
// when we read with a nowInSeconds after the cell has expired, the row is filtered
// so the PartitionIterator is empty
Util.assertEmpty(Util.cmd(cfs, dk).includeRow("c1").withNowInSeconds(nowInSeconds + ttl + 1).build());
}
示例10: getColumnDefinition
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
/**
* Returns a ColumnDefinition given a cell name.
*/
public ColumnDefinition getColumnDefinition(CellName cellName)
{
ColumnIdentifier id = cellName.cql3ColumnName(this);
ColumnDefinition def = id == null
? getColumnDefinition(cellName.toByteBuffer()) // Means a dense layout, try the full column name
: getColumnDefinition(id);
// It's possible that the def is a PRIMARY KEY or COMPACT_VALUE one in case a concrete cell
// name conflicts with a CQL column name, which can happen in 2 cases:
// 1) because the user inserted a cell through Thrift that conflicts with a default "alias" used
// by CQL for thrift tables (see #6892).
// 2) for COMPACT STORAGE tables with a single utf8 clustering column, the cell name can be anything,
// including a CQL column name (without this being a problem).
// In any case, this is fine, this just mean that columnDefinition is not the ColumnDefinition we are
// looking for.
return def != null && def.isPartOfCellName() ? def : null;
}
示例11: UDFunction
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
protected UDFunction(FunctionName name,
List<ColumnIdentifier> argNames,
List<AbstractType<?>> argTypes,
DataType[] argDataTypes,
AbstractType<?> returnType,
DataType returnDataType,
boolean calledOnNullInput,
String language,
String body)
{
super(name, argTypes, returnType);
assert new HashSet<>(argNames).size() == argNames.size() : "duplicate argument names";
this.argNames = argNames;
this.language = language;
this.body = body;
this.argCodecs = UDHelper.codecsFor(argDataTypes);
this.returnCodec = UDHelper.codecFor(returnDataType);
this.calledOnNullInput = calledOnNullInput;
}
示例12: create
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
public static UDFunction create(FunctionName name,
List<ColumnIdentifier> argNames,
List<AbstractType<?>> argTypes,
AbstractType<?> returnType,
boolean calledOnNullInput,
String language,
String body)
{
UDFunction.assertUdfsEnabled(language);
switch (language)
{
case "java":
return new JavaBasedUDFunction(name, argNames, argTypes, returnType, calledOnNullInput, body);
default:
return new ScriptBasedUDFunction(name, argNames, argTypes, returnType, calledOnNullInput, language, body);
}
}
示例13: createBrokenFunction
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
/**
* It can happen that a function has been declared (is listed in the scheam) but cannot
* be loaded (maybe only on some nodes). This is the case for instance if the class defining
* the class is not on the classpath for some of the node, or after a restart. In that case,
* we create a "fake" function so that:
* 1) the broken function can be dropped easily if that is what people want to do.
* 2) we return a meaningful error message if the function is executed (something more precise
* than saying that the function doesn't exist)
*/
public static UDFunction createBrokenFunction(FunctionName name,
List<ColumnIdentifier> argNames,
List<AbstractType<?>> argTypes,
AbstractType<?> returnType,
boolean calledOnNullInput,
String language,
String body,
InvalidRequestException reason)
{
return new UDFunction(name, argNames, argTypes, returnType, calledOnNullInput, language, body)
{
protected ExecutorService executor()
{
return Executors.newSingleThreadExecutor();
}
public ByteBuffer executeUserDefined(int protocolVersion, List<ByteBuffer> parameters)
{
throw new InvalidRequestException(String.format("Function '%s' exists but hasn't been loaded successfully "
+ "for the following reason: %s. Please see the server log for details",
this,
reason.getMessage()));
}
};
}
示例14: generateArguments
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
private static String generateArguments(Class<?>[] paramTypes, List<ColumnIdentifier> argNames)
{
StringBuilder code = new StringBuilder(64 * paramTypes.length);
for (int i = 0; i < paramTypes.length; i++)
{
if (i > 0)
code.append(",\n");
if (logger.isTraceEnabled())
code.append(" /* parameter '").append(argNames.get(i)).append("' */\n");
code
// cast to Java type
.append(" (").append(javaSourceName(paramTypes[i])).append(") ")
// generate object representation of input parameter (call UDFunction.compose)
.append(composeMethod(paramTypes[i])).append("(protocolVersion, ").append(i).append(", params.get(").append(i).append("))");
}
return code.toString();
}
示例15: CreateTableStatement
import org.apache.cassandra.cql3.ColumnIdentifier; //导入依赖的package包/类
public CreateTableStatement(CFName name, TableParams params, boolean ifNotExists, Set<ColumnIdentifier> staticColumns, UUID id)
{
super(name);
this.params = params;
this.ifNotExists = ifNotExists;
this.staticColumns = staticColumns;
this.id = id;
}