text:
 .. Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

 ..   http://www.apache.org/licenses/LICENSE-2.0

 .. Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.

Python API Reference
====================

.. _pythonapi:operators:

Operators
---------
Operators allow for generation of certain types of tasks that become nodes in
the DAG when instantiated. All operators derive from :class:`~airflow.models.BaseOperator` and
inherit many attributes and methods that way.

There are 3 main types of operators:

- Operators that performs an **action**, or tell another system to
  perform an action
- **Transfer** operators move data from one system to another
- **Sensors** are a certain type of operator that will keep running until a
  certain criterion is met. Examples include a specific file landing in HDFS or
  S3, a partition appearing in Hive, or a specific time of the day. Sensors
  are derived from :class:`~airflow.sensors.base_sensor_operator.BaseSensorOperator` and run a poke
  method at a specified :attr:`~airflow.sensors.base_sensor_operator.BaseSensorOperator.poke_interval` until it returns ``True``.

BaseOperator
''''''''''''
All operators are derived from :class:`~airflow.models.BaseOperator` and acquire much
functionality through inheritance. Since this is the core of the engine,
it's worth taking the time to understand the parameters of :class:`~airflow.models.BaseOperator`
to understand the primitive features that can be leveraged in your
DAGs.

BaseSensorOperator
''''''''''''''''''
All sensors are derived from :class:`~airflow.sensors.base_sensor_operator.BaseSensorOperator`. All sensors inherit
the :attr:`~airflow.sensors.base_sensor_operator.BaseSensorOperator.timeout` and :attr:`~airflow.sensors.base_sensor_operator.BaseSensorOperator.poke_interval` on top of the :class:`~airflow.models.BaseOperator`
attributes.

Operators packages
''''''''''''''''''
All operators are in the following packages:

.. toctree::
  :includehidden:
  :glob:
  :maxdepth: 1

  airflow/operators/index

  airflow/sensors/index

  airflow/providers/amazon/aws/operators/index

  airflow/providers/amazon/aws/sensors/index

  airflow/providers/apache/cassandra/sensors/index

  airflow/providers/apache/druid/operators/index

  airflow/providers/apache/hdfs/sensors/index

  airflow/providers/apache/hive/operators/index

  airflow/providers/apache/hive/sensors/index

  airflow/providers/apache/livy/operators/index

  airflow/providers/apache/livy/sensors/index

  airflow/providers/apache/pig/operators/index

  airflow/providers/apache/spark/operators/index

  airflow/providers/apache/sqoop/operators/index

  airflow/providers/celery/sensors/index

  airflow/providers/cncf/kubernetes/operators/index

  airflow/providers/cncf/kubernetes/sensors/index

  airflow/providers/databricks/operators/index

  airflow/providers/datadog/sensors/index

  airflow/providers/dingding/operators/index

  airflow/providers/discord/operators/index

  airflow/providers/docker/operators/index

  airflow/providers/email/operators/index

  airflow/providers/exasol/operators/index

  airflow/providers/ftp/sensors/index

  airflow/providers/google/ads/operators/index

  airflow/providers/google/cloud/operators/index

  airflow/providers/google/cloud/sensors/index

  airflow/providers/google/firebase/operators/index

  airflow/providers/google/marketing_platform/operators/index

  airflow/providers/google/marketing_platform/sensors/index

  airflow/providers/google/suite/operators/index

  airflow/providers/grpc/operators/index

  airflow/providers/http/operators/index

  airflow/providers/http/sensors/index

  airflow/providers/imap/sensors/index

  airflow/providers/jdbc/operators/index

  airflow/providers/jenkins/operators/index

  airflow/providers/jira/operators/index

  airflow/providers/jira/sensors/index

  airflow/providers/microsoft/azure/operators/index

  airflow/providers/microsoft/azure/sensors/index

  airflow/providers/microsoft/mssql/operators/index

  airflow/providers/microsoft/winrm/operators/index

  airflow/providers/mongo/sensors/index

  airflow/providers/mysql/operators/index

  airflow/providers/opsgenie/operators/index

  airflow/providers/oracle/operators/index

  airflow/providers/papermill/operators/index

  airflow/providers/postgres/operators/index

  airflow/providers/qubole/operators/index

  airflow/providers/qubole/sensors/index

  airflow/providers/redis/operators/index

  airflow/providers/redis/sensors/index

  airflow/providers/salesforce/operators/index

  airflow/providers/salesforce/sensors/index

  airflow/providers/segment/operators/index

  airflow/providers/sftp/operators/index

  airflow/providers/sftp/sensors/index

  airflow/providers/singularity/operators/index

  airflow/providers/slack/operators/index

  airflow/providers/snowflake/operators/index

  airflow/providers/sqlite/operators/index

  airflow/providers/ssh/operators/index

  airflow/providers/vertica/operators/index

  airflow/providers/yandex/operators/index

.. _pythonapi:hooks:

Hooks
-----
Hooks are interfaces to external platforms and databases, implementing a common
interface when possible and acting as building blocks for operators. All hooks
are derived from :class:`~airflow.hooks.base_hook.BaseHook`.

Hooks packages
''''''''''''''
All hooks are in the following packages:

.. toctree::
  :includehidden:
  :glob:
  :maxdepth: 1

  airflow/hooks/index

  airflow/providers/amazon/aws/hooks/index

  airflow/providers/apache/cassandra/hooks/index

  airflow/providers/apache/druid/hooks/index

  airflow/providers/apache/hdfs/hooks/index

  airflow/providers/apache/hive/hooks/index

  airflow/providers/apache/livy/hooks/index

  airflow/providers/apache/pig/hooks/index

  airflow/providers/apache/pinot/hooks/index

  airflow/providers/apache/spark/hooks/index

  airflow/providers/apache/sqoop/hooks/index

  airflow/providers/cloudant/hooks/index

  airflow/providers/cncf/kubernetes/hooks/index

  airflow/providers/databricks/hooks/index

  airflow/providers/datadog/hooks/index

  airflow/providers/discord/hooks/index

  airflow/providers/dingding/hooks/index

  airflow/providers/docker/hooks/index

  airflow/providers/elasticsearch/hooks/index

  airflow/providers/exasol/hooks/index

  airflow/providers/facebook/ads/hooks/index

  airflow/providers/ftp/hooks/index

  airflow/providers/google/ads/hooks/index

  airflow/providers/google/cloud/hooks/index

  airflow/providers/google/common/hooks/index

  airflow/providers/google/firebase/hooks/index

  airflow/providers/google/marketing_platform/hooks/index

  airflow/providers/google/suite/hooks/index

  airflow/providers/grpc/hooks/index

  airflow/providers/http/hooks/index

  airflow/providers/imap/hooks/index

  airflow/providers/jdbc/hooks/index

  airflow/providers/jenkins/hooks/index

  airflow/providers/jira/hooks/index

  airflow/providers/microsoft/azure/hooks/index

  airflow/providers/microsoft/mssql/hooks/index

  airflow/providers/microsoft/winrm/hooks/index

  airflow/providers/mongo/hooks/index

  airflow/providers/mysql/hooks/index

  airflow/providers/odbc/hooks/index

  airflow/providers/openfaas/hooks/index

  airflow/providers/opsgenie/hooks/index

  airflow/providers/oracle/hooks/index

  airflow/providers/pagerduty/hooks/index

  airflow/providers/postgres/hooks/index

  airflow/providers/presto/hooks/index

  airflow/providers/qubole/hooks/index

  airflow/providers/redis/hooks/index

  airflow/providers/salesforce/hooks/index

  airflow/providers/samba/hooks/index

  airflow/providers/segment/hooks/index

  airflow/providers/sftp/hooks/index

  airflow/providers/slack/hooks/index

  airflow/providers/snowflake/hooks/index

  airflow/providers/sqlite/hooks/index

  airflow/providers/ssh/hooks/index

  airflow/providers/vertica/hooks/index

  airflow/providers/zendesk/hooks/index

  airflow/providers/yandex/hooks/index

Executors
---------
Executors are the mechanism by which task instances get run. All executors are
derived from :class:`~airflow.executors.base_executor.BaseExecutor`.

Executors packages
''''''''''''''''''
All executors are in the following packages:

.. toctree::
  :includehidden:
  :glob:
  :maxdepth: 1

  airflow/executors/index

Models
------
Models are built on top of the SQLAlchemy ORM Base class, and instances are
persisted in the database.

.. toctree::
  :includehidden:
  :glob:
  :maxdepth: 1

  airflow/models/index

.. _pythonapi:exceptions:

Exceptions
----------

.. toctree::
  :includehidden:
  :glob:
  :maxdepth: 1

  airflow/exceptions/index

Secrets Backends
----------------
Airflow relies on secrets backends to retrieve :class:`~airflow.models.connection.Connection` objects.
All secrets backends derive from :class:`~airflow.secrets.BaseSecretsBackend`.

.. toctree::
  :includehidden:
  :glob:
  :maxdepth: 1

  airflow/secrets/index

  airflow/providers/amazon/aws/secrets/index
  airflow/providers/hashicorp/secrets/index
  airflow/providers/google/cloud/secrets/index


text:
using Newtonsoft.Json;

namespace TagCache.Redis.Json.Net
{
    public class CacheConfiguration : TagCache.Redis.CacheConfiguration
    {
        public CacheConfiguration(RedisConnectionManager connectionManager)
            : base(connectionManager)
        {
            this.Serializer = new JsonSerializationProvider();
        }

        public CacheConfiguration(RedisConnectionManager connectionManager, JsonSerializerSettings settings)
            : base(connectionManager)
        {
            this.Serializer = new JsonSerializationProvider(settings);
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
var fs = require('fs');
var path = require('path');

function getStamp(dir, name, target) {
  return path.join(dir, name, target, 'timestamp');
}

var counter = 0;
var configCache = {};

function cacheConfig(config) {
  ++counter;
  configCache[counter] = config;
  return counter;
}

function pluckConfig(id) {
  if (!configCache.hasOwnProperty(id)) {
    throw new Error('Failed to find id in cache');
  }
  var config = configCache[id];
  delete configCache[id];
  return config;
}

function createTask(grunt, any) {
  return function(name, target) {
    var tasks = [];
    var prefix = this.name;
    if (!target) {
      Object.keys(grunt.config(name)).forEach(function(target) {
        if (!/^_|^options$/.test(target)) {
          tasks.push(prefix + ':' + name + ':' + target);
        }
      });
      return grunt.task.run(tasks);
    }
    var args = Array.prototype.slice.call(arguments, 2).join(':');
    var options = this.options({
      timestamps: path.join(__dirname, '..', '.cache')
    });
    var config = grunt.config.get([name, target]);
    var id = cacheConfig(config);
    config = grunt.util._.clone(config);

    /**
     * Special handling for watch task.  This is a multitask that expects
     * the `files` config to be a string or array of string source paths.
     */
    var srcFiles = true;
    if (typeof config.files === 'string') {
      config.src = [config.files];
      delete config.files;
      srcFiles = false;
    } else if (Array.isArray(config.files) &&
        typeof config.files[0] === 'string') {
      config.src = config.files;
      delete config.files;
      srcFiles = false;
    }

    var files = grunt.task.normalizeMultiTaskFiles(config, target);

    var newerFiles;
    var stamp = getStamp(options.timestamps, name, target);
    var repeat = grunt.file.exists(stamp);
    var modified = false;

    if (repeat) {
      // look for files that have been modified since last run
      var previous = fs.statSync(stamp).mtime;
      newerFiles = files.map(function(obj) {
        var time;
        /**
         * It is possible that there is a dest file that has been created
         * more recently than the last successful run.  This would happen if
         * a target with multiple dest files failed before all dest files were
         * created.  In this case, we don't need to re-run src files that map
         * to dest files that were already created.
         */
        var existsDest = obj.dest && grunt.file.exists(obj.dest);
        if (existsDest) {
          time = Math.max(fs.statSync(obj.dest).mtime, previous);
        } else {
          if (obj.dest) {
            // The dest file may have been removed.  Run with all src files.
            time = 0;
          } else {
            time = previous;
          }
        }
        var src = obj.src.filter(function(filepath) {
          var newer = fs.statSync(filepath).mtime > time;
          if (newer) {
            modified = true;
          }
          return newer;
        });

        if (!existsDest && prefix === 'any-newer') {
          modified = true;
        }
        return {src: src, dest: obj.dest};
      }).filter(function(obj) {
        return obj.src && obj.src.length > 0;
      });
    }

    /**
     * If we started out with only src files in the files config, transform
     * the newerFiles array into an array of source files.
     */
    if (!srcFiles) {
      newerFiles = newerFiles.map(function(obj) {
        return obj.src;
      });
    }

    /**
     * Cases:
     *
     * 1) First run, process all.
     * 2) Repeat run, nothing modified, process none.
     * 3) Repeat run, something modified, any false, process modified.
     * 4) Repeat run, something modified, any true, process all.
     */

    var qualified = name + ':' + target;
    if (repeat && !modified) {
      // case 2
      grunt.log.writeln('No newer files to process.');
    } else {
      if (repeat && modified && !any) {
        // case 3
        config.files = newerFiles;
        delete config.src;
        delete config.dest;
        grunt.config.set([name, target], config);
      }
      // case 1, 3 or 4
      tasks = [
        qualified + (args ? ':' + args : ''),
        'newer-timestamp:' + qualified + ':' + options.timestamps
      ];
      // if we modified the config (case 3), reset it to the original after
      if (repeat && modified && !any) {
        tasks.push('newer-reconfigure:' + qualified + ':' + id);
      }
      grunt.task.run(tasks);
    }
  };
}

/** @param {Object} grunt Grunt. */
module.exports = function(grunt) {

  grunt.registerTask(
      'newer', 'Run a task with only those source files that have been ' +
      'modified since the last successful run.', createTask(grunt));

  grunt.registerTask(
      'any-newer', 'Run a task with all source files if any have been ' +
      'modified since the last successful run.', createTask(grunt, true));

  grunt.registerTask(
      'newer-timestamp', 'Internal task.', function(name, target, dir) {
        // if dir includes a ':', grunt will split it among multiple args
        dir = Array.prototype.slice.call(arguments, 2).join(':');
        grunt.file.write(getStamp(dir, name, target), '');
      });

  grunt.registerTask(
      'newer-reconfigure', 'Internal task.', function(name, target, id) {
        grunt.config.set([name, target], pluckConfig(id));
      });

};


text:
#ifndef RTABMAP_FLANN_OBJECT_FACTORY_H_
#define RTABMAP_FLANN_OBJECT_FACTORY_H_

#include <map>

namespace rtflann
{

class CreatorNotFound
{
};

template<typename BaseClass,
         typename UniqueIdType,
         typename ObjectCreator = BaseClass* (*)()>
class ObjectFactory
{
    typedef ObjectFactory<BaseClass,UniqueIdType,ObjectCreator> ThisClass;
    typedef std::map<UniqueIdType, ObjectCreator> ObjectRegistry;

    // singleton class, private constructor
    ObjectFactory() {}

public:

    bool subscribe(UniqueIdType id, ObjectCreator creator)
    {
        if (object_registry.find(id) != object_registry.end()) return false;

        object_registry[id] = creator;
        return true;
    }

    bool unregister(UniqueIdType id)
    {
        return object_registry.erase(id) == 1;
    }

    ObjectCreator create(UniqueIdType id)
    {
        typename ObjectRegistry::const_iterator iter = object_registry.find(id);

        if (iter == object_registry.end()) {
            throw CreatorNotFound();
        }

        return iter->second;
    }

    static ThisClass& instance()
    {
        static ThisClass the_factory;
        return the_factory;
    }
private:
    ObjectRegistry object_registry;
};

}

#endif /* FLANN_OBJECT_FACTORY_H_ */