public void finish() { if (partList == null) return; // nothing to do if (partList.size() > nparts) System.out.println("PartitionCollectionMutable partList.size() > nparts"); // might be smaller due to failed partition int[] partno = new int[nparts]; int[] groupno = new int[nparts]; int[] varno = new int[nparts]; int count = 0; for (PartitionForVariable2D part : partList) { partno[count] = part.partno; groupno[count] = part.groupno; varno[count] = part.varno; count++; } this.partnoSA = new SmartArrayInt(partno); this.groupnoSA = new SmartArrayInt(groupno); this.varnoSA = new SmartArrayInt(varno); partList = null; // GC }
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(); }
throw new IllegalStateException(); int partWant = vip.partnoSA.findIdx(partno); // which partition ? index into PartitionCollectionImmutable.partitions[]. variable doesnt have to exist in all partitions if (partWant < 0 || partWant >= vip.nparts) { if (Grib.debugRead) System.out.printf(" cant find partition=%d in vip=%s%n", partno, vip); GribCollectionImmutable.GroupGC g = ds.groups.get(vip.groupnoSA.get(partWant)); // LOOK partWant vs partno ?? GribCollectionImmutable.VariableIndex vindex = g.variList.get(vip.varnoSA.get(partWant)); vindex.readRecords(); return vindex;
/** * 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; }
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(); }
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); int partWant = this.partnoSA.get(i); Partition part = partitions.get(partWant); sb.format(" %2d: %7d %s%n", count++, partWant, part.getFilename());
public void setPartitions(List<GribCollectionProto.PartitionVariable> pvList) { int[] partno = new int[nparts]; int[] groupno = new int[nparts]; int[] varno = new int[nparts]; int count = 0; for (GribCollectionProto.PartitionVariable part : pvList) { partno[count] = part.getPartno(); groupno[count] = part.getGroupno(); varno[count] = part.getVarno(); count++; } this.partnoSA = new SmartArrayInt(partno); this.groupnoSA = new SmartArrayInt(groupno); this.varnoSA = new SmartArrayInt(varno); partList = null; // GC }