builder.addField(dataRowKeySchema.getField(dataPosOffset++));
nIndexedColumns--;
}
if (viewIndexId != null) {
nIndexedColumns--;
builder.addField(new PDatum() {
@Override
public boolean isNullable() {
return false;
}
@Override
public PDataType getDataType() {
return MetaDataUtil.getViewIndexIdDataType();
}
@Override
public Integer getMaxLength() {
return null;
}
@Override
public Integer getScale() {
return null;
}
@Override
public SortOrder getSortOrder() {
return SortOrder.getDefault();
}
}, false, SortOrder.getDefault());
}
Field[] indexFields = new Field[nIndexedColumns];
BitSet viewConstantColumnBitSet = this.rowKeyMetaData.getViewConstantColumnBitSet();
// Add Field for all data row pk columns
for (int i = dataPosOffset; i < dataRowKeySchema.getFieldCount(); i++) {
// Ignore view constants from the data table, as these
// don't need to appear in the index (as they're the
// same for all rows in this index)
if (!viewConstantColumnBitSet.get(i)) {
int pos = rowKeyMetaData.getIndexPkPosition(i-dataPosOffset);
indexFields[pos] = dataRowKeySchema.getField(i);
}
}
int indexedColumnTypesIndex = 0;
for (Field indexField : indexFields) {
if (indexField == null) { // Add field for kv column in index
final PDataType dataType = indexedColumnTypes.get(indexedColumnTypesIndex++);
builder.addField(new PDatum() {
@Override
public boolean isNullable() {
return true;
}