use of java.io.ByteArrayInputStream in project flink by apache.
the class FoldApplyProcessAllWindowFunction method open.
@Override
public void open(Configuration configuration) throws Exception {
FunctionUtils.openFunction(this.windowFunction, configuration);
if (serializedInitialValue == null) {
throw new RuntimeException("No initial value was serialized for the fold " + "window function. Probably the setOutputType method was not called.");
}
ByteArrayInputStream bais = new ByteArrayInputStream(serializedInitialValue);
DataInputViewStreamWrapper in = new DataInputViewStreamWrapper(bais);
initialValue = accSerializer.deserialize(in);
}
use of java.io.ByteArrayInputStream in project flink by apache.
the class FoldApplyWindowFunction method open.
@Override
public void open(Configuration configuration) throws Exception {
super.open(configuration);
if (accSerializer == null) {
throw new RuntimeException("No serializer set for the fold accumulator type. " + "Probably the setOutputType method was not called.");
}
if (serializedInitialValue == null) {
throw new RuntimeException("No initial value was serialized for the fold " + "window function. Probably the setOutputType method was not called.");
}
ByteArrayInputStream bais = new ByteArrayInputStream(serializedInitialValue);
DataInputViewStreamWrapper in = new DataInputViewStreamWrapper(bais);
initialValue = accSerializer.deserialize(in);
}
use of java.io.ByteArrayInputStream in project hadoop by apache.
the class TestConfiguration method testInputStreamResource.
public void testInputStreamResource() throws Exception {
StringWriter writer = new StringWriter();
out = new BufferedWriter(writer);
startConfig();
declareProperty("prop", "A", "A");
endConfig();
InputStream in1 = new ByteArrayInputStream(writer.toString().getBytes());
Configuration conf = new Configuration(false);
conf.addResource(in1);
assertEquals("A", conf.get("prop"));
InputStream in2 = new ByteArrayInputStream(writer.toString().getBytes());
conf.addResource(in2);
assertEquals("A", conf.get("prop"));
}
use of java.io.ByteArrayInputStream in project hadoop by apache.
the class TestConfiguration method getActualConf.
private Configuration getActualConf(String xmlStr) {
Configuration ac = new Configuration(false);
InputStream in = new ByteArrayInputStream(xmlStr.getBytes());
ac.addResource(in);
return ac;
}
use of java.io.ByteArrayInputStream in project flink by apache.
the class BlobServerPutTest method testPutStreamSuccessful.
@Test
public void testPutStreamSuccessful() {
BlobServer server = null;
BlobClient client = null;
try {
Configuration config = new Configuration();
server = new BlobServer(config);
InetSocketAddress serverAddress = new InetSocketAddress("localhost", server.getPort());
client = new BlobClient(serverAddress, config);
byte[] data = new byte[2000000];
rnd.nextBytes(data);
// put content addressable (like libraries)
{
BlobKey key1 = client.put(new ByteArrayInputStream(data));
assertNotNull(key1);
}
// put under job and name scope
{
JobID jid = new JobID();
String stringKey = "my test key";
client.put(jid, stringKey, new ByteArrayInputStream(data));
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
} finally {
if (client != null) {
try {
client.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
if (server != null) {
server.shutdown();
}
}
}
Aggregations