List of usage examples for java.io DataInput readInt
int readInt() throws IOException;
From source file:com.marklogic.mapreduce.MarkLogicNode.java
public void readFields(DataInput in) throws IOException { int type = in.readInt(); DocumentBuilder docBuilder = builderLocal.get(); String val = Text.readString(in); try {// w w w . j a va2 s. c o m if (type == Node.ATTRIBUTE_NODE) { AttributeImpl attr = new AttributeImpl(Text.readString(in), Text.readString(in)); node = attr.asW3cNode(docBuilder); } else { node = DomUtil.readXml(IOHelper.newStream(val)); } } catch (SAXException e) { LOG.error("error parsing input", e); throw new IOException(e); } catch (ParserConfigurationException e) { LOG.error("error parsing input", e); throw new IOException(e); } }
From source file:org.apache.geode.management.internal.configuration.messages.ConfigurationRequest.java
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { this.isRequestForEntireConfiguration = in.readBoolean(); int size = in.readInt(); Set<String> groups = new HashSet<>(); if (size > 0) { for (int i = 0; i < size; i++) { groups.add(in.readUTF());/* w w w. j a v a 2 s . co m*/ } } this.groups = groups; this.numAttempts = in.readInt(); }
From source file:org.mitre.la.mapred.io.DenseVectorWritable.java
/** * Deserialize the fields of this object from <code>in</code>. * * @param in <code>DataInput</code> to deseriablize this object from. * @throws IOException/* www . j av a 2 s.c o m*/ */ @Override public void readFields(DataInput in) throws IOException { in.readByte(); String label = in.readUTF(); int length = in.readInt(); double[] v = new double[length]; for (int i = 0; i < length; i++) { v[i] = in.readDouble(); } this.dv = new DenseVector(label, v); }
From source file:org.apache.accumulo.core.client.impl.AuthenticationTokenIdentifier.java
@Override public void readFields(DataInput in) throws IOException { int length = in.readInt(); if (length > 0) { ThriftMessageUtil msgUtil = new ThriftMessageUtil(); byte[] serialized = new byte[length]; in.readFully(serialized);/* w w w . j a v a 2 s . co m*/ impl = new TAuthenticationTokenIdentifier(); msgUtil.deserialize(serialized, impl); } }
From source file:org.apache.crunch.io.FormatBundle.java
@Override public void readFields(DataInput in) throws IOException { this.formatClass = readClass(in); int ecSize = in.readInt(); this.extraConf = Maps.newHashMap(); for (int i = 0; i < ecSize; i++) { String key = Text.readString(in); String value = Text.readString(in); extraConf.put(key, value);//w w w. ja v a 2 s . c o m } }
From source file:org.glukit.dexcom.sync.responses.ManufacturingDataDatabasePagesResponse.java
public List<ManufacturingParameters> getManufacturingParameters() { List<ManufacturingParameters> manufacturingParameters = newArrayList(); try {//from w ww . ja va2 s . c o m for (DatabasePage page : getPages()) { ByteArrayInputStream inputStream = new ByteArrayInputStream(page.getPageData()); DataInput input = this.dataInputFactory.create(inputStream); // TODO: something better than ignoring the data? long systemSeconds = UnsignedInts.toLong(input.readInt()); long displaySeconds = UnsignedInts.toLong(input.readInt()); byte[] xmlBytes = new byte[inputStream.available() - 2]; input.readFully(xmlBytes); validateCrc(input.readUnsignedShort(), page.getPageData()); XmlMapper xmlMapper = new XmlMapper(); ManufacturingParameters parameterPage = xmlMapper.readValue(new String(xmlBytes, "UTF-8"), ManufacturingParameters.class); manufacturingParameters.add(parameterPage); } return manufacturingParameters; } catch (IOException e) { throw Throwables.propagate(e); } }
From source file:edu.umn.cs.spatialHadoop.core.JTSShape.java
@Override public void readFields(DataInput in) throws IOException { try {//from w ww .j a v a 2 s . co m byte[] wkb = new byte[in.readInt()]; in.readFully(wkb); geom = wkbReader.read(wkb); } catch (ParseException e) { e.printStackTrace(); throw new IOException(e); } }
From source file:org.apache.hama.bsp.Directive.java
public void readFields(DataInput in) throws IOException { this.timestamp = in.readLong(); int t = in.readInt(); if (Directive.Type.Request.value() == t) { this.type = Directive.Type.Request; int length = WritableUtils.readVInt(in); if (length > 0) { this.actionList = new ArrayList<GroomServerAction>(); for (int i = 0; i < length; ++i) { GroomServerAction.ActionType actionType = WritableUtils.readEnum(in, GroomServerAction.ActionType.class); GroomServerAction action = GroomServerAction.createAction(actionType); action.readFields(in);/* w w w .j av a 2 s . c o m*/ actionList.add(action); } } else { this.actionList = null; } String[] groomServerNames = WritableUtils.readCompressedStringArray(in); String[] groomServerAddresses = WritableUtils.readCompressedStringArray(in); groomServerPeers = new HashMap<String, String>(groomServerNames.length); for (int i = 0; i < groomServerNames.length; i++) { groomServerPeers.put(groomServerNames[i], groomServerAddresses[i]); } } else if (Directive.Type.Response.value() == t) { this.type = Directive.Type.Response; this.status = new GroomServerStatus(); this.status.readFields(in); } else { throw new IllegalStateException("Wrong directive type:" + t); } }
From source file:edu.umn.cs.spatialHadoop.indexing.BTRPartitioner.java
@Override public void readFields(DataInput in) throws IOException { mbr.readFields(in);/* w ww .j a va 2 s. c om*/ columns = in.readInt(); rows = in.readInt(); xSplits = new double[columns]; ySplits = new double[columns * rows]; int bufferLength = (xSplits.length + ySplits.length) * 8; byte[] buffer = new byte[bufferLength]; in.readFully(buffer); ByteBuffer bbuffer = ByteBuffer.wrap(buffer); for (int i = 0; i < xSplits.length; i++) xSplits[i] = bbuffer.getDouble(); for (int i = 0; i < ySplits.length; i++) ySplits[i] = bbuffer.getDouble(); if (bbuffer.hasRemaining()) throw new RuntimeException("Error reading STR partitioner"); }
From source file:org.cloudata.core.tabletserver.CommitLog.java
public void readFields(DataInput in) throws IOException { operation = in.readInt(); rowKey.readFields(in);//from w w w .j ava 2s . c o m columnName = CWritableUtils.readString(in); columnKey.readFields(in); timestamp = in.readLong(); int length = in.readInt(); if (length > MAX_VALUE_SIZE) { LOG.error("number of bytes in commitlog exceeds CommitLog.MAX_VALUE_SIZE[" + MAX_VALUE_SIZE + "]"); throw new IOException("data size is too long.[" + length + "]"); } if (length >= 0) { value = new byte[length]; in.readFully(value); } }