private DataResult readData2(InputStream is) throws IOException { int psize = NcStream.readVInt(is); if (debug) System.out.println(" readData data message len= " + psize); byte[] dp = new byte[psize]; NcStream.readFully(is, dp); NcStreamProto.DataCol dproto = NcStreamProto.DataCol.parseFrom(dp); // NcStreamProto.Data2 dproto = NcStreamProto.Data2.parseDelimitedFrom(is); NcStreamDataCol decoder = new NcStreamDataCol(); Array data = decoder.decode(dproto, null); return new DataResult(dproto.getName(), data); }
public long sendData2(Variable v, Section section, OutputStream out, NcStreamCompression compress) throws IOException, InvalidRangeException { if (show) System.out.printf(" %s section=%s%n", v.getFullName(), section); boolean isVlen = v.isVariableLength(); // && v.getRank() > 1; if (isVlen) v.read(section); NcStreamDataCol encoder = new NcStreamDataCol(); NcStreamProto.DataCol dataProto = encoder.encodeData2(v.getFullName(), isVlen, section, v.read(section)); // LOOK trap error, write error message ?? // dataProto.writeDelimitedTo(out); long size = 0; size += writeBytes(out, NcStream.MAGIC_DATA2); // data version 3 byte[] datab = dataProto.toByteArray(); size += NcStream.writeVInt(out, datab.length); // dataProto len size += writeBytes(out, datab); // dataProto return size; }