use of org.apache.ignite.internal.schema.Column in project ignite-3 by apache.
the class UpgradingRowAdapter method stringValue.
/**
* {@inheritDoc}
*/
@Override
public String stringValue(int colIdx) throws InvalidTypeException {
int mappedId = mapColumn(colIdx);
Column column = mappedId < 0 ? mapper.mappedColumn(colIdx) : super.schema().column(mappedId);
if (NativeTypeSpec.STRING != column.type().spec()) {
throw new SchemaException("Type conversion is not supported yet.");
}
return mappedId < 0 ? (String) column.defaultValue() : super.stringValue(mappedId);
}
use of org.apache.ignite.internal.schema.Column in project ignite-3 by apache.
the class UpgradingRowAdapter method floatValueBoxed.
/**
* {@inheritDoc}
*/
@Override
public Float floatValueBoxed(int colIdx) throws InvalidTypeException {
int mappedId = mapColumn(colIdx);
Column column = mappedId < 0 ? mapper.mappedColumn(colIdx) : super.schema().column(mappedId);
if (NativeTypeSpec.FLOAT != column.type().spec()) {
throw new SchemaException("Type conversion is not supported yet.");
}
return mappedId < 0 ? (Float) column.defaultValue() : super.floatValueBoxed(mappedId);
}
use of org.apache.ignite.internal.schema.Column in project ignite-3 by apache.
the class UpgradingRowAdapter method timestampValue.
/**
* {@inheritDoc}
*/
@Override
public Instant timestampValue(int colIdx) throws InvalidTypeException {
int mappedId = mapColumn(colIdx);
Column column = mappedId < 0 ? mapper.mappedColumn(colIdx) : super.schema().column(mappedId);
if (NativeTypeSpec.TIMESTAMP != column.type().spec()) {
throw new SchemaException("Type conversion is not supported yet.");
}
return mappedId < 0 ? (Instant) column.defaultValue() : super.timestampValue(mappedId);
}
use of org.apache.ignite.internal.schema.Column in project ignite-3 by apache.
the class SchemaSerializerImpl method writeTo.
/**
* {@inheritDoc}
*/
@Override
public void writeTo(SchemaDescriptor desc, ByteBuffer byteBuf) {
byteBuf.putShort(SCHEMA_VER);
byteBuf.putInt(desc.version());
appendColumns(desc.keyColumns(), byteBuf);
appendColumns(desc.valueColumns(), byteBuf);
Column[] colocationCols = desc.colocationColumns();
byteBuf.putInt(colocationCols.length);
for (Column column : colocationCols) {
appendString(column.name(), byteBuf);
}
appendColumnMapping(desc.columnMapping(), desc.length(), byteBuf);
}
use of org.apache.ignite.internal.schema.Column in project ignite-3 by apache.
the class SchemaSerializerImpl method readColumnMapping.
/**
* Reads column mapping from byte buffer.
*
* @param desc SchemaDescriptor.
* @param buf Byte buffer.
* @return ColumnMapper object.
*/
private ColumnMapper readColumnMapping(SchemaDescriptor desc, ByteBuffer buf) {
int mappingSize = buf.getInt();
if (mappingSize == 0) {
return ColumnMapping.identityMapping();
}
ColumnMapper mapper = ColumnMapping.createMapper(desc);
for (int i = 0; i < mappingSize; i++) {
int from = buf.getInt();
int to = buf.getInt();
if (to == -1) {
Column col = readColumn(buf);
mapper.add(col);
} else {
mapper.add(from, to);
}
}
return mapper;
}
Aggregations