private RefList<LooseRef> getLooseRefs() { final RefList<LooseRef> oldLoose = looseRefs.get(); LooseScanner scan = new LooseScanner(oldLoose); scan.scan(ALL); RefList<LooseRef> loose; if (scan.newLoose != null) { loose = scan.newLoose.toRefList(); if (looseRefs.compareAndSet(oldLoose, loose)) modCnt.incrementAndGet(); } else loose = oldLoose; return loose; }
return all.toRefList();
/** {@inheritDoc} */ @Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefCache curr = read(); RefList<Ref> packed = RefList.emptyList(); RefList<Ref> loose = curr.ids; RefList.Builder<Ref> sym = new RefList.Builder<>(curr.sym.size()); for (int idx = 0; idx < curr.sym.size(); idx++) { Ref 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()); }
@Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefCache curr = read(); RefList<Ref> packed = RefList.emptyList(); RefList<Ref> loose = curr.ids; RefList.Builder<Ref> sym = new RefList.Builder<Ref>(curr.sym.size()); for (int idx = 0; idx < curr.sym.size(); idx++) { Ref 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()); }
private RefCache read() throws DhtException, TimeoutException { RefList.Builder<DhtRef> id = new RefList.Builder<DhtRef>(); RefList.Builder<DhtRef> sym = new RefList.Builder<DhtRef>(); ObjectIdSubclassMap<IdWithChunk> hints = new ObjectIdSubclassMap<IdWithChunk>(); for (Map.Entry<RefKey, RefData> e : scan()) { DhtRef ref = fromData(e.getKey().getName(), e.getValue()); if (ref.isSymbolic()) sym.add(ref); id.add(ref); if (ref.getObjectId() instanceof IdWithChunk && !hints.contains(ref.getObjectId())) hints.add((IdWithChunk) ref.getObjectId()); if (ref.getPeeledObjectId() instanceof IdWithChunk && !hints.contains(ref.getPeeledObjectId())) hints.add((IdWithChunk) ref.getPeeledObjectId()); } id.sort(); sym.sort(); return new RefCache(id.toRefList(), sym.toRefList(), hints); }
private RefCache read() throws DhtException, TimeoutException { RefList.Builder<DhtRef> id = new RefList.Builder<DhtRef>(); RefList.Builder<DhtRef> sym = new RefList.Builder<DhtRef>(); ObjectIdSubclassMap<IdWithChunk> hints = new ObjectIdSubclassMap<IdWithChunk>(); for (Map.Entry<RefKey, RefData> e : scan()) { DhtRef ref = fromData(e.getKey().getName(), e.getValue()); if (ref.isSymbolic()) sym.add(ref); id.add(ref); if (ref.getObjectId() instanceof IdWithChunk && !hints.contains(ref.getObjectId())) hints.add((IdWithChunk) ref.getObjectId()); if (ref.getPeeledObjectId() instanceof IdWithChunk && !hints.contains(ref.getPeeledObjectId())) hints.add((IdWithChunk) ref.getPeeledObjectId()); } id.sort(); sym.sort(); return new RefCache(id.toRefList(), sym.toRefList(), hints); }
/** {@inheritDoc} */ @Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefList.Builder<Ref> all = new RefList.Builder<>(); lock.lock(); try { Reftable table = reader(); try (RefCursor rc = ALL.equals(prefix) ? table.allRefs() : (prefix.endsWith("/") ? table.seekRefsWithPrefix(prefix) //$NON-NLS-1$ : table.seekRef(prefix))) { while (rc.next()) { Ref ref = table.resolve(rc.getRef()); if (ref != null && ref.getObjectId() != null) { all.add(ref); } } } } finally { lock.unlock(); } RefList<Ref> none = RefList.emptyList(); return new RefMap(prefix, all.toRefList(), none, none); }
@Override protected RefCache scanAllRefs() throws IOException { RefList.Builder<Ref> ids = new RefList.Builder<Ref>(); RefList.Builder<Ref> sym = new RefList.Builder<Ref>(); try { lock.readLock().lock(); for (Ref ref : refs.values()) { if (ref.isSymbolic()) sym.add(ref); ids.add(ref); } } finally { lock.readLock().unlock(); } ids.sort(); sym.sort(); objdb.getCurrentPackList().markDirty(); return new RefCache(ids.toRefList(), 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()); }
private RefList<LooseRef> getLooseRefs() { final RefList<LooseRef> oldLoose = looseRefs.get(); LooseScanner scan = new LooseScanner(oldLoose); scan.scan(ALL); RefList<LooseRef> loose; if (scan.newLoose != null) { loose = scan.newLoose.toRefList(); if (looseRefs.compareAndSet(oldLoose, loose)) modCnt.incrementAndGet(); } else loose = oldLoose; return loose; }
@Override public String toString() { return toRefList().toString(); } }
@Override public String toString() { return toRefList().toString(); } }
private RefList<LooseRef> getLooseRefs() { final RefList<LooseRef> oldLoose = looseRefs.get(); LooseScanner scan = new LooseScanner(oldLoose); scan.scan(ALL); RefList<LooseRef> loose; if (scan.newLoose != null) { loose = scan.newLoose.toRefList(); if (looseRefs.compareAndSet(oldLoose, loose)) modCnt.incrementAndGet(); } else loose = oldLoose; return loose; }
/** {@inheritDoc} */ @Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefCache curr = read(); RefList<Ref> packed = RefList.emptyList(); RefList<Ref> loose = curr.ids; RefList.Builder<Ref> sym = new RefList.Builder<>(curr.sym.size()); for (int idx = 0; idx < curr.sym.size(); idx++) { Ref 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()); }
/** {@inheritDoc} */ @Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefList.Builder<Ref> all = new RefList.Builder<>(); lock.lock(); try { Reftable table = reader(); try (RefCursor rc = ALL.equals(prefix) ? table.allRefs() : (prefix.endsWith("/") ? table.seekRefsWithPrefix(prefix) //$NON-NLS-1$ : table.seekRef(prefix))) { while (rc.next()) { Ref ref = table.resolve(rc.getRef()); if (ref != null && ref.getObjectId() != null) { all.add(ref); } } } } finally { lock.unlock(); } RefList<Ref> none = RefList.emptyList(); return new RefMap(prefix, all.toRefList(), none, none); }
@Override public String toString() { return toRefList().toString(); } }