// sort branch heads by number of touched commit, to minimize the length of the recursive calls boolean buildMetaGraph() { Entry<Commit, ArrayList<Commit>> e; Iterator<Entry<Commit, ArrayList<Commit>>> setIt = comInB.entrySet().iterator(); int sorted[], size = comInB.keySet().size(); Integer cNum[] = new Integer[size]; Commit[] commits = new Commit[size]; ArrayList<Commit> sortedCommits = new ArrayList<Commit>(size); for (int i = 0; i < size; i++) { e = setIt.next(); commits[i] = e.getKey(); cNum[i] = e.getValue().size(); } sorted = IndexedSortable.sortedPermutation(cNum, false); for (int i = 0; i < size; i++) { sortedCommits.add(commits[sorted[i]]); } metaGraph = MetaGraph.createMetaGraph(allCommits, sortedCommits); return metaGraph.checkup(); }
String getInfo() { if (allCommits == null) return "GitMiner : uninitialized."; return "GitMiner : " + name + " ( " + id + " ) has " + allCommits.size() + " commits, " + allAuthors.size() + " authors, " + branches.size() + " forks and " + allBranches.size() + "(" + comInB.size() + " distinct) branches." + "\n\t\t**s metagraph has " + (metaGraph == null ? "not been defined yet." : metaGraph.toString()); }
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeUTF(name); out.writeLong(id); out.writeInt(allBranches.size()); Iterator<BranchRef> itb = allBranches.iterator(); while (itb.hasNext()) { itb.next().writeExternal(out); } out.writeInt(allCommits.size()); Iterator<Commit> itc = allCommits.iterator(); while (itc.hasNext()) { itc.next().writeExternal(out); } out.writeInt(allAuthors.size()); Iterator<Person> itp = allAuthors.iterator(); while (itp.hasNext()) { itp.next().writeExternal(out); } externalizeMap(branches, out); externalizeMap(comInB, out); externalizeMap(comOnlyInB, out); externalizeMap(comInF, out); externalizeMap(comOnlyInF, out); externalizeMap(comNotInF, out); externalizeMap(authOfComInB, out); externalizeMap(authOfComOnlyInB, out); externalizeMap(authOfComInF, out); externalizeMap(authOfComOnlyInF, out); externalizeMap(authOfComNotInF, out); if (metaGraph == null) out.writeInt(0); else metaGraph.writeExternal(out); out.flush(); }
@SuppressWarnings("unchecked") @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int i, j, size; BranchRef b; name = in.readUTF(); id = in.readLong(); size = in.readInt(); allBranches = new ArrayList<BranchRef>(size); for (i = 0; i < size; i++) { b = new BranchRef(); b.readExternal(in); b.index = i; allBranches.add(b); } Commit c; size = in.readInt(); allCommits = new ArrayList<Commit>(size); for (i = 0; i < size; i++) { c = new Commit(); c.readExternal(in); for (j = 0; j < c.branches.size(); j++) { c.branches.set(j, getBranchRef(c.branches.get(j).index)); } if (c.isHead()) { for (j = 0; j < c.heads.size(); j++) { c.heads.set(j, getBranchRef(c.heads.get(j).index)); } } allCommits.add(c); } Person p; size = in.readInt(); allAuthors = new ArrayList<Person>(size); for (i = 0; i < size; i++) { p = new Person(); p.readExternal(in); allAuthors.add(p); } branches = importMap(in); comInB = importMap(in); comOnlyInB = importMap(in); comInF = importMap(in); comOnlyInF = importMap(in); comNotInF = importMap(in); authOfComInB = importMap(in); authOfComOnlyInB = importMap(in); authOfComInF = importMap(in); authOfComOnlyInF = importMap(in); authOfComNotInF = importMap(in); metaGraph = new MetaGraph(allCommits); metaGraph.readExternal(in); if (!metaGraph.checkup()) System.err.println("ERROR : Metagraph checkup failed!!!"); // else // XXX // System.out.println(this.name + " post-dated commit ratio : " + // metaGraph.checkTimestamps()); //.exportToGexf(name + "_complete"); }