Get a chunk by index
762581
def get(self, index):
        """"""
        assert index <= self.count
        assert index < self.size
        offset = index * self.chunk_size
        return self.data[offset:offset + self.chunk_size]
335123
def ChunksExist(self, chunk_numbers):
    """"""
    index_urns = {
        self.urn.Add(self.CHUNK_ID_TEMPLATE % chunk_number): chunk_number
        for chunk_number in chunk_numbers
    }

    res = {chunk_number: False for chunk_number in chunk_numbers}

    for metadata in aff4.FACTORY.Stat(index_urns):
      res[index_urns[metadata["urn"]]] = True

    return res
1316543
def ChunkBy(self, f=None):
    
    if f is None:
        return _chunk(self)
    if is_to_destruct(f):
        f = destruct_func(f)
    return _chunk(self, f)
1111579
def get_chunk_path_from_string(string, chunk=3):
    """"""
    return os.path.join(
        *list(generate_chunks(
            string,
            chunk
        ))
    )
999631
def create_index(group, chunk_size, compression=None, compression_opts=None):
    """"""
    dtype = np.int64
    if chunk_size == 'auto':
        chunks = True
    else:
        chunks = (nb_per_chunk(np.dtype(dtype).itemsize, 1, chunk_size),)

    group.create_dataset(
        'index', (0,), dtype=dtype,
        chunks=chunks, maxshape=(None,),
        compression=compression, compression_opts=compression_opts)
567975
def chunks(l, n):
    """"""
    if n:
        for i in xrange(0, len(l), n):
            yield l[i:i + n]
356879
def remove(self, index):
        """"""
        assert index < self.count
        last_index = self.count - 1
        data = self.get(index)

        if index == last_index:
            # easy case - nothing to do except zero last chunk
            last_data = data
            moved = None
        else:
            last_data = self.get(last_index)
            # copy the last chunk's data over the data to be deleted
            data[0:self.chunk_size] = last_data
            moved = last_index

        # zero last chunk's data
        last_data[0:self.chunk_size] = [0] * self.chunk_size
        self.count -= 1

        # provide which index has now moved
        return moved
554887
def chunks(iterable, size=1):
    """"""
    iterator = iter(iterable)

    for element in iterator:
        yield chain([element], islice(iterator, size - 1))
1287902
function pullByIndex(arr, index) {
    if (index < arr.length) {
        const value = arr[index];
        shift(arr, index);
        return value;
    }

    return undefined;
}
182338
def _chunk_list(l, n):
    """"""
    for i in range(0, len(l), n):
        yield l[i:i + n]
419810
def _GetChunkForWriting(self, chunk):
    """"""
    try:
      chunk = self.chunk_cache.Get(chunk)
      chunk.dirty = True
      return chunk
    except KeyError:
      pass

    try:
      chunk = self._ReadChunk(chunk)
      chunk.dirty = True
      return chunk
    except KeyError:
      pass

    fd = io.BytesIO()
    fd.chunk = chunk
    fd.dirty = True
    self.chunk_cache.Put(chunk, fd)

    # Keep track of the biggest chunk_number we've seen so far.
    if chunk > self.last_chunk:
      self.last_chunk = chunk
      self._dirty = True

    return fd
698371
def _chunk_from_ranges(contents_lines,
                       start_line_index,
                       start_column_index,
                       end_line_index,
                       end_column_index):
    
    # If the start and end line are the same we have to compensate for
    # that by subtracting start_column_index from end_column_index
    if start_line_index == end_line_index:
        end_column_index -= start_column_index

    lines = contents_lines[start_line_index:end_line_index + 1]
    lines[0] = lines[0][start_column_index:]
    lines[-1] = lines[-1][:end_column_index]

    return _ChunkInfo(start_line_index,
                      start_column_index,
                      lines)
270159
def chunks(event_list, chunk_size):
    """"""
    for i in range(0, len(event_list), chunk_size):
        yield event_list[i:i + chunk_size]
50774
def chunks(items, chunksize):
    """"""

    items = iter(items)
    for first in items:
        chunk = chain((first,), islice(items, chunksize - 1))
        yield chunk
        deque(chunk, 0)
1015754
def generate_chunks(data, chunk_size=DEFAULT_CHUNK_SIZE):
    """"""
    iterator = iter(repeated.getvalues(data))

    while True:
        chunk = list(itertools.islice(iterator, chunk_size))
        if not chunk:
            return

        yield chunk
98847
public static void extractChunkPart(Chunk ic, Chunk oc, int startRow, int nrows, Futures fs) {
    try {
      NewChunk dst = new NewChunk(oc);
      dst._len = dst._sparseLen = 0;
      // Iterate over values skip all 0
      ic.extractRows(dst, startRow,startRow+nrows);
      // Handle case when last added value is followed by zeros till startRow+nrows
      assert dst._len == oc._len : "NewChunk.dst.len = " + dst._len + ", oc._len = " + oc._len;
      dst.close(dst.cidx(), fs);
    } catch(RuntimeException t){
      Log.err("got exception in chunkSplitter, ic = " + ic + ", oc = " + oc + " startRow = " + startRow + " nrows = " + nrows);
      throw t;
    }
  }
915646
def most_even_chunk(string, group):
    """"""
    counts = [0] + most_even(len(string), group)
    indices = accumulate(counts)
    slices = window(indices, 2)
    return [string[slice(*one)] for one in slices]