Examples of JythonWritableWrapper


Examples of org.apache.giraph.jython.wrappers.JythonWritableWrapper

   * @return new value object
   */
  public Writable newJythonClassInstance() {
    if (useWrapper) {
      PyObject jythonObj = JythonUtils.newInstance(jythonClassName);
      JythonWritableWrapper wrapper = new JythonWritableWrapper(jythonObj);
      return wrapper;
    } else {
      return JythonUtils.newInstance(jythonClassName, writableValueClass());
    }
  }
View Full Code Here

Examples of org.apache.giraph.jython.wrappers.JythonWritableWrapper

    fooVal = foo.__getattr__("val");
    assertTrue(fooVal instanceof PyInteger);
    val = (PyInteger) fooVal;
    assertEquals(26, val.getValue());

    JythonWritableWrapper wrappedFoo = new JythonWritableWrapper(foo);
    PyObject newOtherMethod = wrappedFoo.__getattr__("new_other");

    assertTrue(newOtherMethod instanceof PyMethod);
    newOtherMethod.__call__();

    function.__call__(wrappedFoo, new PyInteger(2));

    fooVal = foo.__getattr__("val");
    assertTrue(fooVal instanceof PyInteger);
    val = (PyInteger) fooVal;
    assertEquals(30, val.getValue());

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    wrappedFoo.write(dos);

    byte[] data = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    DataInputStream dis = new DataInputStream(bais);

    PyObject foo2 = fooClass.__call__();

    PyObject foo2Val = foo2.__getattr__("val");
    assertTrue(foo2Val instanceof PyInteger);
    PyInteger val2 = (PyInteger) foo2Val;
    assertEquals(17, val2.getValue());

    JythonWritableWrapper wrappedFoo2 = new JythonWritableWrapper(foo2);

    foo2Val = wrappedFoo2.getPyObject().__getattr__("val");
    assertTrue(foo2Val instanceof PyInteger);
    val2 = (PyInteger) foo2Val;
    assertEquals(17, val2.getValue());

    wrappedFoo2.readFields(dis);

    foo2Val = wrappedFoo2.getPyObject().__getattr__("val");
    assertTrue(foo2Val instanceof PyInteger);
    val2 = (PyInteger) foo2Val;
    assertEquals(30, val2.getValue());
  }
View Full Code Here

Examples of org.apache.giraph.jython.wrappers.JythonWritableWrapper

      return (W) object;
    }
    if (getConf().getValueLanguages().get(graphType) == Language.JYTHON &&
        getConf().getValueNeedsWrappers().get(graphType)) {
      Preconditions.checkArgument(object instanceof PyObject);
      return (W) new JythonWritableWrapper((PyObject) object);
    } else {
      return (W) object;
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.