/** * Reads the string following a <code>Type.STRING</code> code. * * @return the obtained string * @throws IOException */ public String readString() throws IOException { return WritableUtils.readString(in); }
public static String[] readStringArray(DataInput in) throws IOException { int len = in.readInt(); if (len == -1) return null; String[] s = new String[len]; for(int i = 0; i < len; i++) { s[i] = readString(in); } return s; }
@Override public void readFields(DataInput in) throws IOException { primitiveCategory = WritableUtils.readEnum(in, PrimitiveObjectInspector.PrimitiveCategory.class); typeName = WritableUtils.readString(in); try { primitiveJavaType = Class.forName(WritableUtils.readString(in)); primitiveJavaClass = Class.forName(WritableUtils.readString(in)); primitiveWritableClass = Class.forName(WritableUtils.readString(in)); } catch (ClassNotFoundException e) { throw new IOException(e); } }
private static void readStatus(DataInputStream inStream) throws IOException { int status = inStream.readInt(); // read status if (status != SaslStatus.SUCCESS.state) { throw new RemoteException(WritableUtils.readString(inStream), WritableUtils.readString(inStream)); } }
@SuppressWarnings("unchecked") @Override public void readFields(DataInput input) throws IOException { String partitionInfoString = WritableUtils.readString(input); partitionInfo = (PartInfo) HCatUtil.deserialize(partitionInfoString); String baseSplitClassName = WritableUtils.readString(input); org.apache.hadoop.mapred.InputSplit split; try { Class<? extends org.apache.hadoop.mapred.InputSplit> splitClass = (Class<? extends org.apache.hadoop.mapred.InputSplit>) JavaUtils.loadClass(baseSplitClassName); //Class.forName().newInstance() does not work if the underlying //InputSplit has package visibility Constructor<? extends org.apache.hadoop.mapred.InputSplit> constructor = splitClass.getDeclaredConstructor(new Class[]{}); constructor.setAccessible(true); split = constructor.newInstance(); // read baseSplit from input ((Writable) split).readFields(input); this.baseMapRedSplit = split; } catch (Exception e) { throw new IOException("Exception from " + baseSplitClassName, e); } }
public ByteBuffer readResponse() throws IOException { int length = in.readInt(); if (firstResponse) { firstResponse = false; // pre-rpcv9 exception, almost certainly a version mismatch. if (length == -1) { in.readInt(); // ignore fatal/error status, it's fatal for us. throw new RemoteException(WritableUtils.readString(in), WritableUtils.readString(in)); } } if (length <= 0) { throw new RpcException("RPC response has invalid length"); } if (maxResponseLength > 0 && length > maxResponseLength) { throw new RpcException("RPC response exceeds maximum data length"); } ByteBuffer bb = ByteBuffer.allocate(length); in.readFully(bb.array()); return bb; }
@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)); } }
public Writable readWritable(Writable writable) throws IOException { DataInputStream dis = null; try { ByteArrayInputStream bais = new ByteArrayInputStream(in.readBytes()); dis = new DataInputStream(bais); String className = WritableUtils.readString(dis); if (writable == null) { try { Class<? extends Writable> cls = conf.getClassByName(className) .asSubclass(Writable.class); writable = (Writable) ReflectionUtils.newInstance(cls, conf); } catch (ClassNotFoundException e) { throw new IOException(e); } } else if (!writable.getClass().getName().equals(className)) { throw new IOException("wrong Writable class given"); } writable.readFields(dis); dis.close(); dis = null; return writable; } finally { IOUtils.closeStream(dis); } }
@Override public void readFields(DataInput in) throws IOException { if (in.readBoolean()) { this.peerName = WritableUtils.readString(in); } if (in.readBoolean()) { this.remoteIdentifier = WritableUtils.readString(in); } if (in.readBoolean()) { this.sourceTableId = Table.ID.of(WritableUtils.readString(in)); } }
private static void readStatus(DataInputStream inStream) throws IOException { int status = inStream.readInt(); // read status if (status != SaslStatus.SUCCESS.state) { throw new RemoteException(WritableUtils.readString(inStream), WritableUtils.readString(inStream)); } }
/** * @since 1.5.0 * @see Writable */ @Override public void readFields(DataInput din) throws IOException { priority = WritableUtils.readVInt(din); name = WritableUtils.readString(din); iteratorClass = WritableUtils.readString(din); properties.clear(); int size = WritableUtils.readVInt(din); while (size > 0) { properties.put(WritableUtils.readString(din), WritableUtils.readString(din)); size--; } }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); this.tenantId = PNameFactory.newName(WritableUtils.readString(input)); this.functionClassName = WritableUtils.readString(input); String str = WritableUtils.readString(input); this.jarPath = str.length() == 0 ? null: str; constructUDFFunction(); }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); dateFormat = WritableUtils.readString(input); dateParser = DateUtil.getDateParser(dateFormat); }
@Override public void readFields(DataInput input) throws IOException { tableName = WritableUtils.readString(input); rowkey = new ImmutableBytesWritable(); rowkey.readFields(input); }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); formatString = WritableUtils.readString(input); type = WritableUtils.readEnum(input, FunctionArgumentType.class); formatter = type.getFormatter(formatString); }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); formatString = WritableUtils.readString(input); type = WritableUtils.readEnum(input, FunctionArgumentType.class); if (formatString != null) { format = type.getFormatter(formatString); } }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); formatString = WritableUtils.readString(input); type = WritableUtils.readEnum(input, FunctionArgumentType.class); formatter = type.getFormatter(formatString); }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); formatString = WritableUtils.readString(input); type = WritableUtils.readEnum(input, FunctionArgumentType.class); if (formatString != null) { format = type.getFormatter(formatString); } }
@Override public void readFields(DataInput input) throws IOException { regionLocation = WritableUtils.readString(input); regionSize = WritableUtils.readVLong(input); int count = WritableUtils.readVInt(input); scans = Lists.newArrayListWithExpectedSize(count); for (int i = 0; i < count; i++) { byte[] protoScanBytes = new byte[WritableUtils.readVInt(input)]; input.readFully(protoScanBytes); ClientProtos.Scan protoScan = ClientProtos.Scan.parseFrom(protoScanBytes); Scan scan = ProtobufUtil.toScan(protoScan); scans.add(scan); } init(); }
@Override public void readFields(DataInput in) throws IOException { super.readFields(in); int count = WritableUtils.readVInt(in); scans = Lists.newArrayListWithExpectedSize(count); for (int i = 0; i < count; i++) { byte[] protoScanBytes = new byte[WritableUtils.readVInt(in)]; in.readFully(protoScanBytes); ClientProtos.Scan protoScan = ClientProtos.Scan.parseFrom(protoScanBytes); Scan scan = ProtobufUtil.toScan(protoScan); scans.add(scan); } init(); query = WritableUtils.readString(in); regionSize = WritableUtils.readVLong(in); }