grib/src/main/java/ucar/nc2/grib/collection/GribPartitionBuilder.java
private GribCollectionProto.Variable writeVariableProto(PartitionCollectionMutable.VariableIndexPartitioned vp) {

    GribCollectionProto.Variable.Builder b = GribCollectionProto.Variable.newBuilder();

    b.setDiscipline(vp.discipline);
    b.setPds(ByteString.copyFrom(vp.rawPds));

    // extra id info
    b.addIds(vp.center);
    b.addIds(vp.subcenter);

    b.setRecordsPos(vp.recordsPos);
    b.setRecordsLen(vp.recordsLen);

    for (int idx : vp.coordIndex)
      b.addCoordIdx(idx);

    b.setNdups(vp.ndups);
    b.setNrecords(vp.nrecords);
    b.setMissing(vp.nmissing);

    /* if (vp.twot != null) { // only for 2D
      for (int invCount : vp.twot.getCount())
        b.addInvCount(invCount);
    }

    if (vp.time2runtime != null) { // only for 1D
      for (int idx=0; idx < vp.time2runtime.getN(); idx++)
        b.addTime2Runtime(vp.time2runtime.get(idx));
    } */

    // extensions
    if (vp.nparts > 0 && vp.partnoSA != null) {
      for (int i = 0; i < vp.nparts; i++) // PartitionCollection.PartitionForVariable2D pvar : vp.getPartitionForVariable2D())
        b.addPartVariable(writePartitionVariableProto(vp.partnoSA.get(i), vp.groupnoSA.get(i), vp.varnoSA.get(i), vp.nrecords, vp.ndups, vp.nmissing));  // LOOK was it finished ??
    }

    return b.build();
  }
private GribCollectionProto.Variable writeVariableProto(PartitionCollectionMutable.VariableIndexPartitioned vp) {

    GribCollectionProto.Variable.Builder b = GribCollectionProto.Variable.newBuilder();

    b.setDiscipline(vp.discipline);
    b.setPds(ByteString.copyFrom(vp.rawPds));

    // extra id info
    b.addIds(vp.center);
    b.addIds(vp.subcenter);

    b.setRecordsPos(vp.recordsPos);
    b.setRecordsLen(vp.recordsLen);

    for (int idx : vp.coordIndex)
      b.addCoordIdx(idx);

    b.setNdups(vp.ndups);
    b.setNrecords(vp.nrecords);
    b.setMissing(vp.nmissing);

    /* if (vp.twot != null) { // only for 2D
      for (int invCount : vp.twot.getCount())
        b.addInvCount(invCount);
    }

    if (vp.time2runtime != null) { // only for 1D
      for (int idx=0; idx < vp.time2runtime.getN(); idx++)
        b.addTime2Runtime(vp.time2runtime.get(idx));
    } */

    // extensions
    if (vp.nparts > 0 && vp.partnoSA != null) {
      for (int i = 0; i < vp.nparts; i++) // PartitionCollection.PartitionForVariable2D pvar : vp.getPartitionForVariable2D())
        b.addPartVariable(writePartitionVariableProto(vp.partnoSA.get(i), vp.groupnoSA.get(i), vp.varnoSA.get(i), vp.nrecords, vp.ndups, vp.nmissing));  // LOOK was it finished ??
    }

    return b.build();
  }
private GribCollectionProto . Variable writeVariableProto ( PartitionCollectionMutable . VariableIndexPartitioned vp ) { GribCollectionProto . Variable . Builder b = GribCollectionProto . Variable . newBuilder ( ) ; b . setDiscipline ( vp . discipline ) ; b . setPds ( ByteString . copyFrom ( vp . rawPds ) ) ; // extra id info b . addIds ( vp . center ) ; b . addIds ( vp . subcenter ) ; b . setRecordsPos ( vp . recordsPos ) ; b . setRecordsLen ( vp . recordsLen ) ; for ( int idx : vp . coordIndex ) b . addCoordIdx ( idx ) ; b . setNdups ( vp . ndups ) ; b . setNrecords ( vp . nrecords ) ; b . setMissing ( vp . nmissing ) ; /* if (vp.twot != null) { // only for 2D
      for (int invCount : vp.twot.getCount())
        b.addInvCount(invCount);
    }

    if (vp.time2runtime != null) { // only for 1D
      for (int idx=0; idx < vp.time2runtime.getN(); idx++)
        b.addTime2Runtime(vp.time2runtime.get(idx));
    } */ // extensions if ( vp . nparts > 0 && vp . partnoSA != null ) { for ( int i = 0 ; i < vp . nparts ; i ++ ) // PartitionCollection.PartitionForVariable2D pvar : vp.getPartitionForVariable2D()) b . addPartVariable ( writePartitionVariableProto ( vp . partnoSA . get ( i ) , vp . groupnoSA . get ( i ) , vp . varnoSA . get ( i ) , vp . nrecords , vp . ndups , vp . nmissing ) ) ; // LOOK was it finished ?? } 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