示例#1
0
class Metric(Model):
    metricId = columns.UUID(primary_key=True, default=uuid.uuid4)
    connectionErrors = columns.Integer()
    writeTimeouts = columns.Integer()
    readTimeouts = columns.Integer()
    unavailables = columns.Integer()
    otherErrors = columns.Integer()
    retries = columns.Integer()
    ignores = columns.Integer()
    knownHosts = columns.Integer()
    connectedTo = columns.Integer()
    openConnections = columns.Integer()
    reqCount = columns.Integer()
    reqMinLatency = columns.Double()
    reqMaxLatency = columns.Double()
    reqMeanLatency = columns.Double()
    reqStdev = columns.Double()
    reqMedian = columns.Double()
    req75percentile = columns.Double()
    req97percentile = columns.Double()
    req98percentile = columns.Double()
    req99percentile = columns.Double()
    req999percentile = columns.Double()
    dateCreated = columns.DateTime()

    __keyspace__ = 'gpmr'
class StockDataset(Model):
    __keyspace__    = 'spardata'
    __connection__  = 'cluster1'
    exchange        = columns.Text(primary_key=True, required=True)
    symbol          = columns.Text(primary_key=True, required=True)
    avg             = columns.Double(required=True)
    date            = columns.Date(primary_key=True, required=True)
    open            = columns.Double(required=True)
    close           = columns.Double(required=True)
    high            = columns.Double(required=True)
示例#3
0
class Predictions(Model):
    device = columns.Text(primary_key=True)
    timestamp_for_prediction = columns.Text(primary_key=True,
                                            clustering_order="ASC",
                                            db_field="timestamp")
    timestamp_created = columns.Text()

    parameter = columns.Text()
    value = columns.Double()
    prediction_error = columns.Double()
class WeatherDataset(Model):
    __keyspace__        = 'spardata'
    __connection__      = 'cluster1'
    year                = columns.Integer(primary_key=True, required=True)
    month               = columns.Integer(primary_key=True, required=True)
    date                = columns.Date(primary_key=True, required=True)
    station_location    = columns.Text(primary_key=True, required=True)
    tmin                = columns.Double(required=False, default=None)
    tmax                = columns.Double(required=False, default=None)
    tavg                = columns.Double(required=False, default=None)
    prcp                = columns.Boolean(required=False, default=False)
示例#5
0
class LegacyEmployeePayData(DjangoCassandraModel):
    client_id = columns.Text()
    emp_id = columns.Integer()
    unique_id = columns.UUID(primary_key=True, default=uuid.uuid4)
    pay_group = columns.Text()
    pay_period = columns.Integer()
    pay_date = columns.Integer()
    pay_component = columns.Text()
    hours = columns.Integer()
    amount = columns.Double()
    taxable = columns.Double()
    country_code = columns.Text()
示例#6
0
class NewEmployeePayData(DjangoCassandraModel):
    emp_id = columns.Integer(index=True)
    client_id = columns.Text(index=True)
    example_id = columns.UUID(primary_key=True, default=uuid.uuid4)
    pay_group = columns.Text()
    pay_period = columns.Integer()
    pay_date = columns.Integer()
    pay_component = columns.Text(index=True)
    hours = columns.Double()
    amount = columns.Double()
    taxable = columns.Double()
    country_code = columns.Text()
class StockWeather311(Model):
    __keyspace__        = 'spardata'
    __connection__      = 'cluster1'
    date                = columns.Date(primary_key=True, required=True)
    stock_deviation     = columns.Double(required=True)
    prcp                = columns.Boolean(required=True, default=False)
    all_complaints      = columns.Integer(required=False)
    noise_complaints    = columns.Integer(required=False)
    homeless_complaints = columns.Integer(required=False)
    tavg                = columns.Double(required=False, default=None)
    tmax                = columns.Double(required=False, default=None)
    tmin                = columns.Double(required=False, default=None)
class Shipment(Model):
    shipping_code = columns.UUID(primary_key=True, default=uuid4)
    created_at = columns.DateTime(primary_key=True,
                                  required=True,
                                  clustering_order="ASC",
                                  default=datetime.utcnow)

    inventory_code = columns.Text(primary_key=True,
                                  clustering_order="ASC",
                                  required=True)
    status = columns.Text(default=constants.K_STATUS_CREATED, required=True)

    # location
    start_name = columns.Text(required=True)
    start_lat = columns.Double(required=True)
    start_lng = columns.Double(required=True)

    destination_name = columns.Text(required=True)
    destination_lat = columns.Double(required=True)
    destination_lng = columns.Double(required=True)

    def set_as_otw(self):
        self.status = constants.K_STATUS_OTW

    def set_as_finished(self):
        self.status = constants.K_STATUS_FINISHED

    @property
    def is_finished(self):
        return self.status == constants.K_STATUS_FINISHED

    @property
    def is_new(self):
        return self.status == constants.K_STATUS_CREATED

    def to_dict(self):
        return {
            'shipping_code': str(self.shipping_code),
            'created_at': str(self.created_at),
            'inventory_code': self.inventory_code,
            'status': self.status,
            'is_finished': self.is_finished,
            'start_name': self.start_name,
            'start_lat': self.start_lat,
            'start_lng': self.start_lng,
            'destination_name': self.destination_name,
            'destination_lat': self.destination_lat,
            'destination_lng': self.destination_lng,
        }
示例#9
0
class CassSpectrum(Model):
    __table_name__ = "spectra"
    id = columns.UUID(primary_key=True, default=uuid.uuid4)
    spectrum_id = columns.Text(index=True)
    wavelengths = columns.List(columns.Double())
    intensities = columns.List(columns.Double())
    metadata = columns.Map(key_type=columns.Text, value_type=columns.Text)

    def to_dict(self):
        return {
            "id": self.spectrum_id,
            "wavelengths": self.intensities,
            "intensities": self.intensities,
            "metadata": self.metadata
        }
示例#10
0
class Weather(DjangoCassandraModel):
    id = columns.UUID(primary_key=True, default=uuid.uuid4)
    lon = columns.Double()
    lat = columns.Double()
    dt = columns.DateTime()
    temp = columns.Double()
    pressure = columns.Double()
    humidity = columns.Double()
    visibility = columns.Double()
    windSpeed = columns.Double()
    windDeg = columns.Double()
    clouds = columns.Double()
示例#11
0
class Alerta(DjangoCassandraModel):
    idAlerta = columns.Integer(primary_key=True)
    tipoAlerta = columns.Text(required=True)
    time = columns.Text(required=True)
    idMicro = columns.Integer(required=True)
    promedio = columns.Double(required=True)
    tipoEntidad = columns.Text(required=True)
示例#12
0
class tweet_bank(DjangoCassandraModel):
    tweetid = columns.Text(primary_key=True)
    pdt_sentiment = columns.Double()
    sentimentid = columns.Text()
    tweet = columns.Text()
    tweet_text = columns.Text()
    tweet_text_cleaned = columns.List(columns.Text)
示例#13
0
class users(Model):
    user_id = columns.UUID(primary_key=True, default=uuid.uuid4)
    username = columns.Text(required=True, index=True)
    password = columns.Text(required=True)
    public_key = columns.Text(required=True)
    logged_in = columns.Text(required=False, index=True)
    login_time = columns.Double(required=False)
    api_key = columns.Text(required=False)
class PlmnProcessedCord(Model):
    cord_id = columns.Text(primary_key=True)
    date = columns.DateTime(primary_key=True)
    kpi_basename = columns.Text(primary_key=True)
    acronym = columns.Text(primary_key=True)
    kpi_name = columns.Text(primary_key=True)
    kpi_version = columns.Text()
    value = columns.Double()
示例#15
0
class PredictionModel(Model):
    device = columns.Text(primary_key=True)
    timestamp_created = columns.Text(primary_key=True, clustering_order="ASC")
    average_error = columns.Double()
    lag_order = columns.Integer()
    # steps = columns.List(columns.Text)
    # conf_parameters = columns.Map(columns.Text, columns.Text)
    __table_name__ = "model"
示例#16
0
class ScalarDataFromRecord(Model):
    """Query table for finding a scalar-valued Record.data entry given record ID."""

    id = columns.Text(primary_key=True)
    name = columns.Text(primary_key=True)
    value = columns.Double(primary_key=True)
    units = columns.Text()
    tags = columns.Set(columns.Text())
class PlmnKeyNotFound(Model):
    kpi_basename = columns.Text(primary_key=True)
    date = columns.DateTime(primary_key=True)
    cord_id = columns.BigInt(primary_key=True)
    acronym = columns.Text(primary_key=True)
    kpi_name = columns.Text(primary_key=True)
    kpi_version = columns.Text()
    value = columns.Double()
示例#18
0
class RecordFromScalarData(Model):
    """Query table for finding records given scalar criteria."""

    name = columns.Text(primary_key=True)
    value = columns.Double(primary_key=True)
    id = columns.Text(primary_key=True)
    units = columns.Text()
    tags = columns.Set(columns.Text())
示例#19
0
class LocationLog(Model):
    # partition with the shipment
    shipping_code = columns.UUID(primary_key=True)
    created_at = columns.DateTime(primary_key=True,
                                  required=True,
                                  clustering_order="ASC",
                                  default=datetime.utcnow)
    # track movement
    lat = columns.Double(required=True)
    lng = columns.Double(required=True)

    def to_dict(self):
        return {
            'shipping_code': str(self.shipping_code),
            'created_at': str(self.created_at),
            'lat': self.lat,
            'lng': self.lng,
        }
示例#20
0
class Checkpoint(Model):
    # partition with the shipment
    shipping_code = columns.UUID(primary_key=True)
    created_at = columns.DateTime(primary_key=True,
                                  required=True,
                                  clustering_order="ASC",
                                  default=datetime.utcnow)

    location_name = columns.Text(primary_key=True, required=True)
    location_lat = columns.Double(required=True)
    location_lng = columns.Double(required=True)

    def to_dict(self):
        return {
            'shipping_code': str(self.shipping_code),
            'created_at': str(self.created_at),
            'location_name': self.location_name,
            'location_lat': self.location_lat,
            'location_lng': self.location_lng,
        }
示例#21
0
class ScalarListDataFromRecord(Model):
    """Query table for finding a scalar list-valued Record.data entry given record ID."""

    id = columns.Text(primary_key=True)
    name = columns.Text(primary_key=True)
    # CQLEngine support for frozen collections isn't part of their API.
    # Currently, _freeze_db_type() *is* the least hacky option.
    # pylint: disable=protected-access
    value = columns.List(columns.Double(), primary_key=True)
    value._freeze_db_type()
    units = columns.Text()
    tags = columns.Set(columns.Text())
示例#22
0
class Song(DjangoCassandraModel):
    __table_name__ = 'songs_by_user'

    class Meta:
        get_pk_field = 'uid'

    uid = columns.UUID(primary_key=True)
    created = columns.DateTime(primary_key=True, clustering_order="DESC")
    uri = columns.Text(primary_key=True)

    title = columns.Text()
    artists = columns.List(columns.Text())
    duration = columns.Double()
    album = columns.Text()
    isrc = columns.Text()
示例#23
0
class AllDatatypes(UserType):
    a = columns.Ascii()
    b = columns.BigInt()
    c = columns.Blob()
    d = columns.Boolean()
    e = columns.DateTime()
    f = columns.Decimal()
    g = columns.Double()
    h = columns.Float()
    i = columns.Inet()
    j = columns.Integer()
    k = columns.Text()
    l = columns.TimeUUID()
    m = columns.UUID()
    n = columns.VarInt()
示例#24
0
class PredictorNetwork(Model):
    """Cassandra Model that represents predictor neural network.

    Variables:
    ------------------
    id: UUID.

    configuration_id: Id of host aggregate.

    image: Name of workload image.

    category: Name of workload category.

    model: Neural network model in bytes.

    x_maxima: Maximal values of network input data.

    y_maxima: Maximal values of network output data."""

    image = columns.Text(primary_key=True)
    category = columns.Text(primary_key=True)
    model = columns.Blob()
    x_maxima = columns.Map(columns.Integer(), columns.Double())
    y_maxima = columns.Map(columns.Integer(), columns.Double())
示例#25
0
class Metrics(Model):
    """Cassandra model that's represents metric from SWAN.

    Variables:
    ------------------
    ns: Namespace of metric.

    ver: Collector plugin version.

    disk: Host name.

    time: Time when metric was collected.

    boolval: Boolean value of metric.

    doubleval: Double value of metric.

    strval: String value of metric.

    tags: Tags in <key,value>.

    valtype: Value type of metric."""

    ns = columns.Text(partition_key=True)
    ver = columns.Integer(partition_key=True)
    host = columns.Text(partition_key=True)
    time = columns.DateTime(partition_key=True)
    boolval = columns.Boolean()
    doubleval = columns.Double()
    strval = columns.Text()
    tags = columns.Map(columns.Text(), columns.Text())
    valtype = columns.Text()

    @staticmethod
    def get_by_experiment_id(experiment_id):
        """Return metrics from experiment.

        Keyword arguments:
        ------------------
        experiment_id : string
            Experiment id.

        Returns:
        --------
        host_aggregates: list of Metric objects."""

        return Metrics.objects().filter(
            tags__contains=experiment_id).allow_filtering().limit(None)
示例#26
0
 class AllDatatypesModel(Model):
     id = columns.Integer(primary_key=True)
     a = columns.Ascii()
     b = columns.BigInt()
     c = columns.Blob()
     d = columns.Boolean()
     e = columns.DateTime()
     f = columns.Decimal()
     g = columns.Double()
     h = columns.Float()
     i = columns.Inet()
     j = columns.Integer()
     k = columns.Text()
     l = columns.TimeUUID()
     m = columns.UUID()
     n = columns.VarInt()
示例#27
0
class Sample(Model):
    """Cassandra Model that represents collected samples for classification.

    Variables:
    ------------------
    id: UUID.

    instance_id: Id of instance.

    configuration_id: Id of host aggregate.

    image: Name of workload image.

    metrics: Collected metrics."""

    id = columns.UUID(primary_key=True)
    instance_id = columns.Text()
    configuration_id = columns.Text()
    metrics = columns.Map(columns.Text(), columns.Double())
示例#28
0
class RecordFromScalarListData(Model):
    """
    Query table for finding records given scalar list criteria.

    Each entry in a scalar list is given its own row in the database in this
    table (not in its partner table) to facilitate the specific case of
    "find Records where x contains (y, a value < y, etc.)" This is more efficient
    for querying, but does mean that the arrangement of list members, as well as
    any duplication within a list (rows overwrite) is lost. The partner table
    is in charge of maintaining this order.

    We store neither units nor tags since they're not required for this type of
    query. Those are more for 'find me everything tagged "output" in "record_1"'
    (tags) or simple retrieval (units), both of which use the partner table.
    """

    name = columns.Text(primary_key=True)
    value = columns.Double(primary_key=True)
    id = columns.Text(primary_key=True)
示例#29
0
class SensorData(Model):
    date = columns.Date(required = True, partition_key = True)
    time = columns.Time(required = True, primary_key = True)

    source_id = columns.Bytes(required = True)
    event = columns.Text(required = True)
    value_name = columns.Text(required = True)
    value = columns.Double(required = True)
    units = columns.Text(required = True)

    def validate(self):
        super(SensorData, self).validate()
        SensorData.validate_source_id(self.source_id)
        SensorData.validate_event(self.event)
        SensorData.validate_value_name(self.value_name)
        SensorData.validate_units(self.units)

    @staticmethod
    def validate_source_id(id):
        if len(source_id) != 12 or not mongo_adapter.is_valid_foreign_id(SENSORS_COLLECTION_NAME, source_id.hex()):
            raise ValidationError('not a valid source id')
        return id

    @staticmethod
    def validate_event(event):
        if event not in EVENTS:
            raise ValidationError('not a valid event')

    @staticmethod
    def validate_value_name(value_name):
        if value_name not in VALUE_TYPES:
            raise ValidationError('not a valid value type')

    @staticmethod
    def validate_units(units):
        if units not in VALUE_UNITS:
            raise ValidationError('not a valid value units')
示例#30
0
class Position(Model):
    date = columns.Date(required = True, partition_key = True)
    time = columns.Time(required = True, primary_key = True)

    x = columns.Double(required = True)
    y = columns.Double(required = True)
    z = columns.Double(required = True)

    speed = columns.Double(required = True)
    attack_angle = columns.Double(required = True)
    direction_angle = columns.Double(required = True)

    def validate(self):
        super(Position, self).validate()

        self.attack_angle = Position.validate_angle(self.attack_angle)
        self.direction_angle = Position.validate_angle(self.direction_angle)

    @staticmethod
    def validate_angle(angle):
        angle -= math.floor(angle / (2 * math.pi)) * 2 * math.pi
        return angle