use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob in project sirius-biz by scireum.
the class JobStartingRoot method uploadAndTrigger.
/**
* Creates an <tt>OutputStream</tt> which triggers the given job with the given parameters once the stream is closed.
*
* @param jobToRun the job to actually run
* @param parameterProvider permits to control the parameter values for the job (the file is automatically used as
* first {@link FileParameter} of the job)
* @param filename the actual filename of the file being processed
* @return an output stream which triggers the job once the stream is closed
*/
protected OutputStream uploadAndTrigger(JobFactory jobToRun, Function<String, Value> parameterProvider, String filename) {
try {
BlobStorageSpace temporaryStorageSpace = blobStorage.getSpace(TmpRoot.TMP_SPACE);
Blob buffer = temporaryStorageSpace.createTemporaryBlob(UserContext.getCurrentUser().getTenantId());
return buffer.createOutputStream(() -> {
if (buffer.getSize() > 0) {
temporaryStorageSpace.markAsUsed(buffer);
trigger(jobToRun, parameterProvider, buffer, filename);
} else {
buffer.delete();
}
}, filename);
} catch (Exception e) {
throw Exceptions.handle(e);
}
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob in project flytekit-java by flyteorg.
the class ProtoUtilTest method shouldSerializeBlob.
@Test
void shouldSerializeBlob() {
BlobType type = BlobType.builder().dimensionality(BlobType.BlobDimensionality.MULTIPART).format("csv").build();
BlobMetadata metadata = BlobMetadata.builder().type(type).build();
Blob blob = Blob.builder().metadata(metadata).uri("file://uri").build();
Literals.Blob proto = ProtoUtil.serialize(blob);
assertThat(proto, equalTo(Literals.Blob.newBuilder().setMetadata(Literals.BlobMetadata.newBuilder().setType(Types.BlobType.newBuilder().setDimensionality(Types.BlobType.BlobDimensionality.MULTIPART).setFormat("csv").build())).setUri("file://uri").build()));
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob in project flytekit-java by flyteorg.
the class StringUtilTest method shouldSerializeLiteralMap.
@Test
void shouldSerializeLiteralMap() {
Map<String, Literal> input = new HashMap<>();
Literal integer = Literal.ofScalar(Scalar.ofPrimitive(Primitive.ofIntegerValue(1337L)));
Literal map = Literal.ofMap(singletonMap("b", integer));
Literal list = Literal.ofCollection(singletonList(integer));
BlobType type = BlobType.builder().dimensionality(BlobType.BlobDimensionality.MULTIPART).format("csv").build();
BlobMetadata metadata = BlobMetadata.builder().type(type).build();
Blob blob = Blob.builder().metadata(metadata).uri("file://test").build();
input.put("string", Literal.ofScalar(Scalar.ofPrimitive(Primitive.ofStringValue("string"))));
input.put("integer", integer);
input.put("float", Literal.ofScalar(Scalar.ofPrimitive(Primitive.ofFloatValue(2.0))));
input.put("boolean", Literal.ofScalar(Scalar.ofPrimitive(Primitive.ofBooleanValue(true))));
input.put("datetime", Literal.ofScalar(Scalar.ofPrimitive(Primitive.ofDatetime(Instant.ofEpochSecond(60L)))));
input.put("duration", Literal.ofScalar(Scalar.ofPrimitive(Primitive.ofDuration(Duration.ofSeconds(61)))));
input.put("list", list);
input.put("map", map);
input.put("listOfList", Literal.ofCollection(ImmutableList.of(list, integer)));
input.put("mapOfMap", Literal.ofMap(ImmutableMap.of("a", map, "c", integer)));
input.put("struct", Literal.ofScalar(Scalar.ofGeneric(Struct.of(ImmutableMap.<String, Struct.Value>builder().put("bool", Struct.Value.ofBoolValue(true)).put("string", Struct.Value.ofStringValue("string")).put("list", Struct.Value.ofListValue(ImmutableList.of(Struct.Value.ofNumberValue(1)))).put("number", Struct.Value.ofNumberValue(2)).put("null", Struct.Value.ofNullValue()).put("struct", Struct.Value.ofStructValue(Struct.of(ImmutableMap.of()))).build()))));
input.put("blob", Literal.ofScalar(Scalar.ofBlob(blob)));
Map<String, String> expected = new HashMap<>();
expected.put("string", "string");
expected.put("integer", "1337");
expected.put("float", "2.0");
expected.put("boolean", "true");
expected.put("datetime", "1970-01-01T00:01:00Z");
expected.put("duration", "PT1M1S");
expected.put("list", "[1337]");
expected.put("listOfList", "[[1337], 1337]");
expected.put("map", "{b=1337}");
expected.put("mapOfMap", "{a={b=1337}, c=1337}");
expected.put("struct", "{bool=true, string=string, list=[1.0], number=2.0, null=null, struct={}}");
expected.put("blob", "{uri=file://test, metadata={type={dimensionality=MULTIPART, format=csv}}}");
Map<String, String> output = StringUtil.serializeLiteralMap(input);
assertEquals(expected, output);
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob in project flytekit-java by flyteorg.
the class JacksonSdkTypeTest method testFromLiteralMap.
@Test
void testFromLiteralMap() {
Instant datetime = Instant.ofEpochSecond(12, 34);
Duration duration = Duration.ofSeconds(56, 78);
Blob blob = Blob.builder().metadata(BlobMetadata.builder().type(BLOB_TYPE).build()).uri("file://test").build();
Map<String, Literal> literalMap = new HashMap<>();
literalMap.put("i", literalOf(Primitive.ofIntegerValue(123L)));
literalMap.put("f", literalOf(Primitive.ofFloatValue(123.0)));
literalMap.put("s", literalOf(Primitive.ofStringValue("123")));
literalMap.put("b", literalOf(Primitive.ofBooleanValue(true)));
literalMap.put("t", literalOf(Primitive.ofDatetime(datetime)));
literalMap.put("d", literalOf(Primitive.ofDuration(duration)));
literalMap.put("blob", literalOf(blob));
literalMap.put("l", Literal.ofCollection(singletonList(literalOf(Primitive.ofStringValue("123")))));
literalMap.put("m", Literal.ofMap(singletonMap("marco", literalOf(Primitive.ofStringValue("polo")))));
AutoValueInput input = JacksonSdkType.of(AutoValueInput.class).fromLiteralMap(literalMap);
assertThat(input, equalTo(AutoValueInput.create(/* i= */
123L, /* f= */
123.0, /* s= */
"123", /* b= */
true, /* t= */
datetime, /* d= */
duration, /* blob= */
blob, /* l= */
singletonList("123"), /* m= */
singletonMap("marco", "polo"))));
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob in project flytekit-java by flyteorg.
the class JacksonSdkTypeTest method testToLiteralMap.
@Test
void testToLiteralMap() {
Blob blob = Blob.builder().metadata(BlobMetadata.builder().type(BLOB_TYPE).build()).uri("file://test").build();
Map<String, Literal> literalMap = JacksonSdkType.of(AutoValueInput.class).toLiteralMap(AutoValueInput.create(/* i= */
42L, /* f= */
42.0d, /* s= */
"42", /* b= */
false, /* t= */
Instant.ofEpochSecond(42, 1), /* d= */
Duration.ofSeconds(1, 42), /* blob= */
blob, /* l= */
singletonList("foo"), /* m= */
singletonMap("marco", "polo")));
Map<String, Literal> expected = new HashMap<>();
expected.put("i", literalOf(Primitive.ofIntegerValue(42L)));
expected.put("f", literalOf(Primitive.ofFloatValue(42.0d)));
expected.put("s", literalOf(Primitive.ofStringValue("42")));
expected.put("b", literalOf(Primitive.ofBooleanValue(false)));
expected.put("t", literalOf(Primitive.ofDatetime(Instant.ofEpochSecond(42, 1))));
expected.put("d", literalOf(Primitive.ofDuration(Duration.ofSeconds(1, 42))));
expected.put("l", Literal.ofCollection(singletonList(literalOf(Primitive.ofStringValue("foo")))));
expected.put("m", Literal.ofMap(singletonMap("marco", literalOf(Primitive.ofStringValue("polo")))));
expected.put("blob", literalOf(blob));
assertThat(literalMap, equalTo(expected));
}
Aggregations