Add a zonefile to the database.
    Mark it as present or absent.
    Keep our in-RAM inventory vector up-to-date
510764
def atlasdb_add_zonefile_info( name, zonefile_hash, txid, present, tried_storage, block_height, con=None, path=None ):
    
    global ZONEFILE_INV, NUM_ZONEFILES, ZONEFILE_INV_LOCK

    with AtlasDBOpen( con=con, path=path ) as dbcon:
        with ZONEFILE_INV_LOCK:
            # need to lock here since someone could call atlasdb_cache_zonefile_info
            if present:
                present = 1
            else:
                present = 0

            if tried_storage:
                tried_storage = 1
            else:
                tried_storage = 0

            sql = "UPDATE zonefiles SET name = ?, zonefile_hash = ?, txid = ?, present = ?, tried_storage = ?, block_height = ? WHERE txid = ?;"
            args = (name, zonefile_hash, txid, present, tried_storage, block_height, txid )

            cur = dbcon.cursor()
            update_res = atlasdb_query_execute( cur, sql, args )
            dbcon.commit()

            if update_res.rowcount == 0:
                sql = "INSERT OR IGNORE INTO zonefiles (name, zonefile_hash, txid, present, tried_storage, block_height) VALUES (?,?,?,?,?,?);"
                args = (name, zonefile_hash, txid, present, tried_storage, block_height)
            
                cur = dbcon.cursor()
                atlasdb_query_execute( cur, sql, args )
                dbcon.commit()

            # keep in-RAM zonefile inv coherent
            zfbits = atlasdb_get_zonefile_bits( zonefile_hash, con=dbcon, path=path )

            inv_vec = None
            if ZONEFILE_INV is None:
                inv_vec = ""
            else:
                inv_vec = ZONEFILE_INV[:]

            ZONEFILE_INV = atlas_inventory_flip_zonefile_bits( inv_vec, zfbits, present )
            log.debug('Set {} ({}) to {}'.format(zonefile_hash, ','.join(str(i) for i in zfbits), present))

            # keep in-RAM zonefile count coherent
            NUM_ZONEFILES = atlasdb_zonefile_inv_length( con=dbcon, path=path )

    return True
761206
def add(self, abspath_or_winfile, enable_verbose=True):
        
        if isinstance(abspath_or_winfile, str): # abspath
            if abspath_or_winfile in self.files:
                if enable_verbose:
                    print("'%s' already in this collections" % 
                          abspath_or_winfile)
            else:
                self.files.setdefault(abspath_or_winfile, WinFile(abspath_or_winfile))
        elif isinstance(abspath_or_winfile, WinFile): # WinFile
            if abspath_or_winfile.abspath in self.files:
                if enable_verbose:
                    print("'%s' already in this collections" % 
                          abspath_or_winfile)
            else:
                self.files.setdefault(abspath_or_winfile.abspath, abspath_or_winfile)
        else:
            raise TypeError
321305
def atlasdb_set_zonefile_tried_storage( zonefile_hash, tried_storage, con=None, path=None ):
    
    with AtlasDBOpen(con=con, path=path) as dbcon:
        if tried_storage:
            tried_storage = 1
        else:
            tried_storage = 0

        sql = "UPDATE zonefiles SET tried_storage = ? WHERE zonefile_hash = ?;"
        args = (tried_storage, zonefile_hash)

        cur = dbcon.cursor()
        res = atlasdb_query_execute( cur, sql, args )
        dbcon.commit()

    return True
689058
def add(self, index, value):
        
        self.buf.append(value)
        if (index - self.flush_at) < self.interval:
            return
        value = np.mean(self.buf)
        if self.verbose:
            logger.info("iter={} {{{}}}={}".format(index, self.name, value))
        if self.fd is not None:
            print("{} {:g}".format(index, value), file=self.fd)
        self.flush_at = index
        self.buf = []
503863
def _update(self, dataFile, handle):
        
        self._cache.remove((dataFile, handle))
        self._add(dataFile, handle)
1007449
public function addZoneRecord($zone, $type, $name, $content, $ttl = 120)
    {
        // List of supported record types to add
        $types = ['A', 'AAAA', 'TXT', 'CNAME'];
        if (!in_array($type, $types)) {
            throw new \Exception("record type {$type} not in list of supported types: ".implode(',', $types));
        }
        // Make sure we know what zone to target
        if (!isset($this->zones[$zone])) {
            throw new \Exception("unknown zone {$zone} did you call getZones()?");
        }
        // VERISCUMs new api is REALLY DUMB about name.zone.tld with a missing DOT at the end.
        if(substr($name, -1) != '.') {
            $name = $name . '.';
        }
        // build our postable body
        $request = [
                    'owner'   => $name,
                    'type'    => $type,
                    'rdata'   => $content,
                    'ttl'     => $ttl,
                ];
        $uri = $this->baseuri.'/accounts/'.$this->account.'/zones/'.$zone.'/rr';
        $result = $this->httpPostJson($uri, $request);
        // Save the resulting new zone into our cache of zones
        $this->zonerecords[$zone][] = $result;

        return $result;
    }
640876
def store_atlas_zonefile_data(zonefile_data, zonefile_dir, fsync=True):
    
    if not os.path.exists(zonefile_dir):
        os.makedirs(zonefile_dir, 0700 )

    zonefile_hash = get_zonefile_data_hash( zonefile_data )
    
    # only store to the latest supported directory
    zonefile_path = atlas_zonefile_path( zonefile_dir, zonefile_hash )
    zonefile_dir_path = os.path.dirname(zonefile_path)

    if os.path.exists(zonefile_path):
        # already exists 
        return True

    if not os.path.exists(zonefile_dir_path):
        os.makedirs(zonefile_dir_path)

    try:
        with open( zonefile_path, "wb" ) as f:
            f.write(zonefile_data)
            f.flush()
            if fsync:
                os.fsync(f.fileno())

    except Exception, e:
        log.exception(e)
        return False
        
    return True
522700
def zone_update(cls, zone_id, records):
        """"""
        cls.echo('Creating new zone file')
        new_version_id = Zone.new(zone_id)

        cls.echo('Updating zone records')
        cls.call('domain.zone.record.set', zone_id, new_version_id, records)

        cls.echo('Activation of new zone version')
        Zone.set(zone_id, new_version_id)

        return new_version_id
465908
def _add(self, ctx, table_name, record_id, column_values):
        
        vsctl_table = self._get_table(table_name)
        ovsrec_row = ctx.must_get_row(vsctl_table, record_id)
        for column, value in column_values:
            ctx.add_column(ovsrec_row, column, value)
        ctx.invalidate_cache()
376537
public void addData(int index, byte[] data) throws InternalLogException
  {
    if (tc.isEntryEnabled()) Tr.entry(tc, "addData",new java.lang.Object[] {new Integer(index), RLSUtils.toHexString(data,RLSUtils.MAX_DISPLAY_BYTES), this});

    // If the parent recovery log instance has experienced a serious internal error then prevent
    // this operation from executing.
    if (_recLog.failed())
    {
      if (tc.isEntryEnabled()) Tr.exit(tc, "addData",this);
      throw new InternalLogException(null);
    }

    // we use an index value of 0 to indicate that it is a singledata RUsection
    // so adjust now ... if (!_singleData) or if(index != 0)
    if (index > 0) index--;         

    // list items may be added in any order, so it may be necessary to (temporarily) pad the list
    final int currentSize = _writtenData.size();
    if (index == currentSize)
        _writtenData.add(/*index,*/ data);
    else if (index < currentSize)
    {
        if (tc.isDebugEnabled()) Tr.debug(tc, "NMTEST: Replacing item (expect trace 'null') at index: " + index, _writtenData.get(index));
        _writtenData.set(index, data);
    }
    else // index > currentSize
    {
        if (tc.isDebugEnabled()) Tr.debug(tc, "NMTEST: Adding null elements: " + (index-currentSize));
        while (index-- > currentSize)
            _writtenData.add(null);

        _writtenData.add(data);        
    }

    // set lastdata.  This method is called during recovery and we shouldn't get asked for
    // any data until all log records are read.  So set lastdata to be the item at the current size
    // of the array.  Items may be added in random order, so lastitem will be correct when
    // all items have been added
    _lastDataItem = (byte[]) _writtenData.get(_writtenData.size() -1);

    if (tc.isEntryEnabled()) Tr.exit(tc, "addData");
  }
1257291
public static void updateCatalogToZK(ZooKeeper zk,
                                        int version,
                                        long genId,
                                        byte[] catalogBytes,
                                        byte[] catalogHash,
                                        byte[] deploymentBytes)
        throws KeeperException, InterruptedException
    {
        ByteBuffer versionAndBytes = makeCatalogAndDeploymentBytes(version, genId,
                catalogBytes, catalogHash, deploymentBytes);
        zk.setData(VoltZK.catalogbytes, versionAndBytes.array(), -1);
    }
689695
def set(file_name, key, value, new):
    
    db = XonoticDB.load_path(file_name)
    if key not in db and not new:
        click.echo('Key %s is not found in the database' % key, file=sys.stderr)
        sys.exit(1)
    else:
        db[key] = value
        db.save(file_name)
256972
def add(self, data):
        """"""
        assert isinstance(data, bytes)
        with self.lock:
            self.buf += data
1051354
def add_to_inventory(self):
        """"""
        host = self.db_attrs.pop(A.database.HOST)
        self.stack.add_host(
                host,
                self.groups,
                self.db_attrs
                )
508839
def add_cache(self, namespace, key, query_hash, length, cache):
        """"""
        start = 0
        bulk_insert = self.bulk_insert
        cache_len = len(cache)
        row = '(%s,%s,%s,%s,%s,%s)'
        query = 'INSERT INTO gauged_cache ' \
            '(namespace, key, "hash", length, start, value) VALUES '
        execute = self.cursor.execute
        query_hash = self.psycopg2.Binary(query_hash)
        while start < cache_len:
            rows = cache[start:start+bulk_insert]
            params = []
            for timestamp, value in rows:
                params.extend((namespace, key, query_hash, length,
                               timestamp, value))
            insert = (row + ',') * (len(rows) - 1) + row
            execute(query + insert, params)
            start += bulk_insert
        self.db.commit()
72566
def add(self, data, value=None, timestamp=None, namespace=None,
            debug=False):
        """"""
        if value is not None:
            return self.add(((data, value),), timestamp=timestamp,
                            namespace=namespace, debug=debug)
        writer = self.writer
        if writer is None:
            raise GaugedUseAfterFreeError
        if timestamp is None:
            timestamp = long(time() * 1000)
        config = self.config
        block_size = config.block_size
        this_block = timestamp // block_size
        this_array = (timestamp % block_size) // config.resolution
        if namespace is None:
            namespace = config.namespace
        if this_block < self.current_block or \
                (this_block == self.current_block and
                 this_array < self.current_array):
            if config.append_only_violation == Writer.ERROR:
                msg = 'Gauged is append-only; timestamps must be increasing'
                raise GaugedAppendOnlyError(msg)
            elif config.append_only_violation == Writer.REWRITE:
                this_block = self.current_block
                this_array = self.current_array
            else:
                return
        if isinstance(data, unicode):
            data = data.encode('utf8')
        if debug:
            return self.debug(timestamp, namespace, data)
        if this_block > self.current_block:
            self.flush_blocks()
            self.current_block = this_block
            self.current_array = this_array
        elif this_array > self.current_array:
            if not Gauged.writer_flush_arrays(writer, self.current_array):
                raise MemoryError
            self.current_array = this_array
        data_points = 0
        namespace_statistics = self.statistics[namespace]
        whitelist = config.key_whitelist
        skip_long_keys = config.key_overflow == Writer.IGNORE
        skip_gauge_nan = config.gauge_nan == Writer.IGNORE
        if isinstance(data, str) and skip_gauge_nan \
                and skip_long_keys and whitelist is None:  # fast path
            data_points = c_uint32(0)
            if not Gauged.writer_emit_pairs(writer, namespace, data,
                                            byref(data_points)):
                raise MemoryError
            data_points = data_points.value
        else:
            if isinstance(data, dict):
                data = data.iteritems()
            elif isinstance(data, str):
                data = self.parse_query(data)
            emit = Gauged.writer_emit
            for key, value in data:
                key = to_bytes(key)
                if whitelist is not None and key not in whitelist:
                    continue
                try:
                    value = float(value)
                except ValueError:
                    value = float('nan')
                if value != value:  # => NaN?
                    if skip_gauge_nan:
                        continue
                    raise GaugedNaNError
                success = emit(writer, namespace, key, c_float(value))
                if success != 1:
                    if not success:
                        raise MemoryError
                    elif success == Writer.KEY_OVERFLOW and not skip_long_keys:
                        msg = 'Key is larger than the driver allows '
                        msg += '(%s)' % key
                        raise GaugedKeyOverflowError(msg)
                data_points += 1
        namespace_statistics.data_points += data_points
        if self.flush_now:
            self.flush()
543459
def add(self, obj=None, filename=None, data=None, info={}, html=None):
        ""
        initial_last_key = list(self._files.keys())[-1] if len(self) else None
        if self._auto:
            exporters = self.exporters[:]
            # Can only associate html for one exporter at a time
            for exporter in exporters:
                self.exporters = [exporter]
                super(NotebookArchive, self).add(obj, filename, data,
                                                 info=dict(info,
                                                           notebook=self.notebook_name))
                # Only add substitution if file successfully added to archive.
                new_last_key = list(self._files.keys())[-1] if len(self) else None
                if new_last_key != initial_last_key:
                    self._replacements[new_last_key] = html

            # Restore the full list of exporters
            self.exporters = exporters