use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class BaseMetadataInjectionTest method check.
/**
* Check int property.
*/
protected void check(String propertyName, IntGetter getter) throws KettleException {
ValueMetaInterface valueMetaString = new ValueMetaString("f");
injector.setProperty(meta, propertyName, setValue(valueMetaString, "1"), "f");
assertEquals(1, getter.get());
injector.setProperty(meta, propertyName, setValue(valueMetaString, "45"), "f");
assertEquals(45, getter.get());
ValueMetaInterface valueMetaInteger = new ValueMetaInteger("f");
injector.setProperty(meta, propertyName, setValue(valueMetaInteger, 1234L), "f");
assertEquals(1234, getter.get());
injector.setProperty(meta, propertyName, setValue(valueMetaInteger, (long) Integer.MAX_VALUE), "f");
assertEquals(Integer.MAX_VALUE, getter.get());
skipPropertyTest(propertyName);
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class SpeedTest method populateMetaAndData.
private static void populateMetaAndData(int i, Object[] rowString10, RowMetaInterface metaString10, Object[] rowMixed10, RowMetaInterface metaMixed10) {
rowString10[i] = StringUtil.generateRandomString(20, "", "", false);
ValueMetaInterface meta = new ValueMetaString("String" + (i + 1), 20, 0);
metaString10.addValueMeta(meta);
rowMixed10[i * 5 + 0] = StringUtil.generateRandomString(20, "", "", false);
ValueMetaInterface meta0 = new ValueMetaString("String" + (i * 5 + 1), 20, 0);
metaMixed10.addValueMeta(meta0);
rowMixed10[i * 5 + 1] = new Date();
ValueMetaInterface meta1 = new ValueMetaDate("String" + (i * 5 + 1));
metaMixed10.addValueMeta(meta1);
rowMixed10[i * 5 + 2] = new Double(Math.random() * 1000000);
ValueMetaInterface meta2 = new ValueMetaNumber("String" + (i * 5 + 1), 12, 4);
metaMixed10.addValueMeta(meta2);
rowMixed10[i * 5 + 3] = new Long((long) (Math.random() * 1000000));
ValueMetaInterface meta3 = new ValueMetaInteger("String" + (i * 5 + 1), 8, 0);
metaMixed10.addValueMeta(meta3);
rowMixed10[i * 5 + 4] = Boolean.valueOf(Math.random() > 0.5 ? true : false);
ValueMetaInterface meta4 = new ValueMetaBoolean("String" + (i * 5 + 1));
metaMixed10.addValueMeta(meta4);
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class Database method getGeneratedKeys.
/**
* @param ps The prepared insert statement to use
* @return The generated keys in auto-increment fields
* @throws KettleDatabaseException in case something goes wrong retrieving the keys.
*/
public RowMetaAndData getGeneratedKeys(PreparedStatement ps) throws KettleDatabaseException {
ResultSet keys = null;
try {
// 1 row of keys
keys = ps.getGeneratedKeys();
ResultSetMetaData resultSetMetaData = keys.getMetaData();
if (resultSetMetaData == null) {
resultSetMetaData = ps.getMetaData();
}
RowMetaInterface rowMeta;
if (resultSetMetaData == null) {
rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaInteger("ai-key"));
} else {
rowMeta = getRowInfo(resultSetMetaData, false, false);
}
return new RowMetaAndData(rowMeta, getRow(keys, resultSetMetaData, rowMeta));
} catch (Exception ex) {
throw new KettleDatabaseException("Unable to retrieve key(s) from auto-increment field(s)", ex);
} finally {
if (keys != null) {
try {
keys.close();
} catch (SQLException e) {
throw new KettleDatabaseException("Unable to close resultset of auto-generated keys", e);
}
}
}
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class TableInputIT method createRowMetaInterface.
public RowMetaInterface createRowMetaInterface() {
RowMetaInterface rm = new RowMeta();
ValueMetaInterface[] valuesMeta = { new ValueMetaInteger("int_field") };
for (int i = 0; i < valuesMeta.length; i++) {
rm.addValueMeta(valuesMeta[i]);
}
return rm;
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class TextFileInputIT method createResultData2.
/**
* Create result data for test case 2. Each Object array in element in list should mirror the data written by
* writeInputFile().
*
* @return list of metadata/data couples of how the result should look like.
*/
public List<RowMetaAndData> createResultData2() {
List<RowMetaAndData> list = new ArrayList<RowMetaAndData>();
ValueMetaInterface[] valuesMeta = { new ValueMetaInteger("a", 15, -1), new ValueMetaInteger("b", 15, -1) };
RowMetaInterface rm = createResultRowMetaInterface(valuesMeta);
Object[] r1 = new Object[] { 123456L, (long) 1234567 };
Object[] r2 = new Object[] { 654321L, (long) 7654321 };
list.add(new RowMetaAndData(rm, r1));
list.add(new RowMetaAndData(rm, r2));
return list;
}
Aggregations