/** * Create a VariableIndexPartitioned, add it to the given group * * @param group the new VariableIndexPartitioned is in this group * @param from copy info from here * @param nparts size of partition list * @return a new VariableIndexPartitioned */ public VariableIndexPartitioned makeVariableIndexPartitioned(GroupGC group, GribCollectionMutable.VariableIndex from, int nparts) { VariableIndexPartitioned vip = new VariableIndexPartitioned(group, from, nparts); group.addVariable(vip); if (from instanceof VariableIndexPartitioned && !isPartitionOfPartitions) { // LOOK dont really understand this VariableIndexPartitioned vipFrom = (VariableIndexPartitioned) from; assert vipFrom.partList == null; // // check if vipFrom has been finished for (int i=0; i<vipFrom.nparts; i++) vip.addPartition(vipFrom.partnoSA.get(i), vipFrom.groupnoSA.get(i), vipFrom.varnoSA.get(i), 0, 0, 0, vipFrom); } return vip; }
public void show(Formatter sb) { sb.format("VariableIndexPartitioned%n"); sb.format(" partno="); this.partnoSA.show(sb); sb.format("%n groupno="); this.groupnoSA.show(sb); sb.format("%n varno="); this.varnoSA.show(sb); //sb.format("%n flags="); //for (PartitionForVariable2D partVar : partList) // sb.format("%d,", partVar.flag); sb.format("%n"); int count = 0; sb.format(" %7s %3s %3s %6s %3s%n", "N", "dups", "Miss", "density", "partition"); // int totalN = 0, totalDups = 0, totalMiss = 0; for (int i = 0; i < nparts; i++) { int partWant = this.partnoSA.get(i); Partition part = partitions.get(partWant); sb.format(" %2d: %7d %s%n", count++, partWant, part.getFilename()); //sb.format(" %2d: %7d %3d %3d %6.2f %d %s%n", count++, partVar.nrecords, partVar.ndups, partVar.missing, partVar.density, partVar.partno, part.getFilename()); //totalN += partVar.nrecords; //totalDups += partVar.ndups; //totalMiss += partVar.missing; } //sb.format("total: %4d %3d %3d %n", totalN, totalDups, totalMiss); sb.format("%n"); // sb.format(super.toStringComplete()); // return sb.toString(); }
int partWant = this.partnoSA.get(i); Partition part = partitions.get(partWant); sb.format(" %2d: %7d %s%n", count++, partWant, part.getFilename());
private GribCollectionProto.Variable writeVariableProto(PartitionCollectionMutable.VariableIndexPartitioned vp) throws IOException { 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(); }