Search in sources :

Example 86 with ValueMetaInteger

use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.

the class ReadAllCacheTest method setUp.

@Before
public void setUp() {
    stepData = new DatabaseLookupData();
    stepData.conditions = new int[4];
    keysMeta = new RowMeta();
    keysMeta.addValueMeta(new ValueMetaInteger());
    keysMeta.addValueMeta(new ValueMetaString());
    keysMeta.addValueMeta(new ValueMetaDate());
    keysMeta.addValueMeta(new ValueMetaInteger());
    keys = new Object[][] { new Object[] { 0L, "0", new Date(0), null }, new Object[] { 0L, "0", new Date(50), null }, new Object[] { 2L, "2", new Date(200), null }, new Object[] { 1L, "1", new Date(100), null }, new Object[] { 1L, "1", new Date(150), null } };
    data = new Object[][] { new Object[] { 0 }, new Object[] { 1 }, new Object[] { 2 }, new Object[] { 3 }, new Object[] { 4 } };
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) DatabaseLookupData(org.pentaho.di.trans.steps.databaselookup.DatabaseLookupData) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Date(java.util.Date) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Before(org.junit.Before)

Example 87 with ValueMetaInteger

use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.

the class ReadAllCacheTest method lookup_Finds_WithTwoBetweenOperators.

@Test
public void lookup_Finds_WithTwoBetweenOperators() throws Exception {
    RowMeta meta = new RowMeta();
    meta.addValueMeta(new ValueMetaInteger());
    meta.addValueMeta(new ValueMetaString());
    meta.addValueMeta(new ValueMetaString());
    meta.addValueMeta(new ValueMetaDate());
    meta.addValueMeta(new ValueMetaDate());
    meta.addValueMeta(new ValueMetaInteger());
    ReadAllCache cache = buildCache(">,BETWEEN,BETWEEN,IS NULL");
    Object[] found = cache.getRowFromCache(meta, new Object[] { -1L, "1", "3", new Date(0), new Date(1000), null });
    assertArrayEquals("('1' <= keys[1] <= '3') && (0 <= keys[2] <= 1000) --> row 2", data[2], found);
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Date(java.util.Date) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Test(org.junit.Test)

Example 88 with ValueMetaInteger

use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.

the class ReadAllCacheTest method lookup_Finds_WithBetweenOperator.

@Test
public void lookup_Finds_WithBetweenOperator() throws Exception {
    RowMeta meta = keysMeta.clone();
    meta.setValueMeta(3, new ValueMetaDate());
    meta.addValueMeta(new ValueMetaInteger());
    ReadAllCache cache = buildCache("<>,IS NOT NULL,BETWEEN,IS NULL");
    Object[] found = cache.getRowFromCache(meta, new Object[] { -1L, null, new Date(140), new Date(160), null });
    assertArrayEquals("(140 <= keys[2] <= 160) --> row 4", data[4], found);
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Date(java.util.Date) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Test(org.junit.Test)

Example 89 with ValueMetaInteger

use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.

the class ReadAllCacheTest method lookup_HandlesAbsenceOfLookupValue.

@Test
public void lookup_HandlesAbsenceOfLookupValue() throws Exception {
    stepData = new DatabaseLookupData();
    stepData.conditions = new int[] { DatabaseLookupMeta.CONDITION_IS_NOT_NULL };
    ReadAllCache.Builder builder = new ReadAllCache.Builder(stepData, 2);
    RowMeta keysMeta = new RowMeta();
    keysMeta.addValueMeta(new ValueMetaInteger());
    builder.setKeysMeta(keysMeta);
    builder.add(new Object[] { null }, new Object[] { "null" });
    builder.add(new Object[] { 1L }, new Object[] { "one" });
    ReadAllCache cache = builder.build();
    Object[] found = cache.getRowFromCache(new RowMeta(), new Object[0]);
    assertArrayEquals("(keys[1] == 1L) --> row 2", new Object[] { "one" }, found);
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) DatabaseLookupData(org.pentaho.di.trans.steps.databaselookup.DatabaseLookupData) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) Test(org.junit.Test)

Example 90 with ValueMetaInteger

use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.

the class BaseMetadataInjectionTest method check.

/**
 * Check long property.
 */
protected void check(String propertyName, LongGetter 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.MAX_VALUE), "f");
    assertEquals(Long.MAX_VALUE, getter.get());
    skipPropertyTest(propertyName);
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)291 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)198 RowMeta (org.pentaho.di.core.row.RowMeta)132 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)124 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)110 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)89 Test (org.junit.Test)72 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)63 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)60 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)52 KettleException (org.pentaho.di.core.exception.KettleException)39 LongObjectId (org.pentaho.di.repository.LongObjectId)38 ObjectId (org.pentaho.di.repository.ObjectId)33 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)31 KettleStepException (org.pentaho.di.core.exception.KettleStepException)25 ArrayList (java.util.ArrayList)21 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)20 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)19 Date (java.util.Date)17 SQLException (java.sql.SQLException)16