/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public void readFields(DataInput in) throws IOException { super.readFields(in); // First clear the map. Otherwise we will just accumulate // entries every time this method is called. this.instance.clear(); // Read the number of entries in the map int entries = in.readInt(); // Then read each key/value pair for (int i = 0; i < entries; i++) { Writable key = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf()); key.readFields(in); Writable value = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf()); value.readFields(in); instance.put(key, value); } }
@Override public void readFields(DataInput in) throws IOException { this.leaderId = UTF8.readString(in); this.partition = in.readInt(); this.beginOffset = in.readLong(); this.offset = in.readLong(); this.checksum = in.readLong(); this.topic = in.readUTF(); this.time = in.readLong(); this.server = in.readUTF(); // left for legacy this.service = in.readUTF(); // left for legacy this.partitionMap = new MapWritable(); try { this.partitionMap.readFields(in); } catch (IOException e) { this.setServer(this.server); this.setService(this.service); } }
byte[] bytes = Base64.getDecoder().decode(configString); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); mapWritable.readFields(new DataInputStream(bais)); bais.close(); } catch (IOException e) {
hasMetadata = true; metaData = new org.apache.hadoop.io.MapWritable(); oldMetaData.readFields(in); hasMetadata = true; metaData = new org.apache.hadoop.io.MapWritable(); metaData.readFields(in);
@Override public void readFields(DataInput in) throws IOException { map.readFields(in); }
@Override public void readFields(DataInput in) throws IOException { term = in.readUTF(); field = in.readUTF(); type = in.readUTF(); date = in.readUTF(); columnVisibility = in.readUTF(); count.readFields(in); countsByColumnVisibility.readFields(in); }
public static final Properties readProperties(DataInput in) throws IOException { Properties props = new Properties(); MapWritable propsWritable = new MapWritable(); propsWritable.readFields(in); for (Entry<Writable, Writable> prop : propsWritable.entrySet()) { String key = prop.getKey().toString(); String value = prop.getValue().toString(); props.put(key,value); } return props; }
public static final Properties readProperties(DataInput in) throws IOException { Properties props = new Properties(); MapWritable propsWritable = new MapWritable(); propsWritable.readFields(in); for (Entry<Writable, Writable> prop : propsWritable.entrySet()) { String key = prop.getKey().toString(); String value = prop.getValue().toString(); props.put(key,value); } return props; }
@Override public void readFields(DataInput in) throws IOException { this.leaderId = UTF8.readString(in); this.partition = in.readInt(); this.beginOffset = in.readLong(); this.offset = in.readLong(); this.checksum = in.readLong(); this.topic = in.readUTF(); this.time = in.readLong(); this.server = in.readUTF(); // left for legacy this.service = in.readUTF(); // left for legacy this.partitionMap = new MapWritable(); try { this.partitionMap.readFields(in); } catch (IOException e) { this.setServer(this.server); this.setService(this.service); } }
@Override public void readFields(DataInput in) throws IOException { this.leaderId = UTF8.readString(in); this.partition = in.readInt(); this.beginOffset = in.readLong(); this.offset = in.readLong(); this.checksum = in.readLong(); this.topic = in.readUTF(); this.time = in.readLong(); this.server = in.readUTF(); // left for legacy this.service = in.readUTF(); // left for legacy this.partitionMap = new MapWritable(); try { this.partitionMap.readFields(in); } catch (IOException e) { this.setServer(this.server); this.setService(this.service); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public void readFields(DataInput in) throws IOException { super.readFields(in); // First clear the map. Otherwise we will just accumulate // entries every time this method is called. this.instance.clear(); // Read the number of entries in the map int entries = in.readInt(); // Then read each key/value pair for (int i = 0; i < entries; i++) { Writable key = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf()); key.readFields(in); Writable value = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf()); value.readFields(in); instance.put(key, value); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public void readFields(DataInput in) throws IOException { super.readFields(in); // First clear the map. Otherwise we will just accumulate // entries every time this method is called. this.instance.clear(); // Read the number of entries in the map int entries = in.readInt(); // Then read each key/value pair for (int i = 0; i < entries; i++) { Writable key = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf()); key.readFields(in); Writable value = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf()); value.readFields(in); instance.put(key, value); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public void readFields(DataInput in) throws IOException { super.readFields(in); // First clear the map. Otherwise we will just accumulate // entries every time this method is called. this.instance.clear(); // Read the number of entries in the map int entries = in.readInt(); // Then read each key/value pair for (int i = 0; i < entries; i++) { Writable key = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf()); key.readFields(in); Writable value = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf()); value.readFields(in); instance.put(key, value); } }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public void readFields(DataInput in) throws IOException { super.readFields(in); // First clear the map. Otherwise we will just accumulate // entries every time this method is called. this.instance.clear(); // Read the number of entries in the map int entries = in.readInt(); // Then read each key/value pair for (int i = 0; i < entries; i++) { Writable key = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf()); key.readFields(in); Writable value = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf()); value.readFields(in); instance.put(key, value); } }
@Override public void readFields(DataInput in) throws IOException { flag = in.readByte(); if (isVertexMessage()) { vertexId = GraphJobRunner.createVertexIDObject(); vertexId.readFields(in); this.numOfValues = in.readInt(); int bytesLength = in.readInt(); byte[] temp = new byte[bytesLength]; in.readFully(temp); byteBuffer.write(temp); } else if (isMapMessage()) { map = new MapWritable(); map.readFields(in); } else if (isVerticesSizeMessage()) { integerMessage = new IntWritable(); integerMessage.readFields(in); } else if (isPartitioningMessage()) { this.numOfValues = in.readInt(); int bytesLength = in.readInt(); byte[] temp = new byte[bytesLength]; in.readFully(temp); byteBuffer.write(temp); } else { vertexId = ReflectionUtils.newInstance(GraphJobRunner.VERTEX_ID_CLASS, null); vertexId.readFields(in); } }
/** * Reads a map of Strings from a DataInput. * * @param input * @return map of strings * @throws IOException */ public static Map<String,String> readMap(DataInput input) throws IOException { MapWritable mw = new MapWritable(); mw.readFields(input); Map<String,String> map = new TreeMap<>(); for (Map.Entry<Writable,Writable> entry : mw.entrySet()) { map.put(entry.getKey().toString(), entry.getValue().toString()); } return map; }
public void fastReadFields(DataInput in) throws IOException { flag = in.readByte(); if (isVertexMessage()) { vertexId = GraphJobRunner.createVertexIDObject(); vertexId.readFields(in); /* * vertexValue = GraphJobRunner.createVertexValue(); * vertexValue.readFields(in); */ } else if (isMapMessage()) { map = new MapWritable(); map.readFields(in); } else if (isVerticesSizeMessage()) { integerMessage = new IntWritable(); integerMessage.readFields(in); } else { vertexId = ReflectionUtils.newInstance(GraphJobRunner.VERTEX_ID_CLASS, null); vertexId.readFields(in); } }
public void fastReadFields(DataInput in) throws IOException { flag = in.readByte(); if (isVertexMessage()) { vertexId = GraphJobRunner.createVertexIDObject(); vertexId.readFields(in); /* * vertexValue = GraphJobRunner.createVertexValue(); * vertexValue.readFields(in); */ } else if (isMapMessage()) { map = new MapWritable(); map.readFields(in); } else if (isVerticesSizeMessage()) { integerMessage = new IntWritable(); integerMessage.readFields(in); } else { vertexId = ReflectionUtils.newInstance(GraphJobRunner.VERTEX_ID_CLASS, null); vertexId.readFields(in); } }
/** * Assert MapWritable does not grow across calls to readFields. * @throws Exception * @see <a href="https://issues.apache.org/jira/browse/HADOOP-2244">HADOOP-2244</a> */ public void testMultipleCallsToReadFieldsAreSafe() throws Exception { // Create an instance and add a key/value. MapWritable m = new MapWritable(); final Text t = new Text(getName()); m.put(t, t); // Get current size of map. Key values are 't'. int count = m.size(); // Now serialize... save off the bytes. ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); m.write(dos); dos.close(); // Now add new values to the MapWritable. m.put(new Text("key1"), new Text("value1")); m.put(new Text("key2"), new Text("value2")); // Now deserialize the original MapWritable. Ensure count and key values // match original state. ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); DataInputStream dis = new DataInputStream(bais); m.readFields(dis); assertEquals(count, m.size()); assertTrue(m.get(t).equals(t)); dis.close(); }
/** * Assert MapWritable does not grow across calls to readFields. * @throws Exception * @see <a href="https://issues.apache.org/jira/browse/HADOOP-2244">HADOOP-2244</a> */ public void testMultipleCallsToReadFieldsAreSafe() throws Exception { // Create an instance and add a key/value. MapWritable m = new MapWritable(); final Text t = new Text(getName()); m.put(t, t); // Get current size of map. Key values are 't'. int count = m.size(); // Now serialize... save off the bytes. ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); m.write(dos); dos.close(); // Now add new values to the MapWritable. m.put(new Text("key1"), new Text("value1")); m.put(new Text("key2"), new Text("value2")); // Now deserialize the original MapWritable. Ensure count and key values // match original state. ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); DataInputStream dis = new DataInputStream(bais); m.readFields(dis); assertEquals(count, m.size()); assertTrue(m.get(t).equals(t)); dis.close(); }