de.akquinet.jbosscc.guttenbase.defaults.impl.DefaultSplitColumn Maven / Gradle / Ivy
The newest version!
package de.akquinet.jbosscc.guttenbase.defaults.impl;
import de.akquinet.jbosscc.guttenbase.meta.ColumnMetaData;
import de.akquinet.jbosscc.guttenbase.meta.ColumnType;
import de.akquinet.jbosscc.guttenbase.meta.TableMetaData;
import de.akquinet.jbosscc.guttenbase.tools.SplitColumn;
import java.util.List;
/**
* Sometimes the amount of data exceeds buffers. In these cases we need to split the data by some given range, usually the primary key.
* I.e., the data is read in chunks where these chunks are split using the ID column range of values.
*
* By default use the first primary key column, if any. Otherwise returns the first column with a numeric type. Otherwise return the first
* column.
*
*
* © 2012-2034 akquinet tech@spree
*
*
* @author M. Dahm
*/
public class DefaultSplitColumn implements SplitColumn {
@Override
public ColumnMetaData getSplitColumn(final TableMetaData table) {
final List columns = table.getColumnMetaData();
for (final ColumnMetaData columnMetaData : columns) {
if (columnMetaData.isPrimaryKey()) {
return columnMetaData;
}
}
for (final ColumnMetaData columnMetaData : columns) {
final String columnClassName = columnMetaData.getColumnClassName();
if (ColumnType.isSupportedClass(columnClassName)) {
final ColumnType columnType = ColumnType.valueForClass(columnClassName);
if (columnType.isNumber()) {
return columnMetaData;
}
}
}
return columns.get(0);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy