private void doMessage ( Socket s, DataInputStream in, DataOutputStream out, Object payload ) throws Exception { System.err.println("Reading message..."); int op = in.read(); switch ( op ) { case TransportConstants.Call: // service incoming RMI call doCall(in, out, payload); break; case TransportConstants.Ping: // send ack for ping out.writeByte(TransportConstants.PingAck); break; case TransportConstants.DGCAck: UID u = UID.read(in); break; default: throw new IOException("unknown transport op " + op); } s.close(); }
public AvroGenericRecordReader(JobConf job, FileSplit split, Reporter reporter) throws IOException { this.jobConf = job; Schema latest; try { latest = getSchema(job, split); } catch (AvroSerdeException e) { throw new IOException(e); } GenericDatumReader<GenericRecord> gdr = new GenericDatumReader<GenericRecord>(); if(latest != null) { gdr.setExpected(latest); } if (split.getLength() == 0) { this.isEmptyInput = true; this.start = 0; this.reader = null; } else { this.isEmptyInput = false; this.reader = new DataFileReader<GenericRecord>(new FsInput(split.getPath(), job), gdr); this.reader.sync(split.getStart()); this.start = reader.tell(); } this.stop = split.getStart() + split.getLength(); this.recordReaderID = new UID(); }
/** * Returns the string representation of this GUID. * * @return the string representation of this GUID. */ @Override public String toString() { return host + ":" + uid.toString(); } }
@Override public void write(DataOutput out) throws IOException { // Write schema since we need it to pull the data out. (see point #1 above) String schemaString = record.getSchema().toString(false); out.writeUTF(schemaString); schemaString = fileSchema.toString(false); out.writeUTF(schemaString); recordReaderID.write(out); // Write record to byte buffer GenericDatumWriter<GenericRecord> gdw = new GenericDatumWriter<GenericRecord>(); BinaryEncoder be = EncoderFactory.get().directBinaryEncoder((DataOutputStream)out, null); gdw.setSchema(record.getSchema()); gdw.write(record, be); }
/** * override readExternal to initialise localRef * We could actually receive anything from the server on lookup * @param in the object input * @param newFormat the new format boolean */ public void readExternal(ObjectInput in, boolean newFormat) throws IOException, ClassNotFoundException { raddr = new byte[in.readInt()]; in.read(raddr); ruid = UID.read(in); localRef = ((Arrays.equals(raddr, JInterceptorHelper.getInetAddress())) &&(ruid.equals(JInterceptorHelper.getSpaceID()))); // write initializers array in UTF String[] ia = new String [in.readInt()]; for (int i=0; i< ia.length; i++) { ia[i] = in.readUTF(); } this.initializers=ia; cis = JInterceptorStore.setRemoteInterceptors(raddr, ruid,ia); ref = LiveRef.read(in, newFormat); }
public AvroGenericRecordReader(JobConf job, FileSplit split, Reporter reporter) throws IOException { this.jobConf = job; Schema latest; try { latest = getSchema(job, split); } catch (AvroSerdeException e) { throw new IOException(e); } GenericDatumReader<GenericRecord> gdr = new GenericDatumReader<GenericRecord>(); if(latest != null) { gdr.setExpected(latest); } if (split.getLength() == 0) { this.isEmptyInput = true; this.start = 0; this.reader = null; } else { this.isEmptyInput = false; this.reader = new DataFileReader<GenericRecord>(new FsInput(split.getPath(), job), gdr); this.reader.sync(split.getStart()); this.start = reader.tell(); } this.stop = split.getStart() + split.getLength(); this.recordReaderID = new UID(); }
@Override public void writeExternal(ObjectOutput out) throws IOException { uid.write(out); }
/** * override readExternal to initialize localRef We could actually receive * anything from the server on lookup * @param in the object input * @param newFormat the new format boolean */ public void readExternal(ObjectInput in, boolean newFormat) throws IOException, ClassNotFoundException { raddr = new byte[in.readInt()]; in.read(raddr); ruid = UID.read(in); localRef = ((Arrays.equals(raddr, JInterceptorHelper.getInetAddress())) && (ruid.equals(JInterceptorHelper .getSpaceID()))); // write initializers array in UTF String[] ia = new String[in.readInt()]; for (int i = 0; i < ia.length; i++) { ia[i] = in.readUTF(); } this.initializers = ia; cis = JInterceptorStore.getJInterceptorStore().setRemoteInterceptors(ia); localId = in.readInt(); ref = LiveRef.read(in, newFormat); }
public VMID() { addr = localAddr; uid = new UID(); }
@Override public void readFields(DataInput in) throws IOException { Schema schema = AvroSerdeUtils.getSchemaFor(in.readUTF()); fileSchema = AvroSerdeUtils.getSchemaFor(in.readUTF()); recordReaderID = UID.read(in); record = new GenericData.Record(schema); binaryDecoder = DecoderFactory.defaultFactory().createBinaryDecoder((InputStream) in, binaryDecoder); GenericDatumReader<GenericRecord> gdr = new GenericDatumReader<GenericRecord>(schema); record = gdr.read(record, binaryDecoder); }
/** * override writeExternal to send spaceID And the interceptor * We could actually send anything to the client on lookup * @param out the object output * @param newFormat the boolean new format */ public void writeExternal(ObjectOutput out, boolean newFormat) throws IOException { out.writeInt(raddr.length); out.write(raddr); ruid.write(out); // write initializers array in UTF String [] ia = this.initializers; out.writeInt(ia.length); for (int i=0; i< ia.length; i++) { out.writeUTF(ia[i]); } ref.write(out, newFormat); out.flush(); } }
/** * @return space UID */ public static UID getSpaceID() { if(spaceID == null) { spaceID = new UID(); } return spaceID; }
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { uid = UID.read(in); }
@Override public void write(DataOutput out) throws IOException { // Write schema since we need it to pull the data out. (see point #1 above) String schemaString = record.getSchema().toString(false); out.writeUTF(schemaString); schemaString = fileSchema.toString(false); out.writeUTF(schemaString); recordReaderID.write(out); // Write record to byte buffer GenericDatumWriter<GenericRecord> gdw = new GenericDatumWriter<GenericRecord>(); BinaryEncoder be = EncoderFactory.get().directBinaryEncoder((DataOutputStream)out, null); gdw.setSchema(record.getSchema()); gdw.write(record, be); }
/** Internal method for creating feature id's when none is specified. */ public static String createDefaultFeatureId() { // According to GML and XML schema standards, FID is a XML ID // (http://www.w3.org/TR/xmlschema-2/#ID), whose acceptable values are those that match an // NCNAME production (http://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-NCName): // NCName ::= (Letter | '_') (NCNameChar)* /* An XML Name, minus the ":" */ // NCNameChar ::= Letter | Digit | '.' | '-' | '_' | CombiningChar | Extender // We have to fix the generated UID replacing all non word chars with an _ (it seems // they area all ":") // return "fid-" + NON_WORD_PATTERN.matcher(new UID().toString()).replaceAll("_"); // optimization, since the UID toString uses only ":" and converts long and integers // to strings for the rest, so the only non word character is really ":" return "fid-" + new UID().toString().replace(':', '_'); } /**