rowVal = null; } else { rowVal = ((ObjectWritable)value).get();
@Override @SuppressWarnings("deprecation") public void readFields(DataInput in) throws IOException { rpcVersion = in.readLong(); declaringClassProtocolName = UTF8.readString(in); methodName = UTF8.readString(in); clientVersion = in.readLong(); clientMethodsHash = in.readInt(); parameters = new Object[in.readInt()]; parameterClasses = new Class[parameters.length]; ObjectWritable objectWritable = new ObjectWritable(); for (int i = 0; i < parameters.length; i++) { parameters[i] = ObjectWritable.readObject(in, objectWritable, this.conf); parameterClasses[i] = objectWritable.getDeclaredClass(); } }
public ObjectWritable(Object instance) { set(instance); }
@Override @SuppressWarnings("unchecked") public void readFields(DataInput in) throws IOException { int length = in.readInt(); if (length == -1) this.value = null; else if (length == 0) { this.elementType = (Class<E>) ObjectWritable.loadClass(conf, WritableUtils.readString(in)); this.value = EnumSet.noneOf(this.elementType); } else { E first = (E) ObjectWritable.readObject(in, conf); this.value = (EnumSet<E>) EnumSet.of(first); for (int i = 1; i < length; i++) this.value.add((E) ObjectWritable.readObject(in, conf)); } }
Class<?> declaredClass = PRIMITIVE_NAMES.get(className); if (declaredClass == null) { declaredClass = loadClass(conf, className); instance = Array.newInstance(declaredClass.getComponentType(), length); for (int i = 0; i < length; i++) { Array.set(instance, i, readObject(in, conf)); instance = Enum.valueOf((Class<? extends Enum>) declaredClass, UTF8.readString(in)); } else if (Message.class.isAssignableFrom(declaredClass)) { instance = tryInstantiateProtobuf(declaredClass, in); } else { // Writable Class instanceClass = null; String str = UTF8.readString(in); instanceClass = loadClass(conf, str);
private void readObject(ObjectInputStream in) throws IOException { ObjectWritable ow = new ObjectWritable(); ow.setConf(new Configuration(false)); ow.readFields(in); this.inputSplit = (InputSplit) ow.get(); }
public Object encode(Record record) throws SerializationError { try { ObjectWritable blob = new ObjectWritable(record); return serde.deserialize(blob); } catch (SerDeException e) { throw new SerializationError("Unable to convert Record into Object", e); } }
/** Write a {@link Writable}, {@link String}, primitive type, or an array of * the preceding. */ public static void writeObject(DataOutput out, Object instance, Class declaredClass, Configuration conf) throws IOException { writeObject(out, instance, declaredClass, conf, false); }
@SuppressWarnings("unchecked") public void testSerializeAndDeserializeNonEmpty() throws IOException { DataOutputBuffer out = new DataOutputBuffer(); ObjectWritable.writeObject(out, nonEmptyFlagWritable, nonEmptyFlagWritable .getClass(), null); DataInputBuffer in = new DataInputBuffer(); in.reset(out.getData(), out.getLength()); EnumSet<TestEnumSet> read = ((EnumSetWritable<TestEnumSet>) ObjectWritable .readObject(in, null)).get(); assertEquals(read, nonEmptyFlag); }
@Override public void notify(final CentroidPairing<Object> pairing) { pairing.getPairedItem().setGroupID(pairing.getCentroid().getID()); pairing.getPairedItem().setZoomLevel(pairing.getCentroid().getZoomLevel() + 1); // just get the contents of the returned ObjectWritable to // avoid // having to assign outputValWritable rather than update its // contents. // the 'toWritabeValue' method is efficient, not creating an // extra instance of // ObjectWritable each time, so this is just a simple // exchange of a reference outputValWritable.set( toWritableValue(key, pairing.getPairedItem().getWrappedItem()).get()); AtomicInteger ii = logCounts.get(pairing.getCentroid().getID()); if (ii == null) { ii = new AtomicInteger(0); logCounts.put(pairing.getCentroid().getID(), ii); } ii.incrementAndGet(); } };
/** Read a {@link Writable}, {@link String}, primitive type, or an array of * the preceding. */ public static Object readObject(DataInput in, Configuration conf) throws IOException { return readObject(in, null, conf); }
@Override public void readFields(DataInput in) throws IOException { this.stageName = Text.readString(in); this.recordWritable.readFields(in); this.record = (RECORD) recordWritable.get(); }
private void writeObject(ObjectOutputStream out) throws IOException { new ObjectWritable(inputSplit).write(out); } }
@Override public void setConf(Configuration conf) { this.conf = conf; recordWritable = new ObjectWritable(); // ObjectWritable does not set conf while reading fields recordWritable.setConf(conf); }
Method parseMethod = getStaticProtobufMethod(protoClass, "parseDelimitedFrom", InputStream.class); return (Message)parseMethod.invoke(null, (InputStream)dataIn); Method parseMethod = getStaticProtobufMethod(protoClass, "parseFrom", byte[].class); return (Message)parseMethod.invoke(null, data);
private void readObject(ObjectInputStream in) throws IOException { ObjectWritable ow = new ObjectWritable(); ow.setConf(new Configuration(false)); ow.readFields(in); this.inputSplit = (InputSplit) ow.get(); }
Class<?> declaredClass = PRIMITIVE_NAMES.get(className); if (declaredClass == null) { declaredClass = loadClass(conf, className); instance = Array.newInstance(declaredClass.getComponentType(), length); for (int i = 0; i < length; i++) { Array.set(instance, i, readObject(in, conf)); instance = Enum.valueOf((Class<? extends Enum>) declaredClass, UTF8.readString(in)); } else if (Message.class.isAssignableFrom(declaredClass)) { instance = tryInstantiateProtobuf(declaredClass, in); } else { // Writable Class instanceClass = null; String str = UTF8.readString(in); instanceClass = loadClass(conf, str);
for (Entry<String, Object> entry : record.entrySet()) { value.put(new Text(entry.getKey()), entry.getValue() == null ? NullWritable.get() : new ObjectWritable(entry.getValue()));
@Override public void write(DataOutput out) throws IOException { writeObject(out, instance, declaredClass, conf); }
@SuppressWarnings("unchecked") public void testSerializeAndDeserializeNonEmpty() throws IOException { DataOutputBuffer out = new DataOutputBuffer(); ObjectWritable.writeObject(out, nonEmptyFlagWritable, nonEmptyFlagWritable .getClass(), null); DataInputBuffer in = new DataInputBuffer(); in.reset(out.getData(), out.getLength()); EnumSet<TestEnumSet> read = ((EnumSetWritable<TestEnumSet>) ObjectWritable .readObject(in, null)).get(); assertEquals(read, nonEmptyFlag); }