fetchInitialBatch
174460
function () {
                            hints = hints || {};
                            var itemPromise = (
                                typeof hints.groupMemberKey === "string" && that._listBinding.fromKey ?
                                    that._listBinding.fromKey(hints.groupMemberKey) :
                                typeof hints.groupMemberIndex === "number" && that._listBinding.fromIndex ?
                                    that._listBinding.fromIndex(hints.groupMemberIndex) :
                                hints.groupMemberDescription !== undefined && that._listBinding.fromDescription ?
                                    that._listBinding.fromDescription(hints.groupMemberDescription) :
                                    that._listBinding.first()
                            );

                            var fetchBefore = Math.floor(0.5 * (that._batchSize - 1));
                            that._fetchBatch(itemPromise, fetchBefore, that._batchSize - 1 - fetchBefore);
                        }
563650
@Override
	public void init(IBatchConfig batchConfig)
			throws BatchContainerServiceException {
		
		String method = "init";
		if(logger.isLoggable(Level.FINER)) { logger.entering(sourceClass, method);	}
		
		String maxThreadPoolSizeStr = batchConfig.getConfigProperties().
				getProperty(BOUNDED_THREADPOOL_MAX_POOL_SIZE, defaultMaxThreadPoolSize); 
		
		int maxThreadPoolSize = Integer.parseInt(maxThreadPoolSizeStr);
		
		if(logger.isLoggable(Level.FINE)) { 
			logger.fine("Glassfish thread pool settings: (" + minThreadPoolSize + "," +  maxThreadPoolSize + "," 
		                 + idleThreadTimeout + "," + TimeUnit.SECONDS + "," + maxQueueSize + ")");  
		}
		
		BlockingQueue<Runnable> queue = null;
		if (maxQueueSize == -1) {
			queue = new LinkedBlockingQueue<Runnable>();
		} else {
			queue = new LinkedBlockingQueue<Runnable>(maxQueueSize);
		}
		
		executorService = new ThreadPoolExecutor(minThreadPoolSize, maxThreadPoolSize, idleThreadTimeout, TimeUnit.SECONDS, queue);  
		
		if(logger.isLoggable(Level.FINER)) { logger.exiting(sourceClass, method);	}
	}
197718
function() {
        return Promise.all([
            this._loadAccountData(),
            this._loadSyncData(),
        ]).then(([accountData, syncData]) => {
            console.log(
                `LocalIndexedDBStoreBackend: loaded initial data`,
            );
            this._syncAccumulator.accumulate({
                next_batch: syncData.nextBatch,
                rooms: syncData.roomsData,
                groups: syncData.groupsData,
                account_data: {
                    events: accountData,
                },
            });
        });
    }
706974
def startLoading(self):
        
        if super(XBatchItem, self).startLoading():
            tree = self.treeWidget()
            if not isinstance(tree, XOrbTreeWidget):
                self.takeFromTree()
                return
            
            next_batch = self.batch()
            tree._loadBatch(self, next_batch)
229592
long getInitialDelay(long stepSize) {
    long now = clock().wallTime();
    long stepBoundary = now / stepSize * stepSize;

    // Buffer by 10% of the step interval on either side
    long offset = stepSize / 10;

    // Check if the current delay is within the acceptable range
    long delay = now - stepBoundary;
    if (delay < offset) {
      return delay + offset;
    } else if (delay > stepSize - offset) {
      return stepSize - offset;
    } else {
      return delay;
    }
  }
193495
public InitialContext getInitialContext() throws ControlException {
        if (_initialContext != null) {
            return _initialContext;
        }
        Properties props = (Properties) _context.getControlPropertySet(Properties.class);
        String url = nullIfEmpty(props.url());
        String factory = nullIfEmpty(props.factory());
        if (url == null && factory == null) {
            try {
                return new InitialContext();
            }
            catch (NamingException e) {
                throw new ControlException("Cannot get default JNDI initial context", e);
            }

        }
        if (url == null || factory == null) {
            throw new ControlException("Both the provider-url and jndi factory need to be provided");

        }
        Hashtable<String, String> env = new Hashtable<String, String>();
        env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, factory);
        env.put(javax.naming.Context.PROVIDER_URL, url);

        String username = nullIfEmpty(props.jndiSecurityPrincipal());
        if (username != null)
            env.put(javax.naming.Context.SECURITY_PRINCIPAL, username);

        String password = nullIfEmpty(props.jndiSecurityCredentials());
        if (password != null)
            env.put(javax.naming.Context.SECURITY_CREDENTIALS, password);

        try {
            return _initialContext = new InitialContext(env);
        }
        catch (NamingException e) {
            throw new ControlException("Cannot get JNDI initial context at provider '" + url + "' with factory '" + factory + "'", e);
        }
    }
239191
function waitForReady (method) {
  return function fetchSync_readyWrapper (...args) {
    if (hasStartedInit) return ready.promise.then(() => method(...args))
    throw new Error('initialise first with fetchSync.init()')
  }
}
97354
@Override
    public BatchMetricQuery findBatchById(String id) {
        String json = _cacheService.get(ROOT + id);
        if (json == null) {
            return null;
        }
        try {
            Map<String, Object> batchData = MAPPER.readValue(json, new TypeReference<HashMap<String, Object>>() {});
            Status status = BatchMetricQuery.Status.fromInt((Integer) batchData.get("status"));
            int ttl = Integer.valueOf(batchData.get("ttl").toString());
            long createdDate = Long.valueOf(batchData.get("createdDate").toString());
            String ownerName = (String) batchData.get("ownerName");
            String batchId = (String) batchData.get("batchId");
            List<AsyncBatchedMetricQuery> queries = new ArrayList<>();

            int[] indices = MAPPER.readValue((String) batchData.get("indices"), int[].class);
            for (int index: indices) {
                queries.add(_findQueryById(batchId, index));
            }
            BatchMetricQuery batch = new BatchMetricQuery(status, ttl, createdDate, batchId, ownerName, queries);
            return batch;
        } catch (IOException ex) {
            throw new SystemException(ex);
        }
    }
629393
def initial_state(self, batch_size, dtype=tf.float32, trainable=False,
                    trainable_initializers=None, trainable_regularizers=None,
                    name=None):
    """"""
    return self._core.initial_state(
        batch_size, dtype=dtype, trainable=trainable,
        trainable_initializers=trainable_initializers,
        trainable_regularizers=trainable_regularizers, name=name)
310554
def fetch(self):
        '''
        
        '''
        if self._fetched is not None:
            raise RuntimeError('fetch() was called but the previous one has '
                               'not yet been applied. Not supported')
        if self._cache:
            self._fetched = len(self._cache)
        return self._cache[0:self._fetched]
788708
protected void initializeBatch(String databaseName, String table)
      throws SQLException {
    this.insertStmtPrefix = createInsertStatementStr(databaseName, table);
    this.insertPstmtForFixedBatch =
        this.conn.prepareStatement(createPrepareStatementStr(this.batchSize));
    LOG.info(String.format("Initialized for %s insert " + this, (this.batchSize > 1) ? "batch" : ""));
  }
8333
private void tryInit() {
    try {
      Configuration conf = getSnapshotConfiguration();
      if (conf != null) {
        // Since this is only used for background loading of transaction snapshots, we use the no-op metrics collector,
        // as there are no relevant metrics to report
        this.storage = new HDFSTransactionStateStorage(conf, new SnapshotCodecProvider(conf),
                                                       new TxMetricsCollector());
        this.storage.startAndWait();
        this.snapshotRefreshFrequency = conf.getLong(TxConstants.Manager.CFG_TX_SNAPSHOT_INTERVAL,
                                                     TxConstants.Manager.DEFAULT_TX_SNAPSHOT_INTERVAL) * 1000;
        this.initialized = true;
      } else {
        LOG.info("Could not load configuration");
      }
    } catch (Exception e) {
      LOG.info("Failed to initialize TransactionStateCache due to: " + e.getMessage());
    }
  }
423886
@Override
	public void init(IBatchConfig batchConfig) throws BatchContainerServiceException {

		logger.config("Entering CLASSNAME.init(), batchConfig =" + batchConfig);

		this.batchConfig = batchConfig;

		schema = batchConfig.getDatabaseConfigurationBean().getSchema();

		if (!batchConfig.isJ2seMode()) {

			dataSource = batchConfig.getDatabaseConfigurationBean().getDataSource();

			if (dataSource != null) {

				logger.config("DataSource obtained from DB config bean = " + dataSource);

			} else {

				jndiName = batchConfig.getDatabaseConfigurationBean().getJndiName();

				logger.config("JNDI name = " + jndiName);

				if (jndiName == null || jndiName.equals("")) {
					throw new BatchContainerServiceException("JNDI name is not defined, which was the last way to initialize a DataSource.");
				}

				try {
					Context ctx = new InitialContext();
					dataSource = (DataSource) ctx.lookup(jndiName);

				} catch (NamingException e) {
					logger.severe("Lookup failed for JNDI name: " + jndiName + 
							".  One cause of this could be that the batch runtime is incorrectly configured to EE mode when it should be in SE mode.");
					throw new BatchContainerServiceException(e);
				}
			}

		} else {
			driver = batchConfig.getDatabaseConfigurationBean().getJdbcDriver();
			url = batchConfig.getDatabaseConfigurationBean().getJdbcUrl();
			userId = batchConfig.getDatabaseConfigurationBean().getDbUser();
			pwd = batchConfig.getDatabaseConfigurationBean().getDbPassword();

			logger.config("driver: " + driver + ", url: " + url);
		}

		try {
			// only auto-create on Derby
			if(isDerby()) {	
				if(!isSchemaValid()) {
					createSchema();
				}
				checkAllTables();
			}
		} catch (SQLException e) {
			logger.severe(e.getLocalizedMessage());
			throw new BatchContainerServiceException(e);
		}

		logger.config("Exiting CLASSNAME.init()");
	}
372067
function setInitialState(ret) {
    
    var e, r;
    
    // Before resetting, keep a copy of args
    if (ret) {
      e = (errored ? errors : null);
      r = results;
    }
    
    // Reset runtime vars to their default state
    counter = 0;
    errored = false;
    errors = [];
    results = [];
    
    // Flush stack on first run or when config.flush is true
    if (stack == null || config.flush) stack = [];
    
    // Return prepared arguments
    if (ret) return [e, r];

  }
1244456
def fetchcbatch(self):
        ''''''
        if not self._last_operation.is_columnar:
            raise NotSupportedError("Server does not support columnar "
                                    "fetching")
        if not self.has_result_set:
            raise ProgrammingError(
                "Trying to fetch results on an operation with no results.")
        if len(self._buffer) > 0:
            log.debug('fetchcbatch: buffer has data in. Returning it and wiping buffer')
            batch = self._buffer
            self._buffer = Batch()
            return batch
        elif self._last_operation_active:
            log.debug('fetchcbatch: buffer empty and op is active => fetching '
                      'more data')
            batch = (self._last_operation.fetch(
                         self.description,
                         self.buffersize,
                         convert_types=self.convert_types))
            if len(batch) == 0:
               return None
            return batch
        else:
           return None
1270029
private BatchObject initBatchObject(Identity identity, Class clazz) {
        if (EventData.class.equals(clazz)) {
            RowBatch rowbatch = new RowBatch();
            rowbatch.setIdentity(identity);
            return rowbatch;
        } else if (FileData.class.equals(clazz)) {
            FileBatch fileBatch = new FileBatch();
            fileBatch.setIdentity(identity);
            return fileBatch;
        } else {
            throw new TransformException("no support Data[" + clazz.getName() + "]");
        }
    }
201334
@Inject
   public void preStart() {
      // We have to do this before start, since some components may start before the actual cache and they
      // have to have access to the default metadata on some operations
      defaultMetadata = new EmbeddedMetadata.Builder()
            .lifespan(config.expiration().lifespan()).maxIdle(config.expiration().maxIdle()).build();
      transactional = config.transaction().transactionMode().isTransactional();
      batchingEnabled = config.invocationBatching().enabled();
   }