code
stringlengths
73
34.1k
label
stringclasses
1 value
public long getMemoryUsageBytes() { long total = 0; for (int i = 0; i < maps_.length; i++) { if (maps_[i] != null) { total += maps_[i].getMemoryUsageBytes(); } } return total; }
java
public long getKeyMemoryUsageBytes() { long total = 0; for (int i = 0; i < maps_.length; i++) { if (maps_[i] != null) { total += (long) (maps_[i].getActiveEntries()) * keySizeBytes_; } } return total; }
java
int getActiveMaps() { int levels = 0; final int iMapsLen = maps_.length; for (int i = 0; i < iMapsLen; i++) { if (maps_[i] != null) { levels++; } } return levels; }
java
private boolean propagateToSharedSketch(final long hash) { //noinspection StatementWithEmptyBody while (localPropagationInProgress.get()) { } //busy wait until previous propagation completed localPropagationInProgress.set(true); final boolean res = shared.propagate(localPropagationInProgress, null, ...
java
private void propagateToSharedSketch() { //noinspection StatementWithEmptyBody while (localPropagationInProgress.get()) { } //busy wait until previous propagation completed final CompactSketch compactSketch = compact(propagateOrderedCompact, null); localPropagationInProgress.set(true); shared.p...
java
private int countValidLevelsBelow(final int tgtLvl) { int count = 0; long bitPattern = ds_.getBitPattern(); for (int i = 0; (i < tgtLvl) && (bitPattern > 0); ++i, bitPattern >>>= 1) { if ((bitPattern & 1L) > 0L) { ++count; } } return count; // shorter implementation, testing...
java
static void checkFamilyID(final int familyID) { final Family family = Family.idToFamily(familyID); if (!family.equals(Family.QUANTILES)) { throw new SketchesArgumentException( "Possible corruption: Invalid Family: " + family.toString()); } }
java
static boolean checkPreLongsFlagsCap(final int preambleLongs, final int flags, final long memCapBytes) { final boolean empty = (flags & EMPTY_FLAG_MASK) > 0; //Preamble flags empty state final int minPre = Family.QUANTILES.getMinPreLongs(); //1 final int maxPre = Family.QUANTILES.getMaxPreLongs(); //2 f...
java
static void checkHeapFlags(final int flags) { //only used by checkPreLongsFlagsCap and test final int allowedFlags = READ_ONLY_FLAG_MASK | EMPTY_FLAG_MASK | COMPACT_FLAG_MASK | ORDERED_FLAG_MASK; final int flagsMask = ~allowedFlags; if ((flags & flagsMask) > 0) { throw new SketchesArgumentExc...
java
static boolean checkIsCompactMemory(final Memory srcMem) { // only reading so downcast is ok final int flags = extractFlags(srcMem); final int compactFlags = READ_ONLY_FLAG_MASK | COMPACT_FLAG_MASK; return (flags & compactFlags) > 0; }
java
static final void checkSplitPointsOrder(final double[] values) { if (values == null) { throw new SketchesArgumentException("Values cannot be null."); } final int lenM1 = values.length - 1; for (int j = 0; j < lenM1; j++) { if (values[j] < values[j + 1]) { continue; } throw new Sketches...
java
static int computeRetainedItems(final int k, final long n) { final int bbCnt = computeBaseBufferItems(k, n); final long bitPattern = computeBitPattern(k, n); final int validLevels = computeValidLevels(bitPattern); return bbCnt + (validLevels * k); }
java
static int lowLevelCompressBytes( final byte[] byteArray, // input final int numBytesToEncode, // input, must be an int final short[] encodingTable, // input final int[] compressedWords) { // output int nextWordIndex = 0; long bitBuf = 0; // bits are packed into thi...
java
private static int[] uncompressTheSurprisingValues(final CompressedState source) { final int srcK = 1 << source.lgK; final int numPairs = source.numCsv; assert numPairs > 0; final int[] pairs = new int[numPairs]; final int numBaseBits = CpcCompression.golombChooseNumberOfBaseBits(srcK + numPairs, nu...
java
private static int[] trickyGetPairsFromWindow(final byte[] window, final int k, final int numPairsToGet, final int emptySpace) { final int outputLength = emptySpace + numPairsToGet; final int[] pairs = new int[outputLength]; int rowIndex = 0; int pairIndex = emptySpace; for (rowIndex = 0; rowI...
java
private static void compressHybridFlavor(final CompressedState target, final CpcSketch source) { final int srcK = 1 << source.lgK; final PairTable srcPairTable = source.pairTable; final int srcNumPairs = srcPairTable.getNumPairs(); final int[] srcPairArr = PairTable.unwrappingGetItems(srcPairTable, srcN...
java
private static void compressSlidingFlavor(final CompressedState target, final CpcSketch source) { compressTheWindow(target, source); final PairTable srcPairTable = source.pairTable; final int numPairs = srcPairTable.getNumPairs(); if (numPairs > 0) { final int[] pairs = PairTable.unwrappingGetI...
java
public void update(final float value) { if (Float.isNaN(value)) { return; } if (isEmpty()) { minValue_ = value; maxValue_ = value; } else { if (value < minValue_) { minValue_ = value; } if (value > maxValue_) { maxValue_ = value; } } if (levels_[0] == 0) { compressWhile...
java
public void merge(final KllFloatsSketch other) { if ((other == null) || other.isEmpty()) { return; } if (m_ != other.m_) { throw new SketchesArgumentException("incompatible M: " + m_ + " and " + other.m_); } final long finalN = n_ + other.n_; for (int i = other.levels_[0]; i < other.levels_[1]...
java
public float getQuantile(final double fraction) { if (isEmpty()) { return Float.NaN; } if (fraction == 0.0) { return minValue_; } if (fraction == 1.0) { return maxValue_; } if ((fraction < 0.0) || (fraction > 1.0)) { throw new SketchesArgumentException("Fraction cannot be less than zero or greater...
java
public static int getKFromEpsilon(final double epsilon, final boolean pmf) { //Ensure that eps is >= than the lowest possible eps given MAX_K and pmf=false. final double eps = max(epsilon, 4.7634E-5); final double kdbl = pmf ? exp(log(2.446 / eps) / 0.9433) : exp(log(2.296 / eps) / 0.9723); ...
java
public byte[] toByteArray() { final byte[] bytes = new byte[getSerializedSizeBytes()]; final boolean isSingleItem = n_ == 1; bytes[PREAMBLE_INTS_BYTE] = (byte) (isEmpty() || isSingleItem ? PREAMBLE_INTS_SHORT : PREAMBLE_INTS_FULL); bytes[SER_VER_BYTE] = isSingleItem ? serialVersionUID2 : serialVersionUI...
java
public static KllFloatsSketch heapify(final Memory mem) { final int preambleInts = mem.getByte(PREAMBLE_INTS_BYTE) & 0xff; final int serialVersion = mem.getByte(SER_VER_BYTE) & 0xff; final int family = mem.getByte(FAMILY_BYTE) & 0xff; final int flags = mem.getByte(FLAGS_BYTE) & 0xff; final int m = m...
java
static void checkK(final int k) { if ((k < MIN_K) || (k > MAX_K)) { throw new SketchesArgumentException( "K must be >= " + MIN_K + " and <= " + MAX_K + ": " + k); } }
java
private void compressWhileUpdating() { final int level = findLevelToCompact(); // It is important to do add the new top level right here. Be aware that this operation // grows the buffer and shifts the data and also the boundaries of the data and grows the // levels array and increments numLevels_ ...
java
public CompactDoublesSketch compact(final WritableMemory dstMem) { if (dstMem == null) { return HeapCompactDoublesSketch.createFromUpdateSketch(this); } return DirectCompactDoublesSketch.createFromUpdateSketch(this, dstMem); }
java
public static <T> ItemsSketch<T> getInstance(final Comparator<? super T> comparator) { return getInstance(PreambleUtil.DEFAULT_K, comparator); }
java
public static <T> ItemsSketch<T> getInstance(final int k, final Comparator<? super T> comparator) { final ItemsSketch<T> qs = new ItemsSketch<>(k, comparator); final int bufAlloc = 2 * Math.min(DoublesSketch.MIN_K, k); //the min is important qs.n_ = 0; qs.combinedBufferItemCapacity_ = bufAlloc; qs.c...
java
public static <T> ItemsSketch<T> getInstance(final Memory srcMem, final Comparator<? super T> comparator, final ArrayOfItemsSerDe<T> serDe) { final long memCapBytes = srcMem.getCapacity(); if (memCapBytes < 8) { ...
java
static <T> ItemsSketch<T> copy(final ItemsSketch<T> sketch) { final ItemsSketch<T> qsCopy = ItemsSketch.getInstance(sketch.k_, sketch.comparator_); qsCopy.n_ = sketch.n_; qsCopy.minValue_ = sketch.getMinValue(); qsCopy.maxValue_ = sketch.getMaxValue(); qsCopy.combinedBufferItemCapacity_ = sketch.get...
java
public void update(final T dataItem) { // this method only uses the base buffer part of the combined buffer if (dataItem == null) { return; } if ((maxValue_ == null) || (comparator_.compare(dataItem, maxValue_) > 0)) { maxValue_ = dataItem; } if ((minValue_ == null) || (comparator_.compare(dataItem, mi...
java
public T getQuantileUpperBound(final double fraction) { return getQuantile(min(1.0, fraction + Util.getNormalizedRankError(k_, false))); }
java
public T getQuantileLowerBound(final double fraction) { return getQuantile(max(0, fraction - Util.getNormalizedRankError(k_, false))); }
java
public void reset() { n_ = 0; combinedBufferItemCapacity_ = 2 * Math.min(DoublesSketch.MIN_K, k_); //the min is important combinedBuffer_ = new Object[combinedBufferItemCapacity_]; baseBufferCount_ = 0; bitPattern_ = 0; minValue_ = null; maxValue_ = null; }
java
public ItemsSketch<T> downSample(final int newK) { final ItemsSketch<T> newSketch = ItemsSketch.getInstance(newK, comparator_); ItemsMergeImpl.downSamplingMergeInto(this, newSketch); return newSketch; }
java
public void putMemory(final WritableMemory dstMem, final ArrayOfItemsSerDe<T> serDe) { final byte[] byteArr = toByteArray(serDe); final long memCap = dstMem.getCapacity(); if (memCap < byteArr.length) { throw new SketchesArgumentException( "Destination Memory not large enough: " + memCap + "...
java
private void itemsArrayToCombinedBuffer(final T[] itemsArray) { final int extra = 2; // space for min and max values //Load min, max minValue_ = itemsArray[0]; maxValue_ = itemsArray[1]; //Load base buffer System.arraycopy(itemsArray, extra, combinedBuffer_, 0, baseBufferCount_); //Load l...
java
private void scanAllAsearchB() { final long[] scanAArr = a_.getCache(); final int arrLongsIn = scanAArr.length; cache_ = new long[arrLongsIn]; for (int i = 0; i < arrLongsIn; i++ ) { final long hashIn = scanAArr[i]; if ((hashIn <= 0L) || (hashIn >= thetaLong_)) { continue; } final int ...
java
public static double approximateLowerBoundOnP(final long n, final long k, final double numStdDevs) { checkInputs(n, k); if (n == 0) { return 0.0; } // the coin was never flipped, so we know nothing else if (k == 0) { return 0.0; } else if (k == 1) { return (exactLowerBoundOnPForKequalsOne(n, deltaOfNumS...
java
public static double approximateUpperBoundOnP(final long n, final long k, final double numStdDevs) { checkInputs(n, k); if (n == 0) { return 1.0; } // the coin was never flipped, so we know nothing else if (k == n) { return 1.0; } else if (k == (n - 1)) { return (exactUpperBoundOnPForKequalsNminus...
java
private static double erf_of_nonneg(final double x) { // The constants that appear below, formatted for easy checking against the book. // a1 = 0.07052 30784 // a3 = 0.00927 05272 // a5 = 0.00027 65672 // a2 = 0.04228 20123 // a4 = 0.00015 20143 // a6 = 0.00004 30638 fi...
java
private static double abramowitzStegunFormula26p5p22(final double a, final double b, final double yp) { final double b2m1 = (2.0 * b) - 1.0; final double a2m1 = (2.0 * a) - 1.0; final double lambda = ((yp * yp) - 3.0) / 6.0; final double htmp = (1.0 / a2m1) + (1.0 / b2m1); final double h = 2.0...
java
public static <T> ReservoirItemsSketch<T> newInstance(final int k, final ResizeFactor rf) { return new ReservoirItemsSketch<>(k, rf); }
java
@SuppressWarnings("unchecked") public T[] getSamples() { if (itemsSeen_ == 0) { return null; } final Class<?> clazz = data_.get(0).getClass(); return data_.toArray((T[]) Array.newInstance(clazz, 0)); }
java
@SuppressWarnings("unchecked") ReservoirItemsSketch<T> copy() { return new ReservoirItemsSketch<>(reservoirSize_, currItemsAlloc_, itemsSeen_, rf_, (ArrayList<T>) data_.clone()); }
java
public CompactSketch intersect(final Sketch a, final Sketch b) { return intersect(a, b, true, null); }
java
static DirectCouponList newInstance(final int lgConfigK, final TgtHllType tgtHllType, final WritableMemory dstMem) { insertPreInts(dstMem, LIST_PREINTS); insertSerVer(dstMem); insertFamilyId(dstMem); insertLgK(dstMem, lgConfigK); insertLgArr(dstMem, LG_INIT_LIST_SIZE); insertFlags(dstMem, ...
java
static final int checkMaxLgArrLongs(final Memory dstMem) { final int preBytes = CONST_PREAMBLE_LONGS << 3; final long cap = dstMem.getCapacity(); final int maxLgArrLongs = Integer.numberOfTrailingZeros(floorPowerOf2((int)(cap - preBytes)) >>> 3); if (maxLgArrLongs < MIN_LG_ARR_LONGS) { thr...
java
static IntersectionImpl initNewHeapInstance(final long seed) { final IntersectionImpl impl = new IntersectionImpl(null, seed, false); impl.lgArrLongs_ = 0; impl.curCount_ = -1; //Universal Set is true impl.thetaLong_ = Long.MAX_VALUE; impl.empty_ = false; //A virgin intersection represents the Uni...
java
static IntersectionImpl initNewDirectInstance(final long seed, final WritableMemory dstMem) { final IntersectionImpl impl = new IntersectionImpl(dstMem, seed, true); //Load Preamble insertPreLongs(dstMem, CONST_PREAMBLE_LONGS); //RF not used = 0 insertSerVer(dstMem, SER_VER); insertFamilyID(dstMem,...
java
static IntersectionImplR heapifyInstance(final Memory srcMem, final long seed) { final IntersectionImpl impl = new IntersectionImpl(null, seed, false); //Get Preamble //Note: Intersection does not use lgNomLongs (or k), per se. //seedHash loaded and checked in private constructor final int preLongs...
java
@SuppressWarnings({ "unchecked", "null" }) public void update(final Sketch<S> sketchIn) { final boolean isFirstCall = isFirstCall_; isFirstCall_ = false; if (sketchIn == null) { isEmpty_ = true; sketch_ = null; return; } theta_ = min(theta_, sketchIn.getThetaLong()); isEmpty_...
java
private static double contClassicLB(final double numSamplesF, final double theta, final double numSDev) { final double nHat = (numSamplesF - 0.5) / theta; final double b = numSDev * Math.sqrt((1.0 - theta) / theta); final double d = 0.5 * b * Math.sqrt((b * b) + (4.0 * nHat)); final double center...
java
public static double getLowerBound(final long numSamples, final double theta, final int numSDev, final boolean noDataSeen) { //in earlier code numSamples was called numSamplesI if (noDataSeen) { return 0.0; } checkArgs(numSamples, theta, numSDev); final double lb = computeApproxBinoLB(numSamples, ...
java
public static double getUpperBound(final long numSamples, final double theta, final int numSDev, final boolean noDataSeen) { //in earlier code numSamples was called numSamplesI if (noDataSeen) { return 0.0; } checkArgs(numSamples, theta, numSDev); final double ub = computeApproxBinoUB(numSamples, ...
java
static final void checkArgs(final long numSamples, final double theta, final int numSDev) { if ((numSDev | (numSDev - 1) | (3 - numSDev) | numSamples) < 0) { throw new SketchesArgumentException( "numSDev must only be 1,2, or 3 and numSamples must >= 0: numSDev=" + numSDev + ", numSampl...
java
public void update(final ReservoirItemsSketch<T> sketchIn) { if (sketchIn == null) { return; } final ReservoirItemsSketch<T> ris = (sketchIn.getK() <= maxK_ ? sketchIn : sketchIn.downsampledCopy(maxK_)); // can modify the sketch if we downsampled, otherwise may need to copy it final ...
java
public void update(final T datum) { if (datum == null) { return; } if (gadget_ == null) { gadget_ = ReservoirItemsSketch.newInstance(maxK_); } gadget_.update(datum); }
java
public byte[] toByteArray(final ArrayOfItemsSerDe<T> serDe) { if ((gadget_ == null) || (gadget_.getNumSamples() == 0)) { return toByteArray(serDe, null); } else { return toByteArray(serDe, gadget_.getValueAtPosition(0).getClass()); } }
java
static double getRelErr(final boolean upperBound, final boolean oooFlag, final int lgK, final int stdDev) { final int idx = ((lgK - 4) * 3) + (stdDev - 1); final int sw = (oooFlag ? 2 : 0) | (upperBound ? 1 : 0); double f = 0; switch (sw) { case 0 : { //HIP, LB f = HIP_LB[idx]; ...
java
public double getEstimate() { if (!hasHip(mem)) { return getIconEstimate(PreambleUtil.getLgK(mem), getNumCoupons(mem)); } return getHipAccum(mem); }
java
static CompactSketch heapifyInstance(final Memory srcMem, final long seed) { final short memSeedHash = (short) extractSeedHash(srcMem); final short computedSeedHash = computeSeedHash(seed); checkSeedHashes(memSeedHash, computedSeedHash); final int preLongs = extractPreLongs(srcMem); final boolean e...
java
static CompactSketch compact(final UpdateSketch sketch) { final int curCount = sketch.getRetainedEntries(true); long thetaLong = sketch.getThetaLong(); boolean empty = sketch.isEmpty(); thetaLong = thetaOnCompact(empty, curCount, thetaLong); empty = emptyOnCompact(curCount, thetaLong); final sho...
java
public static double select(final double[] arr, int lo, int hi, final int pivot) { while (hi > lo) { final int j = partition(arr, lo, hi); if (j == pivot) { return arr[pivot]; } if (j > pivot) { hi = j - 1; } else { lo = j + 1; } } return arr...
java
public static double selectIncludingZeros(final double[] arr, final int pivot) { final int arrSize = arr.length; final int adj = pivot - 1; return select(arr, 0, arrSize - 1, adj); }
java
public static double selectExcludingZeros(final double[] arr, final int nonZeros, final int pivot) { if (pivot > nonZeros) { return 0L; } final int arrSize = arr.length; final int zeros = arrSize - nonZeros; final int adjK = (pivot + zeros) - 1; return select(arr, 0, arrSize - 1, adjK); ...
java
static final CouponHashSet heapifySet(final Memory mem) { final int lgConfigK = extractLgK(mem); final TgtHllType tgtHllType = extractTgtHllType(mem); final CurMode curMode = extractCurMode(mem); final int memArrStart = (curMode == CurMode.LIST) ? LIST_INT_ARR_START : HASH_SET_INT_ARR_START; final ...
java
static HeapQuickSelectSketch heapifyInstance(final Memory srcMem, final long seed) { final int preambleLongs = extractPreLongs(srcMem); //byte 0 final int lgNomLongs = extractLgNomLongs(srcMem); //byte 3 final int lgArrLongs = extractLgArrLongs(srcMem); //byte 4 check...
java
private final void quickSelectAndRebuild() { final int arrLongs = 1 << lgArrLongs_; final int pivot = (1 << lgNomLongs_) + 1; // pivot for QS thetaLong_ = selectExcludingZeros(cache_, curCount_, pivot); //messes up the cache_ // now we rebuild to clean up dirty data, update count, reconfigure as a ha...
java
public T items(final int i) { loadArrays(); return (sampleLists == null ? null : sampleLists.items[i]); }
java
public double weights(final int i) { loadArrays(); return (sampleLists == null ? Double.NaN : sampleLists.weights[i]); }
java
public SetOperationBuilder setNominalEntries(final int nomEntries) { bLgNomLongs = Integer.numberOfTrailingZeros(ceilingPowerOf2(nomEntries)); if ((bLgNomLongs > MAX_LG_NOM_LONGS) || (bLgNomLongs < MIN_LG_NOM_LONGS)) { throw new SketchesArgumentException("Nominal Entries must be >= 16 and <= 67108864: " ...
java
public SetOperation build(final Family family, final WritableMemory dstMem) { SetOperation setOp = null; switch (family) { case UNION: { if (dstMem == null) { setOp = UnionImpl.initNewHeapInstance(bLgNomLongs, bSeed, bP, bRF); } else { setOp = UnionImpl.initNewD...
java
static ReversePurgeLongHashMap getInstance(final String string) { final String[] tokens = string.split(","); if (tokens.length < 2) { throw new SketchesArgumentException( "String not long enough to specify length and capacity."); } final int numActive = Integer.parseInt(tokens[0]); f...
java
String serializeToString() { final StringBuilder sb = new StringBuilder(); sb.append(String.format("%d,%d,", numActive, keys.length)); for (int i = 0; i < keys.length; i++) { if (states[i] != 0) { sb.append(String.format("%d,%d,", keys[i], values[i])); } } return sb.toString(); ...
java
void keepOnlyPositiveCounts() { // Starting from the back, find the first empty cell, which marks a boundary between clusters. int firstProbe = keys.length - 1; while (states[firstProbe] > 0) { firstProbe--; } //Work towards the front; delete any non-positive entries. for (int probe = fir...
java
public static double getLowerBoundForBoverA(final Sketch sketchA, final Sketch sketchB) { final double thetaA = sketchA.getTheta(); final double thetaB = sketchB.getTheta(); checkThetas(thetaA, thetaB); final int countB = sketchB.getRetainedEntries(true); final int countA = (thetaB == thetaA) ? ske...
java
static <T> void blockyTandemMergeSort(final T[] keyArr, final long[] valArr, final int arrLen, final int blkSize, final Comparator<? super T> comparator) { assert blkSize >= 1; if (arrLen <= blkSize) { return; } int numblks = arrLen / blkSize; if ((numblks * blkSize) < arrLen) { numblks += 1; } ...
java
public static int decodeValue(final short encodedSize) { final int value = encodedSize & 0xFFFF; if (value > MAX_ENC_VALUE) { throw new SketchesArgumentException("Maximum valid encoded value is " + Integer.toHexString(MAX_ENC_VALUE) + ", found: " + value); } final int p = (value >>...
java
public static ConcurrentLimitRule of(int concurrentLimit, TimeUnit timeOutUnit, long timeOut) { requireNonNull(timeOutUnit, "time out unit can not be null"); return new ConcurrentLimitRule(concurrentLimit, timeOutUnit.toMillis(timeOut)); }
java
public static RequestLimitRule of(Duration duration, long limit) { checkDuration(duration); if (limit < 0) { throw new IllegalArgumentException("limit must be greater than zero."); } int durationSeconds = (int) duration.getSeconds(); return new RequestLimitRule(durati...
java
public RequestLimitRule withName(String name) { return new RequestLimitRule(this.durationSeconds, this.limit, this.precision, name, this.keys); }
java
public RequestLimitRule matchingKeys(String... keys) { Set<String> keySet = keys.length > 0 ? new HashSet<>(Arrays.asList(keys)) : null; return matchingKeys(keySet); }
java
public RequestLimitRule matchingKeys(Set<String> keys) { return new RequestLimitRule(this.durationSeconds, this.limit, this.precision, this.name, keys); }
java
public void addScopeBindings(Map<Class<? extends Annotation>, Scope> bindings) { if (scopeCleaner.isRunning()) { scopeBindings.putAll(bindings); } }
java
@Override public void close() throws Exception { if (scopeCleaner.close()) { // executor thread to exit processing loop LOGGER.info("closing PreDestroyMonitor..."); List<Map.Entry<Object, UnscopedCleanupAction>> actions = new ArrayList<>(cleanupActions.entrySet()); ...
java
public InjectorBuilder combineWith(Module ... modules) { List<Module> m = new ArrayList<>(); m.add(module); m.addAll(Arrays.asList(modules)); this.module = Modules.combine(m); return this; }
java
public <T> InjectorBuilder forEachElement(ElementVisitor<T> visitor, Consumer<T> consumer) { Elements .getElements(module) .forEach(element -> Optional.ofNullable(element.acceptVisitor(visitor)).ifPresent(consumer)); return this; }
java
public <T> InjectorBuilder forEachElement(ElementVisitor<T> visitor) { Elements .getElements(module) .forEach(element -> element.acceptVisitor(visitor)); return this; }
java
public InjectorBuilder filter(ElementVisitor<Boolean> predicate) { List<Element> elements = new ArrayList<Element>(); for (Element element : Elements.getElements(Stage.TOOL, module)) { if (element.acceptVisitor(predicate)) { elements.add(element); } } ...
java
public static Module combineAndOverride(List<? extends Module> modules) { Iterator<? extends Module> iter = modules.iterator(); Module current = Modules.EMPTY_MODULE; if (iter.hasNext()) { current = iter.next(); if (iter.hasNext()) { current = Modules.over...
java
public static Module fromClass(final Class<?> cls, final boolean override) { List<Module> modules = new ArrayList<>(); // Iterate through all annotations of the main class, create a binding for the annotation // and add the module to the list of modules to install for (final Annotation a...
java
public <T> Governator setFeature(GovernatorFeature<T> feature, T value) { this.featureOverrides.put(feature, value); return this; }
java
private LifecycleInjector run(Module externalModule, final String[] args) { return InjectorBuilder .fromModules(modules) .combineWith(externalModule) .map(new ModuleTransformer() { @Override public Module transform(Module module) { ...
java
public String toFile() throws Exception { File file = File.createTempFile("GuiceDependencies_", ".dot"); toFile(file); return file.getCanonicalPath(); }
java
public void toFile(File file) throws Exception { PrintWriter out = new PrintWriter(file, "UTF-8"); try { out.write(graph()); } finally { Closeables.close(out, true); } }
java
public String graph() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter out = new PrintWriter(baos); Injector localInjector = Guice.createInjector(new GraphvizModule()); GraphvizGrapher renderer = localInjector.getInstance(GraphvizGrapher.class); ...
java
public boolean isGuiceConstructorInjected(Class<?> c) { for (Constructor<?> con : c.getDeclaredConstructors()) { if (isInjectable(con)) { return true; } } return false; }
java
public Map<Scope, ComponentScope> createScopeMap() { Map<Scope, ComponentScope> result = new HashMap<Scope, ComponentScope>(); result.put(Scopes.SINGLETON, ComponentScope.Singleton); result.put(Scopes.NO_SCOPE, ComponentScope.PerRequest); result.put(ServletScopes.REQUEST, ComponentScope....
java
void addColumn(String columnName) { data.add(new ArrayList<String>()); columnNames.add(columnName); }
java