use of org.apache.cassandra.db.marshal.UserType in project cassandra by apache.
the class AbstractRow method toString.
public String toString(TableMetadata metadata, boolean includeClusterKeys, boolean fullDetails) {
StringBuilder sb = new StringBuilder();
sb.append("Row");
if (fullDetails) {
sb.append("[info=").append(primaryKeyLivenessInfo());
if (!deletion().isLive())
sb.append(" del=").append(deletion());
sb.append(" ]");
}
sb.append(": ");
if (includeClusterKeys)
sb.append(clustering().toString(metadata));
else
sb.append(clustering().toCQLString(metadata));
sb.append(" | ");
boolean isFirst = true;
for (ColumnData cd : this) {
if (isFirst)
isFirst = false;
else
sb.append(", ");
if (fullDetails) {
if (cd.column().isSimple()) {
sb.append(cd);
} else {
ComplexColumnData complexData = (ComplexColumnData) cd;
if (!complexData.complexDeletion().isLive())
sb.append("del(").append(cd.column().name).append(")=").append(complexData.complexDeletion());
for (Cell cell : complexData) sb.append(", ").append(cell);
}
} else {
if (cd.column().isSimple()) {
Cell cell = (Cell) cd;
sb.append(cell.column().name).append('=');
if (cell.isTombstone())
sb.append("<tombstone>");
else
sb.append(cell.column().type.getString(cell.value()));
} else {
sb.append(cd.column().name).append('=');
ComplexColumnData complexData = (ComplexColumnData) cd;
Function<Cell, String> transform = null;
if (cd.column().type.isCollection()) {
CollectionType ct = (CollectionType) cd.column().type;
transform = cell -> String.format("%s -> %s", ct.nameComparator().getString(cell.path().get(0)), ct.valueComparator().getString(cell.value()));
} else if (cd.column().type.isUDT()) {
UserType ut = (UserType) cd.column().type;
transform = cell -> {
Short fId = ut.nameComparator().getSerializer().deserialize(cell.path().get(0));
return String.format("%s -> %s", ut.fieldNameAsString(fId), ut.fieldType(fId).getString(cell.value()));
};
} else {
transform = cell -> "";
}
sb.append(StreamSupport.stream(complexData.spliterator(), false).map(transform).collect(Collectors.joining(", ", "{", "}")));
}
}
}
return sb.toString();
}
Aggregations