scala - How to pickle in Client and Unpickle in Server? -


i have client scala code below

import java.net._ import java.io._ import scala.io._ import scala.pickling._         import scala.pickling.json._   val sk = new socket(inetaddress.getbyname("localhost"), 13373) val output = new printstream(sk.getoutputstream()) val textrdd = sc.textfile("some file"); output.println( #pickle textrdd , pass server) output.flush() sk.close() 

and python server.py below,

import socketserver import json import pickle class mytcpserver(socketserver.threadingtcpserver): allow_reuse_address = true class mytcpserverhandler(socketserver.baserequesthandler): def handle(self):     try:         data = self.request.recv(1024)              #unpickle data received here , print it.         print data     except exception, e:         print "exception wile receiving message: ", e server = mytcpserver(('127.0.0.1', 13373), mytcpserverhandler) server.serve_forever() 

how pickle textrdd file in scala client , pass python server unpickle , print received data?

i don't think able without rewriting scala-pickling in python first. scala-pickling scala-specific serialization library, not intended able serialize/deserialize arbitrary formats; designed used substitute java serialization - fast , precise serialization internal purposes.

if need send data across different languages, should consider using portable protocols , serialization formats, example, protobuf, cap'n'proto, thrift or messagepack. of them there multiple libraries in different languages, including java/scala , python.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -