private GribCollectionProto.Variable writeVariableProto(Grib1CollectionBuilder.VariableBag vb) {
    GribCollectionProto.Variable.Builder b = GribCollectionProto.Variable.newBuilder();

    b.setDiscipline(0);
    b.setPds(ByteString.copyFrom(vb.first.getPDSsection().getRawBytes()));

    b.setRecordsPos(vb.pos);
    b.setRecordsLen(vb.length);

    for (int idx : vb.coordIndex) {
      b.addCoordIdx(idx);
    }

    // keep stats
    SparseArray sa = vb.coordND.getSparseArray();
    if (sa != null) {
      b.setNdups(sa.getNdups());
      b.setNrecords(sa.countNotMissing());
      b.setMissing(sa.countMissing());
    }

    return b.build();
  }
private GribCollectionProto.Variable writeVariableProto(Grib1CollectionBuilder.VariableBag vb) {
    GribCollectionProto.Variable.Builder b = GribCollectionProto.Variable.newBuilder();

    b.setDiscipline(0);
    b.setPds(ByteString.copyFrom(vb.first.getPDSsection().getRawBytes()));

    b.setRecordsPos(vb.pos);
    b.setRecordsLen(vb.length);

    for (int idx : vb.coordIndex) {
      b.addCoordIdx(idx);
    }

    
    SparseArray sa = vb.coordND.getSparseArray();
    if (sa != null) {
      b.setNdups(sa.getNdups());
      b.setNrecords(sa.countNotMissing());
      b.setMissing(sa.countMissing());
    }

    return b.build();
  }
private GribCollectionProto . Variable writeVariableProto ( Grib1CollectionBuilder . VariableBag vb ) { GribCollectionProto . Variable . Builder b = GribCollectionProto . Variable . newBuilder ( ) ; b . setDiscipline ( 0 ) ; b . setPds ( ByteString . copyFrom ( vb . first . getPDSsection ( ) . getRawBytes ( ) ) ) ; b . setRecordsPos ( vb . pos ) ; b . setRecordsLen ( vb . length ) ; for ( int idx : vb . coordIndex ) { b . addCoordIdx ( idx ) ; } // keep stats SparseArray sa = vb . coordND . getSparseArray ( ) ; if ( sa != null ) { b . setNdups ( sa . getNdups ( ) ) ; b . setNrecords ( sa . countNotMissing ( ) ) ; b . setMissing ( sa . countMissing ( ) ) ; } return b . build ( ) ; }
/*
message Variable {
uint32 discipline = 1;
bytes pds = 2;                   // raw pds
repeated uint32 ids = 3 [packed=true];         // extra info not in pds; grib2 id section

uint64 recordsPos = 4;  // offset of SparseArray message for this Variable
uint32 recordsLen = 5;  // size of SparseArray message for this Variable

repeated uint32 coordIdx = 6 [packed=true];    // indexes into Group.coords

optionally keep stats
uint32 ndups = 8;
uint32 nrecords = 9;
uint32 missing = 10;

partition only
repeated PartitionVariable partVariable = 100;
}
/ * message Variable { uint32 discipline = 1 ; bytes pds = 2 ; // raw pds repeated uint32 ids = 3 [ packed = true ] ; // extra info not in pds ; grib2 id section