Creates new blob entries for the given blob keys
353061
def parse_corant(blob):
    """"""

    if 'track_seamuon' in blob.keys():

        muon = blob['track_seamuon']

        blob['Muon'] = Table({
            'id': np.array(muon)[:, 0].astype(int),
            'pos_x': np.array(muon)[:, 1],
            'pos_y': np.array(muon)[:, 2],
            'pos_z': np.array(muon)[:, 3],
            'dir_x': np.array(muon)[:, 4],
            'dir_y': np.array(muon)[:, 5],
            'dir_z': np.array(muon)[:, 6],
            'energy': np.array(muon)[:, 7],
            'time': np.array(muon)[:, 8],
            'particle_id': np.array(muon)[:, 9].astype(int),
            'is_charm': np.array(muon)[:, 10].astype(int),
            'mother_pid': np.array(muon)[:, 11].astype(int),
            'grandmother_pid': np.array(muon)[:, 11].astype(int),
        },
                             h5loc='muon')

        blob['MuonMultiplicity'] = Table({
            'muon_multiplicity': len(np.array(muon)[:, 6])
        },
                                         h5loc='muon_multiplicity')

    if 'track_seaneutrino' in blob.keys():

        nu = blob['track_seaneutrino']

        blob['Neutrino'] = Table({
            'id': np.array(nu)[:, 0].astype(int),
            'pos_x': np.array(nu)[:, 1],
            'pos_y': np.array(nu)[:, 2],
            'pos_z': np.array(nu)[:, 3],
            'dir_x': np.array(nu)[:, 4],
            'dir_y': np.array(nu)[:, 5],
            'dir_z': np.array(nu)[:, 6],
            'energy': np.array(nu)[:, 7],
            'time': np.array(nu)[:, 8],
            'particle_id': np.array(nu)[:, 9].astype(int),
            'is_charm': np.array(nu)[:, 10].astype(int),
            'mother_pid': np.array(nu)[:, 11].astype(int),
            'grandmother_pid': np.array(nu)[:, 11].astype(int),
        },
                                 h5loc='nu')
        blob['NeutrinoMultiplicity'] = Table({
            'total': len(np.array(nu)[:, 6]),
            'nue': len(np.array(nu)[:, 6][np.array(nu)[:, 9] == 66]),
            'anue': len(np.array(nu)[:, 6][np.array(nu)[:, 9] == 67]),
            'numu': len(np.array(nu)[:, 6][np.array(nu)[:, 9] == 68]),
            'anumu': len(np.array(nu)[:, 6][np.array(nu)[:, 9] == 69]),
        },
                                             h5loc='nu_multiplicity')

    if ('track_seamuon' or 'track_seaneutrino') in blob.keys():

        blob['Weights'] = Table({
            'w1': blob['weights'][0][0],
            'w2': blob['weights'][0][1],
            'w3': blob['weights'][0][2],
        },
                                h5loc='weights')

    if 'track_primary' in blob.keys():

        primary = blob['track_primary']

        blob['Primary'] = Table({
            'id': np.array(primary)[:, 0].astype(int),
            'pos_x': np.array(primary)[:, 1],
            'pos_y': np.array(primary)[:, 2],
            'pos_z': np.array(primary)[:, 3],
            'dir_x': np.array(primary)[:, 4],
            'dir_y': np.array(primary)[:, 5],
            'dir_z': np.array(primary)[:, 6],
            'energy': np.array(primary)[:, 7],
            'time': np.array(primary)[:, 8],
            'particle_id': np.array(primary)[:, 9].astype(int)
        },
                                h5loc='primary')

    return blob
1011181
def AddBlob(self, blob_hash, length, chunk_number):
    """"""
    if len(blob_hash.AsBytes()) != self._HASH_SIZE:
      raise ValueError("Hash '%s' doesn't have correct length (%d)." %
                       (blob_hash, self._HASH_SIZE))

    # If we're adding a new blob, we should increase the size. If we're just
    # updating an existing blob, the size should stay the same.
    # That is, if we read the index at the right offset and no hash is there, we
    # must not have seen this blob before, so we say we're adding a new one and
    # increase in size.
    if not self.ChunkExists(chunk_number):
      # We say that we've increased in size by the size of the blob,
      # but really we only store its hash in the AFF4SparseImage.
      self.size += length
      self._dirty = True
      # Keep track of the biggest chunk_number we've seen so far.
      if chunk_number > self.last_chunk:
        self.last_chunk = chunk_number
        self._dirty = True

    index_urn = self.urn.Add(self.CHUNK_ID_TEMPLATE % chunk_number)
    # TODO(amoser): This opens a subobject for each AddBlob call :/
    with aff4.FACTORY.Create(
        index_urn, aff4.AFF4MemoryStream, token=self.token) as fd:
      fd.write(blob_hash.AsBytes())
    if chunk_number in self.chunk_cache:
      self.chunk_cache.Pop(chunk_number)
778685
def get_multi_async(cls, blob_keys, **ctx_options):
    """"""
    for blob_key in blob_keys:
      if not isinstance(blob_key, (BlobKey, basestring)):
        raise TypeError('Expected blob key, got %r' % (blob_key,))
    if 'parent' in ctx_options:
      raise TypeError('Parent is not supported')
    blob_key_strs = map(str, blob_keys)
    keys = [model.Key(BLOB_INFO_KIND, id) for id in blob_key_strs]
    return model.get_multi_async(keys, **ctx_options)
273889
def append(self, data):
        """"""
        for k in self._entries.keys():
            self._entries[k].append(data._entries[k])
82029
public Blob createBlobFromInputStream(String bucketName, String blobName) {
    // [START createBlobFromInputStream]
    InputStream content = new ByteArrayInputStream("Hello, World!".getBytes(UTF_8));
    BlobId blobId = BlobId.of(bucketName, blobName);
    BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType("text/plain").build();
    Blob blob = storage.create(blobInfo, content);
    // [END createBlobFromInputStream]
    return blob;
  }
1182257
def from_blob(cls, s):
        """"""
        atom_str, edge_str = s.split()
        numbers = np.array([int(s) for s in atom_str.split(",")])
        edges = []
        orders = []
        for s in edge_str.split(","):
            i, j, o = (int(w) for w in s.split("_"))
            edges.append((i, j))
            orders.append(o)
        return cls(edges, numbers, np.array(orders))
430589
private void loadAllAndReplaceExisting(Set<? extends K> keys) {
    int[] ignored = { 0 };
    Map<K, V> loaded = cacheLoader.get().loadAll(keys);
    for (Map.Entry<? extends K, ? extends V> entry : loaded.entrySet()) {
      putNoCopyOrAwait(entry.getKey(), entry.getValue(), /* publishToWriter */ false, ignored);
    }
  }
1366325
def stream(key)
        blob = blob_for(key)

        chunk_size = 5.megabytes
        offset = 0

        raise ActiveStorage::FileNotFoundError unless blob.present?

        while offset < blob.properties[:content_length]
          _, chunk = blobs.get_blob(container, key, start_range: offset, end_range: offset + chunk_size - 1)
          yield chunk.force_encoding(Encoding::BINARY)
          offset += chunk_size
        end
      end
759321
def map_blocks(data, f, blen=None, storage=None, create='array', **kwargs):
    """"""

    # setup
    storage = _util.get_storage(storage)
    if isinstance(data, tuple):
        blen = max(_util.get_blen_array(d, blen) for d in data)
    else:
        blen = _util.get_blen_array(data, blen)
    if isinstance(data, tuple):
        _util.check_equal_length(*data)
        length = len(data[0])
    else:
        length = len(data)

    # block-wise iteration
    out = None
    for i in range(0, length, blen):
        j = min(i+blen, length)

        # obtain blocks
        if isinstance(data, tuple):
            blocks = [d[i:j] for d in data]
        else:
            blocks = [data[i:j]]

        # map
        res = f(*blocks)

        # store
        if out is None:
            out = getattr(storage, create)(res, expectedlen=length, **kwargs)
        else:
            out.append(res)

    return out
1356637
def new(cls, alias, sealed_obj, algorithm, key, key_size):
        
        timestamp = int(time.time()) * 1000

        raise NotImplementedError("Creating Secret Keys not implemented")
523825
def put_blob(storage_conn=None, **kwargs):
    '''
    
    '''
    if not storage_conn:
        storage_conn = get_storage_conn(opts=kwargs)

    if 'container' not in kwargs:
        raise SaltSystemExit(code=42, msg='The blob container name must be specified as "container"')

    if 'name' not in kwargs:
        raise SaltSystemExit(code=42, msg='The blob name must be specified as "name"')

    if 'blob_path' not in kwargs and 'blob_content' not in kwargs:
        raise SaltSystemExit(
            code=42,
            msg='Either a path to a file needs to be passed in as "blob_path" '
            'or the contents of a blob as "blob_content."'
        )

    blob_kwargs = {
        'container_name': kwargs['container'],
        'blob_name': kwargs['name'],
        'cache_control': kwargs.get('cache_control', None),
        'content_language': kwargs.get('content_language', None),
        'content_md5': kwargs.get('content_md5', None),
        'x_ms_blob_content_type': kwargs.get('blob_content_type', None),
        'x_ms_blob_content_encoding': kwargs.get('blob_content_encoding', None),
        'x_ms_blob_content_language': kwargs.get('blob_content_language', None),
        'x_ms_blob_content_md5': kwargs.get('blob_content_md5', None),
        'x_ms_blob_cache_control': kwargs.get('blob_cache_control', None),
        'x_ms_meta_name_values': kwargs.get('meta_name_values', None),
        'x_ms_lease_id': kwargs.get('lease_id', None),
    }
    if 'blob_path' in kwargs:
        data = storage_conn.put_block_blob_from_path(
            file_path=kwargs['blob_path'],
            **blob_kwargs
        )
    elif 'blob_content' in kwargs:
        data = storage_conn.put_block_blob_from_bytes(
            blob=kwargs['blob_content'],
            **blob_kwargs
        )

    return data
244605
function createKeys (cb) {
  mkdirp(CONFIG_DIR, function (err) {
    if (err) return cb(err)

    fs.readdir(CONFIG_DIR, function (err, files) {
      if (err) return cb(err)
      var keys = {}

      // check if both files exist
      if (files.indexOf(KEY_NAME) !== -1 && files.indexOf(CERT_NAME) !== -1) {
        return async.parallel([
          function (done) {
            fs.readFile(CERT_LOCATION, function (err, buf) {
              if (err) return done(err)
              keys.cert = buf
              done()
            })
          },
          function (done) {
            fs.readFile(KEY_LOCATION, function (err, buf) {
              if (err) return done(err)
              keys.key = buf
              done()
            })
          }
        ], function (err) {
          if (err) return cb(err)
          cb(null, keys)
        })
      }

      var opts = {
        days: 2048,
        algorithm: 'sha256',
        extensions: [
          {
            name: 'subjectAltName',
            altNames: [
              {
                type: 2, // DNSName
                value: 'localhost'
              }
            ]
          }
        ]
      }

      selfsigned.generate([{ name: 'commonName', value: 'localhost' }], opts, function (err, keys) {
        if (err) return cb(err)

        keys = {
          key: keys.private,
          cert: keys.cert
        }

        async.parallel([
          function (done) {
            fs.writeFile(KEY_LOCATION, keys.key, done)
          },
          function (done) {
            fs.writeFile(CERT_LOCATION, keys.cert, done)
          }
        ], function (err) {
          if (err) return cb(err)
          cb(null, keys)
        })
      })
    })
  })
}
129251
public void createBlob(String key, byte [] data, SettableBlobMeta meta) throws KeyAlreadyExistsException, IOException {
        AtomicOutputStream out = null;
        try {
            out = createBlob(key, meta);
            out.write(data);
            out.close();
            out = null;
        } finally {
            if (out != null) {
                out.cancel();
            }
        }
    }
1302273
def _fill_entries(self):
        """"""
        for file in self.index.files:
            path = self.index.paths[file.pathIndex]
            data_offset = file.dataOffset
            data_size = file.dataSize
            obj = RAFEntry(self._data_handle, path, data_offset, data_size)
            # Add to full path dictionary
            assert path not in self.entries_full
            self.entries_full[path.lower()] = obj
            # Add to name dictionary
            name = os.path.basename(path).lower()
            if name not in self.entries_name:
                self.entries_name[name] = []
            self.entries_name[name].append(obj)
1312919
function blobify(data) {
	if(typeof data === "string") return s2ab(data);
	if(Array.isArray(data)) return a2u(data);
	return data;
}
964376
@Override
    public CompletableFuture<Void> createAllLeasesIfNotExists(List<String> partitionIds) {
        CompletableFuture<Void> future = null;

        // Optimization: list the blobs currently existing in the directory. If there are the
        // expected number of blobs, then we can skip doing the creates.
        int blobCount = 0;
        try {
            Iterable<ListBlobItem> leaseBlobs = this.consumerGroupDirectory.listBlobs("", true, null, this.leaseOperationOptions, null);
            Iterator<ListBlobItem> blobIterator = leaseBlobs.iterator();
            while (blobIterator.hasNext()) {
                blobCount++;
                blobIterator.next();
            }
        } catch (URISyntaxException | StorageException e) {
            TRACE_LOGGER.error(this.hostContext.withHost("Exception checking lease existence - leaseContainerName: " + this.storageContainerName + " consumerGroupName: "
                    + this.hostContext.getConsumerGroupName() + " storageBlobPrefix: " + this.storageBlobPrefix), e);
            future = new CompletableFuture<Void>();
            future.completeExceptionally(LoggingUtils.wrapException(e, EventProcessorHostActionStrings.CREATING_LEASES));
        }

        if (future == null) {
            // No error checking the list, so keep going
            if (blobCount == partitionIds.size()) {
                // All expected blobs found, so short-circuit
                future = CompletableFuture.completedFuture(null);
            } else {
                // Create the blobs in parallel
                ArrayList<CompletableFuture<CompleteLease>> createFutures = new ArrayList<CompletableFuture<CompleteLease>>();

                for (String id : partitionIds) {
                    CompletableFuture<CompleteLease> oneCreate = CompletableFuture.supplyAsync(() -> {
                        CompleteLease returnLease = null;
                        try {
                            returnLease = createLeaseIfNotExistsInternal(id, this.leaseOperationOptions);
                        } catch (URISyntaxException | IOException | StorageException e) {
                            TRACE_LOGGER.error(this.hostContext.withHostAndPartition(id,
                                    "Exception creating lease - leaseContainerName: " + this.storageContainerName + " consumerGroupName: " + this.hostContext.getConsumerGroupName()
                                            + " storageBlobPrefix: " + this.storageBlobPrefix), e);
                            throw LoggingUtils.wrapException(e, EventProcessorHostActionStrings.CREATING_LEASES);
                        }
                        return returnLease;
                    }, this.hostContext.getExecutor());
                    createFutures.add(oneCreate);
                }

                CompletableFuture<?>[] dummy = new CompletableFuture<?>[createFutures.size()];
                future = CompletableFuture.allOf(createFutures.toArray(dummy));
            }
        }

        return future;
    }
1337203
public Blob createNewBlob(int blockSize) throws PersistException {
        StoredLob lob = mLobStorage.prepare();
        lob.setLocator(mLocatorSequence.nextLongValue());
        lob.setBlockSize(blockSize);
        lob.setLength(0);
        lob.insert();
        return new BlobImpl(lob.getLocator());
    }