Search in sources :

Example 1 with ValueMetaBinary

use of org.apache.hop.core.row.value.ValueMetaBinary in project hop by apache.

the class CheckSumMeta method getFields.

@Override
public void getFields(IRowMeta inputRowMeta, String name, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider) throws HopTransformException {
    // Output field (String)
    if (!Utils.isEmpty(resultFieldName)) {
        IValueMeta v = null;
        if (checkSumType == CheckSumType.CRC32 || checkSumType == CheckSumType.ADLER32) {
            v = new ValueMetaInteger(variables.resolve(resultFieldName));
        } else {
            switch(resultType) {
                case BINARY:
                    v = new ValueMetaBinary(variables.resolve(resultFieldName));
                    break;
                default:
                    v = new ValueMetaString(variables.resolve(resultFieldName));
                    break;
            }
        }
        v.setOrigin(name);
        inputRowMeta.addValueMeta(v);
    }
}
Also used : ValueMetaBinary(org.apache.hop.core.row.value.ValueMetaBinary) IValueMeta(org.apache.hop.core.row.IValueMeta) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) ValueMetaInteger(org.apache.hop.core.row.value.ValueMetaInteger)

Example 2 with ValueMetaBinary

use of org.apache.hop.core.row.value.ValueMetaBinary in project hop by apache.

the class CheckSumTest method testHexOutput_adler32.

@Test
public void testHexOutput_adler32() throws Exception {
    MockRowListener results = executeHexTest(CheckSumMeta.CheckSumType.ADLER32, "xyz", new ValueMetaString("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals(Long.valueOf("47645036"), results.getWritten().get(0)[1]);
    results = executeHexTest(CheckSumMeta.CheckSumType.ADLER32, 10.8, new ValueMetaNumber("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals(Long.valueOf("32243912"), results.getWritten().get(0)[1]);
    results = executeHexTest(CheckSumMeta.CheckSumType.ADLER32, 10.82, new ValueMetaNumber("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals(Long.valueOf("48627962"), results.getWritten().get(0)[1]);
    byte[] input = IOUtils.toByteArray(getFile("/checksum.svg").getContent().getInputStream());
    results = executeHexTest(CheckSumMeta.CheckSumType.ADLER32, input, new ValueMetaBinary("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals(Long.valueOf("3864809454"), results.getWritten().get(0)[1]);
}
Also used : ValueMetaBinary(org.apache.hop.core.row.value.ValueMetaBinary) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) ValueMetaNumber(org.apache.hop.core.row.value.ValueMetaNumber)

Example 3 with ValueMetaBinary

use of org.apache.hop.core.row.value.ValueMetaBinary in project hop by apache.

the class CheckSumTest method testHexOutput_md5.

@Test
public void testHexOutput_md5() throws Exception {
    MockRowListener results = executeHexTest(CheckSumMeta.CheckSumType.MD5, "xyz", new ValueMetaString("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals("d16fb36f0911f878998c136191af705e", results.getWritten().get(0)[1]);
    results = executeHexTest(CheckSumMeta.CheckSumType.MD5, 10.8, new ValueMetaNumber("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals("372df98e33ac1bf6b26d225361ba7eb5", results.getWritten().get(0)[1]);
    results = executeHexTest(CheckSumMeta.CheckSumType.MD5, 10.82, new ValueMetaNumber("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals("68b142f87143c917f29d178aa1715957", results.getWritten().get(0)[1]);
    byte[] input = IOUtils.toByteArray(getFile("/checksum.svg").getContent().getInputStream());
    results = executeHexTest(CheckSumMeta.CheckSumType.MD5, input, new ValueMetaBinary("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals("056c290e3639d0f15db479810973d601", results.getWritten().get(0)[1]);
}
Also used : ValueMetaBinary(org.apache.hop.core.row.value.ValueMetaBinary) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) ValueMetaNumber(org.apache.hop.core.row.value.ValueMetaNumber)

Example 4 with ValueMetaBinary

use of org.apache.hop.core.row.value.ValueMetaBinary in project hop by apache.

the class CheckSumTest method testHexOutput_sha384.

@Test
public void testHexOutput_sha384() throws Exception {
    MockRowListener results = executeHexTest(CheckSumMeta.CheckSumType.SHA384, "xyz", new ValueMetaString("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals("edcb0f4721e6578d900e4c24ad4b19e194ab6c87f8243bfc6b11754dd8b0bbde4f30b1d18197932b6376da004dcd97c4", results.getWritten().get(0)[1]);
    results = executeHexTest(CheckSumMeta.CheckSumType.SHA384, 10.8, new ValueMetaNumber("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals("bf42c2b293b7562deca2acccc99f85b33aa150603608d610495dc45e0fb55b60c808ce466213edcf6ca184d97305b20d", results.getWritten().get(0)[1]);
    results = executeHexTest(CheckSumMeta.CheckSumType.SHA384, 10.82, new ValueMetaNumber("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals("96adb3d911a5b02f7604b9f8159d5baf21a6719162887792b7232f91fe19fefeaf9438dc1e09685a33c998897a7e76e2", results.getWritten().get(0)[1]);
    byte[] input = IOUtils.toByteArray(getFile("/checksum.svg").getContent().getInputStream());
    results = executeHexTest(CheckSumMeta.CheckSumType.SHA384, input, new ValueMetaBinary("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals("ef97e467e4fc1894abcdfd589481ff9c269322f7f2f42fde41468d7ac1f2bcd10db6f797f58e531419c886a43d1d8cd0", results.getWritten().get(0)[1]);
}
Also used : ValueMetaBinary(org.apache.hop.core.row.value.ValueMetaBinary) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) ValueMetaNumber(org.apache.hop.core.row.value.ValueMetaNumber)

Example 5 with ValueMetaBinary

use of org.apache.hop.core.row.value.ValueMetaBinary in project hop by apache.

the class CheckSumTest method testHexOutput_sha256.

@Test
public void testHexOutput_sha256() throws Exception {
    MockRowListener results = executeHexTest(CheckSumMeta.CheckSumType.SHA256, "xyz", new ValueMetaString("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals("3608bca1e44ea6c4d268eb6db02260269892c0b42b86bbf1e77a6fa16c3c9282", results.getWritten().get(0)[1]);
    results = executeHexTest(CheckSumMeta.CheckSumType.SHA256, 10.8, new ValueMetaNumber("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals("b52b603f9ec86c382a8483cad4f788f2f927535a76ad1388caedcef5e3c3c813", results.getWritten().get(0)[1]);
    results = executeHexTest(CheckSumMeta.CheckSumType.SHA256, 10.82, new ValueMetaNumber("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals("45cbb96ff9625490cd675a7a39fecad6c167c1ed9b8957f53224fcb3e4a1e4a1", results.getWritten().get(0)[1]);
    byte[] input = IOUtils.toByteArray(getFile("/org/apache/hop/pipeline/transforms/loadfileinput/files/hop.jpg").getContent().getInputStream());
    results = executeHexTest(CheckSumMeta.CheckSumType.SHA256, input, new ValueMetaBinary("test"));
    assertEquals(1, results.getWritten().size());
    assertEquals("51165cf63a5b08470272cbf75f6bfb439fad977a451866a25b5ebb3767f31872", results.getWritten().get(0)[1]);
}
Also used : ValueMetaBinary(org.apache.hop.core.row.value.ValueMetaBinary) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) ValueMetaNumber(org.apache.hop.core.row.value.ValueMetaNumber)

Aggregations

ValueMetaBinary (org.apache.hop.core.row.value.ValueMetaBinary)12 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)11 ValueMetaNumber (org.apache.hop.core.row.value.ValueMetaNumber)7 IRowMeta (org.apache.hop.core.row.IRowMeta)3 IValueMeta (org.apache.hop.core.row.IValueMeta)3 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)3 DatabaseMeta (org.apache.hop.core.database.DatabaseMeta)2 NoneDatabaseMeta (org.apache.hop.core.database.NoneDatabaseMeta)2 RowMeta (org.apache.hop.core.row.RowMeta)2 IVariables (org.apache.hop.core.variables.IVariables)2 IHopMetadataProvider (org.apache.hop.metadata.api.IHopMetadataProvider)2 ILoggingObject (org.apache.hop.core.logging.ILoggingObject)1 ValueMetaInteger (org.apache.hop.core.row.value.ValueMetaInteger)1 Pipeline (org.apache.hop.pipeline.Pipeline)1 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)1 LocalPipelineEngine (org.apache.hop.pipeline.engines.local.LocalPipelineEngine)1 Test (org.junit.Test)1