use of org.apache.ignite.internal.schema.Column in project ignite-3 by apache.
the class RecordMarshallerImpl method collectObjectStats.
/**
* Reads mapped object fields and gather statistic.
*
* @throws MarshallerException If failed to read object content.
*/
private ObjectStatistic collectObjectStats(Columns cols, Marshaller marsh, Object obj) throws MarshallerException {
if (obj == null || !cols.hasVarlengthColumns()) {
return ObjectStatistic.ZERO_VARLEN_STATISTICS;
}
int cnt = 0;
int size = 0;
for (int i = cols.firstVarlengthColumn(); i < cols.length(); i++) {
final Column column = cols.column(i);
final Object val = marsh.value(obj, column.schemaIndex());
if (val == null || column.type().spec().fixedLength()) {
continue;
}
size += getValueSize(val, column.type());
cnt++;
}
return new ObjectStatistic(cnt, size);
}
use of org.apache.ignite.internal.schema.Column in project ignite-3 by apache.
the class SchemaDescriptorConverter method convert.
/**
* Build schema descriptor by table schema.
*
* @param schemaVer Schema version.
* @param tblCfg Table schema.
* @return SchemaDescriptor.
*/
public static SchemaDescriptor convert(int schemaVer, TableDefinition tblCfg) {
Set<String> keyColumnsNames = tblCfg.keyColumns();
List<Column> keyCols = new ArrayList<>(keyColumnsNames.size());
List<Column> valCols = new ArrayList<>(tblCfg.columns().size() - keyColumnsNames.size());
int idx = 0;
for (ColumnDefinition col : tblCfg.columns()) {
if (keyColumnsNames.contains(col.name())) {
keyCols.add(convert(idx, col));
} else {
valCols.add(convert(idx, col));
}
idx++;
}
return new SchemaDescriptor(schemaVer, keyCols.toArray(Column[]::new), tblCfg.colocationColumns().toArray(String[]::new), valCols.toArray(Column[]::new));
}
use of org.apache.ignite.internal.schema.Column in project ignite-3 by apache.
the class UpgradingRowAdapter method doubleValueBoxed.
/**
* {@inheritDoc}
*/
@Override
public Double doubleValueBoxed(int colIdx) throws InvalidTypeException {
int mappedId = mapColumn(colIdx);
Column column = mappedId < 0 ? mapper.mappedColumn(colIdx) : super.schema().column(mappedId);
if (NativeTypeSpec.DOUBLE != column.type().spec()) {
throw new SchemaException("Type conversion is not supported yet.");
}
return mappedId < 0 ? (Double) column.defaultValue() : super.doubleValueBoxed(mappedId);
}
use of org.apache.ignite.internal.schema.Column in project ignite-3 by apache.
the class UpgradingRowAdapter method longValueBoxed.
/**
* {@inheritDoc}
*/
@Override
public Long longValueBoxed(int colIdx) throws InvalidTypeException {
int mappedId = mapColumn(colIdx);
Column column = mappedId < 0 ? mapper.mappedColumn(colIdx) : super.schema().column(mappedId);
if (NativeTypeSpec.INT64 != column.type().spec()) {
throw new SchemaException("Type conversion is not supported yet.");
}
return mappedId < 0 ? (Long) column.defaultValue() : super.longValueBoxed(mappedId);
}
use of org.apache.ignite.internal.schema.Column in project ignite-3 by apache.
the class UpgradingRowAdapter method doubleValue.
/**
* {@inheritDoc}
*/
@Override
public double doubleValue(int colIdx) throws InvalidTypeException {
int mappedId = mapColumn(colIdx);
Column column = mappedId < 0 ? mapper.mappedColumn(colIdx) : super.schema().column(mappedId);
if (NativeTypeSpec.DOUBLE != column.type().spec()) {
throw new SchemaException("Type conversion is not supported yet.");
}
return mappedId < 0 ? (double) column.defaultValue() : super.doubleValue(mappedId);
}
Aggregations