mirror of https://github.com/apache/cassandra
make scrubbing collection-aware
This commit is contained in:
parent
9e0efa3dbb
commit
73b0ffba82
|
|
@ -293,16 +293,9 @@ public class Column implements IColumn
|
|||
// If this is a CQL table, we need to pull out the CQL column name to look up the correct column type.
|
||||
// (Note that COMPACT composites are handled by validateName, above.)
|
||||
ByteBuffer internalName;
|
||||
if (cfdef.isComposite && !cfdef.isCompact)
|
||||
{
|
||||
AbstractCompositeType comparator = (AbstractCompositeType) metadata.comparator;
|
||||
List<AbstractCompositeType.CompositeComponent> components = comparator.deconstruct(name);
|
||||
internalName = components.get(components.size() - 1).value;
|
||||
}
|
||||
else
|
||||
{
|
||||
internalName = name;
|
||||
}
|
||||
internalName = (cfdef.isComposite && !cfdef.isCompact)
|
||||
? ((CompositeType) metadata.comparator).extractLastComponent(name)
|
||||
: name;
|
||||
|
||||
AbstractType<?> valueValidator = metadata.getValueValidator(internalName);
|
||||
if (valueValidator != null)
|
||||
|
|
|
|||
|
|
@ -124,6 +124,30 @@ public class CompositeType extends AbstractCompositeType
|
|||
return build(serialized);
|
||||
}
|
||||
|
||||
// Extract component idx from bb. Return null if there is not enough component.
|
||||
public static ByteBuffer extractComponent(ByteBuffer bb, int idx)
|
||||
{
|
||||
bb = bb.duplicate();
|
||||
int i = 0;
|
||||
while (bb.remaining() > 0)
|
||||
{
|
||||
ByteBuffer c = getWithShortLength(bb);
|
||||
if (i == idx)
|
||||
return c;
|
||||
|
||||
bb.get(); // skip end-of-component
|
||||
++i;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Extract CQL3 column name from the full column name.
|
||||
public ByteBuffer extractLastComponent(ByteBuffer bb)
|
||||
{
|
||||
int idx = types.get(types.size() - 1) instanceof ColumnToCollectionType ? types.size() - 2 : types.size() - 1;
|
||||
return extractComponent(bb, idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatibleWith(AbstractType<?> previous)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue