@Override public Ref getRef(String needle) throws IOException { RefCache curr = readRefs(); for (String prefix : SEARCH_PATH) { DhtRef ref = curr.ids.get(prefix + needle); if (ref != null) { ref = resolve(ref, 0, curr.ids); return ref; } } return null; }
private DhtRef getOneRef(String refName) throws IOException { RefCache curr = readRefs(); DhtRef ref = curr.ids.get(refName); if (ref != null) return resolve(ref, 0, curr.ids); return ref; }
private DhtRef getOneRef(String refName) throws IOException { RefCache curr = readRefs(); DhtRef ref = curr.ids.get(refName); if (ref != null) return resolve(ref, 0, curr.ids); return ref; }
@Override public Ref getRef(String needle) throws IOException { RefCache curr = readRefs(); for (String prefix : SEARCH_PATH) { DhtRef ref = curr.ids.get(prefix + needle); if (ref != null) { ref = resolve(ref, 0, curr.ids); return ref; } } return null; }
private DhtRef resolve(DhtRef ref, int depth, RefList<DhtRef> loose) throws IOException { if (!ref.isSymbolic()) return ref; DhtRef dst = (DhtRef) ref.getTarget(); if (MAX_SYMBOLIC_REF_DEPTH <= depth) return null; // claim it doesn't exist dst = loose.get(dst.getName()); if (dst == null) return ref; dst = resolve(dst, depth + 1, loose); if (dst == null) return null; return new DhtSymbolicRef( ref.getName(), dst, ((DhtSymbolicRef) ref).getRefData()); }
private DhtRef resolve(DhtRef ref, int depth, RefList<DhtRef> loose) throws IOException { if (!ref.isSymbolic()) return ref; DhtRef dst = (DhtRef) ref.getTarget(); if (MAX_SYMBOLIC_REF_DEPTH <= depth) return null; // claim it doesn't exist dst = loose.get(dst.getName()); if (dst == null) return ref; dst = resolve(dst, depth + 1, loose); if (dst == null) return null; return new DhtSymbolicRef( ref.getName(), dst, ((DhtSymbolicRef) ref).getRefData()); }
@Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefCache curr = readRefs(); RefList<DhtRef> packed = RefList.emptyList(); RefList<DhtRef> loose = curr.ids; RefList.Builder<DhtRef> sym = new RefList.Builder<DhtRef>(curr.sym.size()); for (int idx = 0; idx < curr.sym.size(); idx++) { DhtRef ref = curr.sym.get(idx); String name = ref.getName(); ref = resolve(ref, 0, loose); if (ref != null && ref.getObjectId() != null) { sym.add(ref); } else { // A broken symbolic reference, we have to drop it from the // collections the client is about to receive. Should be a // rare occurrence so pay a copy penalty. int toRemove = loose.find(name); if (0 <= toRemove) loose = loose.remove(toRemove); } } return new RefMap(prefix, packed, loose, sym.toRefList()); }
@Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefCache curr = readRefs(); RefList<DhtRef> packed = RefList.emptyList(); RefList<DhtRef> loose = curr.ids; RefList.Builder<DhtRef> sym = new RefList.Builder<DhtRef>(curr.sym.size()); for (int idx = 0; idx < curr.sym.size(); idx++) { DhtRef ref = curr.sym.get(idx); String name = ref.getName(); ref = resolve(ref, 0, loose); if (ref != null && ref.getObjectId() != null) { sym.add(ref); } else { // A broken symbolic reference, we have to drop it from the // collections the client is about to receive. Should be a // rare occurrence so pay a copy penalty. int toRemove = loose.find(name); if (0 <= toRemove) loose = loose.remove(toRemove); } } return new RefMap(prefix, packed, loose, sym.toRefList()); }