org.python.core.PyUnicode Java Examples

The following examples show how to use org.python.core.PyUnicode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PythonRowDoFn.java    From components with Apache License 2.0 6 votes vote down vote up
private void flatMap(IndexedRecord input, ProcessContext context) throws IOException {
    // Prepare Python environment
    PyObject outputList = pyFn.__call__(new PyUnicode(input.toString()));

    if (outputList instanceof PyList) {
        PyList list = (PyList) outputList;
        for (Object output : list) {
            if (jsonGenericRecordConverter == null) {
                JsonSchemaInferrer jsonSchemaInferrer = new JsonSchemaInferrer(new ObjectMapper());
                Schema jsonSchema = jsonSchemaInferrer.inferSchema(output.toString());
                jsonGenericRecordConverter = new JsonGenericRecordConverter(jsonSchema);
            }
            GenericRecord outputRecord = jsonGenericRecordConverter.convertToAvro(output.toString());
            context.output(outputRecord);
        }
    }
}
 
Example #2
Source File: PythonStreamExecutionEnvironment.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private static void registerJythonSerializers(StreamExecutionEnvironment env) {
	env.registerTypeWithKryoSerializer(PyBoolean.class, PyBooleanSerializer.class);
	env.registerTypeWithKryoSerializer(PyFloat.class, PyFloatSerializer.class);
	env.registerTypeWithKryoSerializer(PyInteger.class, PyIntegerSerializer.class);
	env.registerTypeWithKryoSerializer(PyLong.class, PyLongSerializer.class);

	env.registerTypeWithKryoSerializer(PyString.class, PyStringSerializer.class);
	env.registerTypeWithKryoSerializer(PyUnicode.class, PyObjectSerializer.class);

	env.registerTypeWithKryoSerializer(PyTuple.class, PyObjectSerializer.class);
	env.registerTypeWithKryoSerializer(PyObjectDerived.class, PyObjectSerializer.class);
	env.registerTypeWithKryoSerializer(PyInstance.class, PyObjectSerializer.class);
}
 
Example #3
Source File: PythonRowDoFn.java    From components with Apache License 2.0 5 votes vote down vote up
private void map(IndexedRecord input, ProcessContext context) throws IOException {
    PyObject output = pyFn.__call__(new PyUnicode(input.toString()));

    if (jsonGenericRecordConverter == null) {
        JsonSchemaInferrer jsonSchemaInferrer = new JsonSchemaInferrer(new ObjectMapper());
        Schema jsonSchema = jsonSchemaInferrer.inferSchema(output.toString());
        jsonGenericRecordConverter = new JsonGenericRecordConverter(jsonSchema);
    }

    GenericRecord outputRecord = jsonGenericRecordConverter.convertToAvro(output.toString());
    context.output(outputRecord);
}
 
Example #4
Source File: AndroidRobot.java    From sikuli-monkey with MIT License 4 votes vote down vote up
public int type(String text) {
    _device.type(new PyObject[] { new PyUnicode(text) }, null);
    return 1;
}