/* Convert the given list of scopes to a list of scope only schema records. At the same time, fracture the records list
if its size is greater than ELASTICSEARCH_INDEXING_BATCH_SIZE.
326615
protected List<List<ScopeOnlySchemaRecord>> _fractureScopes(Set<String> scopeNames) {
		List<List<ScopeOnlySchemaRecord>> fracturedList = new ArrayList<>();

		List<ScopeOnlySchemaRecord> records = new ArrayList<>(_bulkIndexingSize);
		for(String scope : scopeNames) {
			records.add(new ScopeOnlySchemaRecord(scope));

			if(records.size() == _bulkIndexingSize) {
				fracturedList.add(records);
				records = new ArrayList<>(_bulkIndexingSize);
			}
		}

		if(!records.isEmpty()) {
			fracturedList.add(records);
		}

		return fracturedList;
	}
814587
@Override
  public OperationHandle getTables(SessionHandle sessionHandle, String catalogName,
      String schemaName, String tableName, List<String> tableTypes)
          throws HiveSQLException {
    try {
      TGetTablesReq req = new TGetTablesReq(sessionHandle.toTSessionHandle());
      req.setTableName(tableName);
      req.setTableTypes(tableTypes);
      req.setSchemaName(schemaName);
      TGetTablesResp resp = cliService.GetTables(req);
      checkStatus(resp.getStatus());
      TProtocolVersion protocol = sessionHandle.getProtocolVersion();
      return new OperationHandle(resp.getOperationHandle(), protocol);
    } catch (HiveSQLException e) {
      throw e;
    } catch (Exception e) {
      throw new HiveSQLException(e);
    }
  }
221684
private CompletableFuture<List<EpochRecord>> getEpochRecords(String scope, String stream, int epoch, OperationContext context) {
        List<CompletableFuture<EpochRecord>> list = new ArrayList<>();
        list.add(streamMetadataStore.getEpoch(scope, stream, epoch, context, executor));
        list.add(streamMetadataStore.getActiveEpoch(scope, stream, context, true, executor));
        return Futures.allOfWithResults(list);
    }
194943
public static List<ModelServiceInstance> filter(ServiceInstanceQuery query, List<ModelServiceInstance> list) {

        if (list == null || list.size() == 0) {
            return Collections.emptyList();
        }

        List<QueryCriterion> criteria = query.getCriteria();

        if (criteria == null || criteria.size() == 0) {
            return list;
        }

        List<ModelServiceInstance> instances = new ArrayList<ModelServiceInstance>();
        for (ModelServiceInstance instance : list) {
            boolean passed = true;
            for (QueryCriterion criterion : criteria) {
                if (criterion.isMatch(instance.getMetadata()) == false) {
                    passed = false;
                    break;
                }
            }
            if (passed) {
                instances.add(instance);
            }
        }

        return instances;

    }
1213294
def _expand_tasks(self, scopes):
    
    expanded_scopes = set(scopes)
    for scope, info in self._scope_to_info.items():
      if info.category == ScopeInfo.TASK:
        outer = enclosing_scope(scope)
        while outer != GLOBAL_SCOPE:
          if outer in expanded_scopes:
            expanded_scopes.add(scope)
            break
          outer = enclosing_scope(outer)
    return sorted(expanded_scopes)
89859
def wherex_to_rowlist(scope_, fromx, wherex):
  
  single, multi = classify_wherex(scope_, fromx, wherex)
  single_rowlists = {
    tablename: table_to_rowlist(scope_[tablename], conds)
    for tablename, conds in misc.multimap(single).items() # i.e. {cond.table:[cond.exp, ...]}
  }
  raise NotImplementedError
782914
@Override
  public Iterable<GenericRecord> convertRecordImpl(Schema outputSchema, GenericRecord inputRecord, WorkUnitState workUnit)
      throws DataConversionException {
    try {
      return new SingleRecordIterable<>(AvroUtils.convertRecordSchema(inputRecord, outputSchema));
    } catch (IOException e) {
      throw new DataConversionException(e);
    }
  }
833956
public List<QueryParameters> subListCached(int fromIndex, int toIndex) {
        ArrayList<QueryParameters> result = new ArrayList<QueryParameters>();

        result.addAll(generatedCacheMap.values());
        result.addAll(resultSetCacheMap.values());

        return result.subList(fromIndex, toIndex);
    }
819537
public static Scopes from(String... scopes)
    {
        if (scopes == null || scopes.length == 0) return NONE;
        return new Scopes(scopes, true);
    }
295843
def populate_scoped_cols(self, scoped_tbls):
        
        columns = []
        meta = self.dbmetadata

        for tbl in scoped_tbls:
            # A fully qualified schema.relname reference or default_schema
            # DO NOT escape schema names.
            schema = tbl[0] or self.dbname
            relname = tbl[1]
            escaped_relname = self.escape_name(tbl[1])

            # We don't know if schema.relname is a table or view. Since
            # tables and views cannot share the same name, we can check one
            # at a time
            try:
                columns.extend(meta['tables'][schema][relname])

                # Table exists, so don't bother checking for a view
                continue
            except KeyError:
                try:
                    columns.extend(meta['tables'][schema][escaped_relname])
                    # Table exists, so don't bother checking for a view
                    continue
                except KeyError:
                    pass

            try:
                columns.extend(meta['views'][schema][relname])
            except KeyError:
                pass

        return columns
1305935
private List<Audit> _scanRecords(BigInteger entityId, int limit, ScanFilter filter) {
		
		final Scanner scanner = _client.newScanner(tablename);

		String startRow = entityId.toString();
        String stopRow = HBaseUtils._plusOne(startRow);
        scanner.setStartKey(startRow);
        scanner.setStopKey(stopRow);
        scanner.setMaxNumRows(Math.min(limit, MAX_NUM_ROWS));
        scanner.setFilter(filter);
		
		final List<Audit> records = new ArrayList<>(limit);
        final Deferred<List<Audit>> results = new Deferred<List<Audit>>();
		
        final class ScannerCB implements Callback<Object, ArrayList<ArrayList<KeyValue>>> {

            /**
             * Scans rows.
             *
             * @return  The list of audit records.
             */
            public Object scan() {
            	_logger.debug("Getting next set of rows.");
                return scanner.nextRows().addCallback(this);
            }

            @Override
            public Object call(ArrayList<ArrayList<KeyValue>> rows) throws Exception {
            	_logger.debug("Inside nextRows() callback..");
                try {
                    if (rows == null) {
                        results.callback(records);
                        scanner.close();
                        return null;
                    }
                    
                    _logger.debug("Retrieved " + rows.size() + " rows.");
                    
                    for (ArrayList<KeyValue> row : rows) {
                        for(KeyValue kv : row) {
                            byte[] value = kv.value();
                        	   List<Audit> audits = _mapper.readValue(value, new TypeReference<List<Audit>>() {});
                        	   records.addAll(audits);
                        }
                        
                        if (records.size() >= limit) {
                            results.callback(records);
                            scanner.close();
                            return null;
                        }
                    }
                    return scan();
                } catch (Exception e) {
                    scanner.close();
                    return null;
                }
            }
        }
        
        new ScannerCB().scan();
        
        try {
			List<Audit> audits = results.join(SCAN_TIMEOUT_MS);
			if(audits.size() <= limit) {
				return audits;
			}
			
			return audits.subList(0, limit);
			
		} catch (InterruptedException e) {
			throw new SystemException("Interrupted while waiting to obtain results for jobId: " + entityId, e);
		} catch (TimeoutException e) {
			_logger.warn("Timed out while waiting to obtain results for jobId: {}. Will return an empty list.", entityId);
			return Collections.emptyList();
		} catch (Exception e) {
			throw new SystemException("Exception occurred in getting results for jobId: " + entityId, e);
		}
	}
49797
def chunked(records, single=True):
    
    if version_info[0] > 10:
        invalidate = records.env.cache.invalidate
    elif version_info[0] > 7:
        invalidate = records.env.invalidate_all
    else:
        raise Exception('Not supported Odoo version for this method.')
    size = core.models.PREFETCH_MAX
    model = records._name
    ids = records.with_context(prefetch_fields=False).ids
    for i in range(0, len(ids), size):
        invalidate()
        chunk = records.env[model].browse(ids[i:i + size])
        if single:
            for record in chunk:
                yield record
            continue
        yield chunk
552040
private static <E> List<E> getBatchList(Integer index, int batchSize, Collection<E> collection) {
        List<E> list = null;
        if (collection instanceof List) {
            list = (List<E>) collection;
        } else {
            list = new ArrayList<E>(collection);
        }

        if (index == list.size() / batchSize) {
            return list.subList(index * batchSize, list.size());
        } else {
            return list.subList(index * batchSize, (index + 1) * batchSize);
        }
    }
369811
private Set<Scope> getScopeList(ObjectId collectorId) {
        Set<Scope> projects = new HashSet<>();
        if(featureSettings.isCollectorItemOnlyUpdate()){
            for(FeatureBoard featureBoard: enabledFeatureBoards(collectorId)){
                Scope scope = projectRepository.findByCollectorIdAndPId(collectorId, featureBoard.getProjectId());
                if(scope != null){
                    projects.add(scope);
                }
            }
        }else {
            projects = new HashSet<>(projectRepository.findByCollectorId(collectorId));
        }
        return projects;
    }
1211408
def list_groups(self, scope_ids=None, recurse=None, deleted=None, properties=None):
        
        query_parameters = {}
        if scope_ids is not None:
            query_parameters['scopeIds'] = self._serialize.query('scope_ids', scope_ids, 'str')
        if recurse is not None:
            query_parameters['recurse'] = self._serialize.query('recurse', recurse, 'bool')
        if deleted is not None:
            query_parameters['deleted'] = self._serialize.query('deleted', deleted, 'bool')
        if properties is not None:
            query_parameters['properties'] = self._serialize.query('properties', properties, 'str')
        response = self._send(http_method='GET',
                              location_id='5966283b-4196-4d57-9211-1b68f41ec1c2',
                              version='5.0',
                              query_parameters=query_parameters)
        return self._deserialize('[Identity]', self._unwrap_collection(response))
579024
public static <U extends Aggregate> List<Batch<U>> getBatches(List<U> list) {
        return getBatches(list, batchLimit);
    }
744431
def dynamize_request_items(self, batch_list):
        
        d = None
        if batch_list:
            d = {}
            for batch in batch_list:
                batch_dict = {}
                key_list = []
                for key in batch.keys:
                    if isinstance(key, tuple):
                        hash_key, range_key = key
                    else:
                        hash_key = key
                        range_key = None
                    k = self.build_key_from_values(batch.table.schema,
                                                   hash_key, range_key)
                    key_list.append(k)
                batch_dict['Keys'] = key_list
                if batch.attributes_to_get:
                    batch_dict['AttributesToGet'] = batch.attributes_to_get
            d[batch.table.name] = batch_dict
        return d