d112604.5

Method called after first set of 25 CMP11 entities returned
during a lazy enumeration custom finder execution. Called for each set of
instances to be hydrated via the RemoteEnumerator code path.
18031
public void setCustomFinderAccessIntentThreadState(boolean cfwithupdateaccess,
                                                       boolean readonly,
                                                       String methodname) {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); // d532639.2

        // create a thread local context for ContainerManagedBeanO to determine CF Access Information
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "setCustomFinderAccessIntentThreadState");

        //CMP11CustomFinderAIContext = new WSThreadLocal();    deleted PQ95614
        CMP11CustomFinderAccIntentState _state = new CMP11CustomFinderAccIntentState(methodname, cfwithupdateaccess, readonly);

        if (isTraceOn && tc.isDebugEnabled())
            Tr.debug(tc, "current thread CMP11 Finder state" + _state);

        svThreadData.get().ivCMP11CustomFinderAccIntentState = _state; // d630940

        if (isTraceOn && tc.isEntryEnabled()) //PQ95614
            Tr.exit(tc, "setCustomFinderAccessIntentThreadState");
    }
1141970
protected int createInstances(DelegateExecution execution) {
    int nrOfInstances = resolveNrOfInstances(execution);
    if (nrOfInstances < 0) {
      throw new ActivitiIllegalArgumentException("Invalid number of instances: must be non-negative integer value" + ", but was " + nrOfInstances);
    }

    execution.setMultiInstanceRoot(true);

    setLoopVariable(execution, NUMBER_OF_INSTANCES, nrOfInstances);
    setLoopVariable(execution, NUMBER_OF_COMPLETED_INSTANCES, 0);
    setLoopVariable(execution, NUMBER_OF_ACTIVE_INSTANCES, nrOfInstances);

    List<DelegateExecution> concurrentExecutions = new ArrayList<DelegateExecution>();
    for (int loopCounter = 0; loopCounter < nrOfInstances; loopCounter++) {
      DelegateExecution concurrentExecution = Context.getCommandContext().getExecutionEntityManager()
          .createChildExecution((ExecutionEntity) execution);
      concurrentExecution.setCurrentFlowElement(activity);
      concurrentExecution.setActive(true);
      concurrentExecution.setScope(false);

      concurrentExecutions.add(concurrentExecution);
      logLoopDetails(concurrentExecution, "initialized", loopCounter, 0, nrOfInstances, nrOfInstances);
    }

    // Before the activities are executed, all executions MUST be created up front
    // Do not try to merge this loop with the previous one, as it will lead
    // to bugs, due to possible child execution pruning.
    for (int loopCounter = 0; loopCounter < nrOfInstances; loopCounter++) {
      DelegateExecution concurrentExecution = concurrentExecutions.get(loopCounter);
      // executions can be inactive, if instances are all automatics
      // (no-waitstate) and completionCondition has been met in the meantime
      if (concurrentExecution.isActive() && !concurrentExecution.isEnded() && concurrentExecution.getParent().isActive() && !concurrentExecution.getParent().isEnded()) {
        setLoopVariable(concurrentExecution, getCollectionElementIndexVariable(), loopCounter);
        executeOriginalBehavior(concurrentExecution, loopCounter);
      }
    }

    // See ACT-1586: ExecutionQuery returns wrong results when using multi
    // instance on a receive task The parent execution must be set to false, so it wouldn't show up in
    // the execution query when using .activityId(something). Do not we cannot nullify the
    // activityId (that would have been a better solution), as it would break boundary event behavior.
    if (!concurrentExecutions.isEmpty()) {
      ExecutionEntity executionEntity = (ExecutionEntity) execution;
      executionEntity.setActive(false);
    }

    return nrOfInstances;
  }
9045
public static <T> int count(Iterable<T> iterable, Predicate<? super T> predicate, int batchSize, Executor executor)
    {
        CountCombiner<T> combiner = new CountCombiner<T>();
        CountProcedureFactory<T> procedureFactory = new CountProcedureFactory<T>(predicate);
        ParallelIterate.forEach(
                iterable,
                procedureFactory,
                combiner,
                batchSize,
                executor);
        return combiner.getCount();
    }
154143
static <T> void bucketSort(final List<? extends T> c, final int fromIndex, final int toIndex, final Comparator<? super T> cmp) {
        N.checkFromToIndex(fromIndex, toIndex, c == null ? 0 : c.size());

        if ((N.isNullOrEmpty(c) && fromIndex == 0 && toIndex == 0) || fromIndex == toIndex) {
            return;
        }

        if (toIndex - fromIndex < 32) {
            sort(c, fromIndex, toIndex, cmp);
            return;
        }

        final Comparator<? super T> comparator = cmp == null ? Comparators.NATURAL_ORDER : cmp;
        final Multiset<T> multiset = new Multiset<>();
        ListIterator<T> itr = (ListIterator<T>) c.listIterator(fromIndex);
        int i = fromIndex;

        while (itr.hasNext()) {
            if (i++ >= toIndex) {
                break;
            }

            multiset.add(itr.next());
        }

        final Map<T, Integer> m = multiset.toMapSortedBy(new Comparator<Map.Entry<T, MutableInt>>() {
            @Override
            public int compare(Entry<T, MutableInt> a, Entry<T, MutableInt> b) {
                return comparator.compare(a.getKey(), a.getKey());
            }
        });

        itr = (ListIterator<T>) c.listIterator(fromIndex);

        for (Map.Entry<T, Integer> entry : m.entrySet()) {
            final T key = entry.getKey();
            for (int j = 0; j < entry.getValue(); j++) {
                itr.next();
                itr.set(key);
            }
        }
    }
403622
@Override
    public Iterator<MultiTableScanResult> multiTableScan(final MultiTableScanOptions query, final TableSet tables,
                                                         final LimitCounter limit, final ReadConsistency consistency, @Nullable Instant cutoffTime) {
        checkNotNull(query, "query");
        String placementName = checkNotNull(query.getPlacement(), "placement");
        final DeltaPlacement placement = (DeltaPlacement) _placementCache.get(placementName);

        ScanRange scanRange = Objects.firstNonNull(query.getScanRange(), ScanRange.all());

        // Since the range may wrap from high to low end of the token range we need to unwrap it
        List<ScanRange> ranges = scanRange.unwrapped();

        return touch(FluentIterable.from(ranges)
                .transformAndConcat(new Function<ScanRange, Iterable<MultiTableScanResult>>() {
                    @Override
                    public Iterable<MultiTableScanResult> apply(final ScanRange rowRange) {
                        return new Iterable<MultiTableScanResult>() {
                            @Override
                            public Iterator<MultiTableScanResult> iterator() {
                                return scanMultiTableRows(
                                        tables, placement, rowRange.asByteBufferRange(), limit, query.isIncludeDeletedTables(),
                                        query.isIncludeMirrorTables(), _maxColumnsRange.getLimit(), consistency, cutoffTime);
                            }
                        };
                    }
                })
                .iterator());

    }
236603
@Override
  public final IConverterToFromString<?> lazyGet(
    final Map<String, Object> pAddParam,
      final String pBeanName) throws Exception {
    // There is no way to get from Map partially initialized bean
    // in this double-checked locking implementation
    // cause putting to the Map fully initialized bean
    IConverterToFromString<?> convrt = this.convertersMap.get(pBeanName);
    if (convrt == null) {
      // locking:
      synchronized (this.convertersMap) {
        // make sure again whether it's null after locking:
        convrt = this.convertersMap.get(pBeanName);
        if (convrt == null) {
          if (pBeanName.equals(CnvTfsLong.class.getSimpleName())) {
            convrt = lazyGetCnvTfsLong();
          } else if (pBeanName.equals(CnvTfsDate.class.getSimpleName())) {
            convrt = createPutCnvTfsDate();
          } else if (pBeanName.equals(CnvTfsDateTime.class
            .getSimpleName())) {
            convrt = createPutCnvTfsDateTime();
          } else if (pBeanName.equals(CnvTfsDateTimeSec.class
            .getSimpleName())) {
            convrt = createPutCnvTfsDateTimeSec();
          } else if (pBeanName.equals(CnvTfsDateTimeSecMs.class
            .getSimpleName())) {
            convrt = createPutCnvTfsDateTimeSecMs();
          } else if (pBeanName.equals(CnvTfsBigDecimal.class
            .getSimpleName())) {
            convrt = createPutCnvTfsBigDecimal();
          } else if (pBeanName.equals(CnvTfsFloat.class.getSimpleName())) {
            convrt = createPutCnvTfsFloat();
          } else if (pBeanName.equals(CnvTfsDouble.class.getSimpleName())) {
            convrt = createPutCnvTfsDouble();
          } else if (pBeanName.equals(CnvTfsBoolean.class.getSimpleName())) {
            convrt = createPutCnvTfsBoolean();
          } else if (pBeanName.equals(CnvTfsInteger.class.getSimpleName())) {
            convrt = lazyGetCnvTfsInteger();
          } else if (pBeanName.equals(CnvTfsString.class.getSimpleName())) {
            convrt = lazyGetCnvTfsString();
          } else {
            for (Map.Entry<Class<? extends IHasId<Long>>, String> entry
              : this.hasLongIdMap.entrySet()) {
              if (pBeanName.equals(CnvTfsHasId.class.getSimpleName()
                + "Long" + entry.getKey().getSimpleName())) {
                convrt = createHasLongIdConverter(pBeanName,
                  entry.getKey(), entry.getValue());
                break;
              }
            }
            for (Map.Entry<Class<? extends IHasId<Integer>>, String> entry
              : this.hasIntegerIdMap.entrySet()) {
              if (pBeanName.equals(CnvTfsHasId.class.getSimpleName()
                + "Integer" + entry.getKey().getSimpleName())) {
                convrt = createHasIntegerIdConverter(pBeanName,
                  entry.getKey(), entry.getValue());
                break;
              }
            }
            for (Map.Entry<Class<? extends IHasId<String>>, String> entry
              : this.hasStringIdMap.entrySet()) {
              if (pBeanName.equals(CnvTfsHasId.class.getSimpleName()
                + "String" + entry.getKey().getSimpleName())) {
                convrt = createHasStringIdConverter(pBeanName,
                  entry.getKey(), entry.getValue());
                break;
              }
            }
            for (Map.Entry<Class<? extends IHasId<?>>, String> entry
              : this.hasCompositeIdMap.entrySet()) {
              if (pBeanName.equals(CnvTfsHasId.class.getSimpleName()
                + "Composite" + entry.getKey().getSimpleName())) {
                convrt = createHasCompositeIdConverter(pBeanName,
                  entry.getKey(), entry.getValue());
                break;
              }
            }
            for (Class<?> cmpsClass : this.compositeClasses) {
              if (pBeanName.equals(getCnvTfsObjectName(cmpsClass))) {
                convrt = lazyGetCnvTfsObject(cmpsClass);
                break;
              }
            }
            for (Class<? extends Enum<?>> enumClass : this.enumsClasses) {
              if (pBeanName.equals(CnvTfsEnum
                .class.getSimpleName() + enumClass.getSimpleName())) {
                convrt = createCnvTfsEnum(pBeanName, enumClass);
                break;
              }
            }
          }
        }
      }
    }
    if (convrt == null) {
      throw new ExceptionWithCode(ExceptionWithCode.CONFIGURATION_MISTAKE,
        "There is no converter with name " + pBeanName);
    }
    return convrt;
  }
123010
@Override
	public Enumeration getEnumeration() throws JMSException 
	{
		checkNotClosed();
		
		// Security check
		checkDestinationPermission();
		
		LocalQueueBrowserEnumeration queueBrowserEnum = new LocalQueueBrowserEnumeration(this,(LocalQueue)queue,parsedSelector,UUIDProvider.getInstance().getShortUUID());
		registerEnumeration(queueBrowserEnum);
		return queueBrowserEnum;
	}
1270205
@Override
	public void cacheResult(List<CPMeasurementUnit> cpMeasurementUnits) {
		for (CPMeasurementUnit cpMeasurementUnit : cpMeasurementUnits) {
			if (entityCache.getResult(
						CPMeasurementUnitModelImpl.ENTITY_CACHE_ENABLED,
						CPMeasurementUnitImpl.class,
						cpMeasurementUnit.getPrimaryKey()) == null) {
				cacheResult(cpMeasurementUnit);
			}
			else {
				cpMeasurementUnit.resetOriginalValues();
			}
		}
	}
904454
private Iterable<URL> createServiceFileIterator() {
        if (classLoader == null) {
            ClassLoader classLoader = SchemaFactoryFinder.class.getClassLoader();
            return Collections.singleton(classLoader.getResource(SERVICE_ID));
        } else {
            try {
                Enumeration<URL> e = classLoader.getResources(SERVICE_ID);
                if (debug && !e.hasMoreElements()) {
                    debugPrintln("no "+SERVICE_ID+" file was found");
                }

                // wrap it into an Iterator.
                return Collections.list(e);
            } catch (IOException e) {
                if (debug) {
                    debugPrintln("failed to enumerate resources "+SERVICE_ID);
                    e.printStackTrace();
                }
                return Collections.emptySet();
            }
        }
    }
897303
def enumerator
      Enumerator.new do |yielder|
        response = get_initial_response

        loop do
          items = response.records

          # If there are no records, we're done
          break if items.empty?

          # Otherwise, iterate through the records...
          items.each { |item| yielder << item }

          # ...and fetch the next page
          @params ||= {}
          @params[:page] ||= 1
          @params[:page] += 1

          response = @service.list(**@params)
        end
      end.lazy
    end
699173
private Object generateEnumerateObject(final Field field,
                                           final Map<Field, Long> enumerateMap) {
        final Long currentEnumerateValue = enumerateMap.get(field);
        Object objValue = BasicCastUtils.castToNumber(currentEnumerateValue, field.getType());

        // Increment numerate number for generated field
        enumerateMap.computeIfPresent(field, (k, v) -> v + 1);
        return objValue;
    }
671120
public static Iterator<Cell> gatherTombstones(final ColumnFamily returnCF, final Iterator<? extends OnDiskAtom> iter)
    {
        return new Iterator<Cell>()
        {
            private Cell next;

            public boolean hasNext()
            {
                if (next != null)
                    return true;

                getNext();
                return next != null;
            }

            public Cell next()
            {
                if (next == null)
                    getNext();

                assert next != null;
                Cell toReturn = next;
                next = null;
                return toReturn;
            }

            private void getNext()
            {
                while (iter.hasNext())
                {
                    OnDiskAtom atom = iter.next();

                    if (atom instanceof Cell)
                    {
                        next = (Cell)atom;
                        break;
                    }
                    else
                    {
                        returnCF.addAtom(atom);
                    }
                }
            }

            public void remove()
            {
                throw new UnsupportedOperationException();
            }
        };
    }
162751
def enumerations(
            self,
            name=None,
            function=None,
            header_dir=None,
            header_file=None,
            recursive=None,
            allow_empty=None):
        """"""
        return (
            self._find_multiple(
                self._impl_matchers[scopedef_t.enumeration],
                name=name,
                function=function,
                decl_type=self._impl_decl_types[
                    scopedef_t.enumeration],
                header_dir=header_dir,
                header_file=header_file,
                recursive=recursive,
                allow_empty=allow_empty)
        )
1040864
def enumerator
      response = get_initial_response
      Enumerator.new do |yielder|
        loop do
          response.records.each { |item| yielder << item }

          after_cursor = response.after
          break if after_cursor.nil?

          @options[:params] ||= {}
          @options[:params] = @options[:params].merge(after: after_cursor)
          response = @service.list(@options.merge(after: after_cursor))
        end
      end.lazy
    end
1201263
def one(self):
        ''' 
        '''
        count = -1
        for count, result in enumerate(self):
            if count > 0:
                raise BadResultException('Too many results for .one()')
        if count == -1:
            raise BadResultException('Too few results for .one()')
        return result
1318279
@Override
    public <E> List<E> findAll(Class<E> entityClazz, String[] columnsToSelect, Object... arg1)
    {
        // TODO: Vivek correct it. unfortunately i need to open a new session
        // for each finder to avoid lazy loading.
        Session s = getSession();

        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, getPersistenceUnit(),
                entityClazz);

        Object[] pKeys = getDataType(entityMetadata, arg1);
        String id = ((AbstractAttribute) entityMetadata.getIdAttribute()).getJPAColumnName();

        Criteria c = s.createCriteria(entityClazz);

        c.add(Restrictions.in(id, pKeys));

        return c.list();
    }
545208
@Override
  public final IProcessor lazyGet(//NOPMD
    final Map<String, Object> pAddParam,
      final String pBeanName) throws Exception {
    IProcessor proc = this.processorsMap.get(pBeanName);
    if (proc == null) {
      // locking:
      synchronized (this.processorsMap) {
        // make sure again whether it's null after locking:
        proc = this.processorsMap.get(pBeanName);
        if (proc == null) {
          if (pBeanName.equals(PrcDelItemFromCart.class.getSimpleName())) {
            proc = lazyGetPrcDelItemFromCart(pAddParam);
          } else if (pBeanName.equals(PrCart.class.getSimpleName())) {
            proc = lazyGetPrCart(pAddParam);
          } else if (pBeanName.equals(PrcItemInCart.class.getSimpleName())) {
            proc = lazyGetPrcItemInCart(pAddParam);
          } else if (pBeanName.equals(PrLog.class.getSimpleName())) {
            proc = lazyGetPrLog(pAddParam);
          } else if (pBeanName.equals(PrcCheckOut.class.getSimpleName())) {
            proc = lazyGetPrcCheckOut(pAddParam);
          } else if (pBeanName.equals(PrBuOr.class.getSimpleName())) {
            proc = lazyGetPrBuOr(pAddParam);
          } else if (pBeanName.equals(PrBur.class.getSimpleName())) {
            proc = lazyGetPrBur(pAddParam);
          } else if (pBeanName.equals(PrPur.class.getSimpleName())) {
            proc = lazyGetPrPur(pAddParam);
          } else if (pBeanName.equals(PrcItemPage.class.getSimpleName())) {
            proc = lazyGetPrcItemPage(pAddParam);
          } else if (pBeanName.equals(PrcWebstorePage.class.getSimpleName())) {
            proc = lazyGetPrcWebstorePage(pAddParam);
          }
        }
      }
    }
    if (proc == null) {
      throw new ExceptionWithCode(ExceptionWithCode.CONFIGURATION_MISTAKE,
        "There is no processor with name " + pBeanName);
    }
    return proc;
  }