allocate a big chunk of data
172468
private void preallocate() throws IOException {
    long position = fc.position();
    long triggerSize = Math.max(FSEditLog.preallocateSize / 100, 4096);
    if (position + triggerSize >= fc.size()) {
      if(FSNamesystem.LOG.isDebugEnabled()) {
        FSNamesystem.LOG.debug("Preallocating Edit log, current size "
            + fc.size());
      }
      fill.position(0);
      int written = fc.write(fill, position);
      if(FSNamesystem.LOG.isDebugEnabled()) {
        FSNamesystem.LOG.debug("Edit log size is now " + fc.size() +
            " written " + written + " bytes " + " at offset " + position);
      }
    }
  }
1337648
public void allocate(long size) throws IOException, ServerException {
        Command cmd = new Command("ALLO", String.valueOf(size));
        Reply reply = null;
        try {
            reply = controlChannel.execute(cmd);
        } catch (UnexpectedReplyCodeException urce) {
            throw ServerException.embedUnexpectedReplyCodeException(urce);
        } catch (FTPReplyParseException rpe) {
            throw ServerException.embedFTPReplyParseException(rpe);
        }
    }
751603
def _split_batches(self, data, batch_size):
        """"""
        for i in range(0, len(data), batch_size):
            yield data[i : i + batch_size]
245665
function compressSessionData(data) {
    let amorphicOptions = AmorphicContext.amorphicOptions;
    if (amorphicOptions.compressSession) {
        return zlib.deflateSync(data);
    }

    return data;
}
819239
def allocate(self):
        """"""
        network_name = None

        self._hypervisor = libvirt.open(
            self.configuration.get('hypervisor', 'lxc:///'))

        if 'network' in self.configuration:
            self._network = network.create(self._hypervisor, self.identifier,
                                           self.configuration['network'])
            network_name = self._network.name()

        self._domain = domain_create(self._hypervisor, self.identifier,
                                     self.configuration['domain'],
                                     network_name=network_name)
        if self._network is None:
            self._network = network.lookup(self._domain)
565622
def pack_data(self, remaining_size):
        """"""
        payload = self.part_struct.pack(self.locator_id, self.readoffset + 1, self.readlength, b'    ')
        return 4, payload
558703
def _create_dataset(
            self, group, chunk_size, compression, compression_opts):
        """"""
        if chunk_size == 'auto':
            chunks = True
        else:
            # if dtype is a variable str, guess representative size is 20 bytes
            per_chunk = (
                nb_per_chunk(20, 1, chunk_size) if self.dtype == np.dtype('O')
                else nb_per_chunk(
                        np.dtype(self.dtype).itemsize, 1, chunk_size))
            chunks = (per_chunk,)

        shape = (0,)
        maxshape = (None,)

        # raise if per_chunk >= 4 Gb, this is requested by h5py
        group.create_dataset(
            self.name, shape, dtype=self.dtype,
            chunks=chunks, maxshape=maxshape, compression=compression,
            compression_opts=compression_opts)
364711
def allocate(n, dtype=numpy.float32):
    
    return drv.pagelocked_empty(int(n), dtype, order='C', mem_flags=drv.host_alloc_flags.PORTABLE)
20105
def distribute(self, cache):
        
        data = self._features_as_kv()
        for key in data.keys():
            cache.batch_set(data[key])
915480
def _preallocate_samples(self):
        
        self.prealloc_samples_ = []
        for i in range(self.num_prealloc_samples_):
            self.prealloc_samples_.append(self.sample())
839135
private void allocateNormal(PooledByteBuf<T> buf, int reqCapacity, int normCapacity) {
        if (q050.allocate(buf, reqCapacity, normCapacity) || q025.allocate(buf, reqCapacity, normCapacity) ||
            q000.allocate(buf, reqCapacity, normCapacity) || qInit.allocate(buf, reqCapacity, normCapacity) ||
            q075.allocate(buf, reqCapacity, normCapacity)) {
            return;
        }

        // Add a new chunk.
        PoolChunk<T> c = newChunk(pageSize, maxOrder, pageShifts, chunkSize);
        boolean success = c.allocate(buf, reqCapacity, normCapacity);
        assert success;
        qInit.add(c);
    }
1077673
def nbytes_stored(self):
        """"""
        m = getsize(self._store, self._path)
        if self._chunk_store is None:
            return m
        else:
            n = getsize(self._chunk_store, self._path)
            if m < 0 or n < 0:
                return -1
            else:
                return m + n
1063668
def preallocate(self, data_loader, training):
        
        batch_size = data_loader.batch_size
        max_len = data_loader.dataset.max_len

        src_length = [max_len] * batch_size
        tgt_length = [max_len] * batch_size

        if self.batch_first:
            shape = (batch_size, max_len)
        else:
            shape = (max_len, batch_size)

        src = torch.full(shape, 4, dtype=torch.int64)
        tgt = torch.full(shape, 4, dtype=torch.int64)
        src = src, src_length
        tgt = tgt, tgt_length
        self.iterate(src, tgt, update=False, training=training)
        self.model.zero_grad()
1281450
function cpuReduce (data, op) {
  var result = op(data[0], data[1])
  for (var i = 2; i < data.length; i++) {
    result = op(result, data[i])
  }
  return result
}
201806
def alloc(self):
        """"""
        byte = 0
        remaining_bytes = bytearray(5)
        i = 0
        
        remaining_length = self.remaining_length
        
        self.payload = None
        self.remaining_count = 0
        loop_flag = True
        
        #self.dump()
        while loop_flag:
            byte = remaining_length % 128
            remaining_length = remaining_length / 128
            
            if remaining_length > 0:
                byte = byte | 0x80
                
            remaining_bytes[self.remaining_count] = byte
            self.remaining_count += 1
            
            if not (remaining_length > 0 and self.remaining_count < 5):
                loop_flag = False
        
        if self.remaining_count == 5:
            return NC.ERR_PAYLOAD_SIZE
        
        self.packet_length = self.remaining_length + 1 + self.remaining_count
        self.payload = bytearray(self.packet_length)
        
        self.payload[0] = self.command
        
        i = 0
        while i < self.remaining_count:
            self.payload[i+1] = remaining_bytes[i]
            i += 1
        
        self.pos = 1 + self.remaining_count
        
        return NC.ERR_SUCCESS
220943
private long allocate_from_tail(int block_size)
    throws IOException
    {
        long block_to_alloc;

        block_to_alloc = tail_ptr;
        tail_ptr = tail_ptr + block_size;

        allocated_blocks++;
        allocated_words += block_size;

        seek_and_count(block_to_alloc);
        writeInt(- block_size);
        seek_and_count(TAIL_DPTR);
        writeLong(tail_ptr);

        return(block_to_alloc + HDR_SIZE);
    }
404200
public PooledByteBuffer allocate() {
        final Queue<Slice> sliceQueue = this.sliceQueue;
        final Slice slice = sliceQueue.poll();
        if (slice == null && (maxRegions <= 0 || regionUpdater.getAndIncrement(this) < maxRegions)) {
            final int bufferSize = this.bufferSize;
            final int buffersPerRegion = this.buffersPerRegion;
            final ByteBuffer region = allocator.allocate(buffersPerRegion * bufferSize);
            int idx = bufferSize;
            for (int i = 1; i < buffersPerRegion; i ++) {
                sliceQueue.add(new Slice(region, idx, bufferSize));
                idx += bufferSize;
            }
            final Slice newSlice = new Slice(region, 0, bufferSize);
            return new PooledByteBuffer(newSlice, newSlice.slice(), sliceQueue);
        }
        if (slice == null) {
            return null;
        }
        return new PooledByteBuffer(slice, slice.slice(), sliceQueue);
    }