Пример #1
0
class Game(Model):
    home_team = Text(primary_key=True, required=True)
    away_team = Text(primary_key=True, required=True)
    date = Date(primary_key=True, clustering_order="ASC")
    home_win = Boolean(required=True)
    playoffs = Boolean(required=True)
    season = Text(required=True)

    home_players = Set(value_type=Integer)
    away_players = Set(value_type=Integer)
    # cassandra.cqlengine.columns.Set

    # home_rest = Integer()	# number of games past X days
    # away_rest = Integer()

    # home_success = Integer()	# recent record past X games
    # away_success = Integer()

    home_wins = Integer()
    home_losses = Integer()

    away_wins = Integer()
    away_losses = Integer()

    # rest for each team
    # recent success for each team
    # records for each team

    @staticmethod
    def get_model_string():
        return 'game'

    def validate(self):
        super(Game, self).validate()
Пример #2
0
class user(UserType):
    id = UUID(primary_key=True, default=uuid.uuid4, partition_key=True)
    gid = Integer(required=True, index=True)
    name = Text(required=True, index=True)
    friends_count = Integer()
    reviews_count = Integer()
    age = Integer(index=True)
    gender = Text(index=True)
    location = Text(index=True)
    small_user = Boolean(default=False, index=True)
    private = Boolean(default=False, index=True)
Пример #3
0
class Recommendation(Model):
    id = UUID(primary_key=True, default=uuid.uuid4, partition_key=True)
    user_gid = Integer(required=True, index=True)
    username = Text()
    user_image = Text()
    item_recommended = List(Integer)
    books_details_recommended = List(UserDefinedType(book))
    precision = Double(default=0.0, index=True)
    recall = Double(default=0.0, index=True)
    book_details_retrieved = Boolean(default=False, index=True)
    most_common_shelves = List(UserDefinedType(shelve), required=False)
    common_shelves_retrieved = Boolean(default=False, index=True)
Пример #4
0
class book(UserType):
    id = UUID(primary_key=True, default=uuid.uuid4, partition_key=True)
    gid = Integer(required=True, index=True)
    title = Text(required=True, index=True)
    isbn = Text(index=True)
    isbn13 = Text()
    publication_date = DateTime(index=True)
    description = Text()
    average_rating = Double(required=True, index=True)
    ratings_count = Integer(required=True)
    reviews_count = Integer()
    small_book = Boolean(
    )  # no shelves, review_count, description, smilar_book
    author = UserDefinedType(author, default=author())
    list_shelves = List(UserDefinedType(shelve))
    error_retrieving_shelves = Boolean(default=False)
Пример #5
0
class shelve(UserType):
    #id=UUID(primary_key=True, default=uuid.uuid4, partition_key=True)
    gid = Integer(index=True)
    shelve = Text(required=True, index=True)
    votes = Integer(index=True)
    count = Integer(index=True)
    best = Boolean(default=False)
Пример #6
0
def _str_to_column(type_str, key_type=None, value_type=None, column_def={}):
    '''
    Converts name of Cassandra types to driver class wrapper for
    that type.
    '''
    type_str = type_str.lower()

    if type_str == 'integer':
        return Integer(**column_def)
    elif type_str == 'text':
        return Text(**column_def)
    elif type_str == 'ascii':
        return Ascii(**column_def)
    elif type_str == 'bigint':
        return BigInt(**column_def)
    elif type_str == 'blob':
        return Blob(**column_def)
    elif type_str == 'bytes':
        return Bytes(**column_def)
    elif type_str == 'boolean':
        return Boolean(**column_def)
    elif type_str == 'counter':
        return Counter(**column_def)
    elif type_str == 'date':
        return Date(**column_def)
    elif type_str == 'datetime':
        return DateTime(**column_def)
    elif type_str == 'decimal':
        return Decimal(**column_def)
    elif type_str == 'double':
        return Double(**column_def)
    elif type_str == 'float':
        return Float(**column_def)
    elif type_str == 'list':
        _assert_type_exception(value_type, "list type requires value_type")
        return List(value_type=value_type, **column_def)
    elif type_str == 'map':
        _assert_type_exception(key_type, "list type requires key_type")
        _assert_type_exception(value_type, "list type requires value_type")
        return Map(key_type=key_type, value_type=value_type, **column_def)
    elif type_str == 'set':
        _assert_type_exception(value_type, "set type requires value_type")
        return Set(value_type=value_type, **column_def)
    elif type_str == 'smallint':
        return SmallInt(**column_def)
    elif type_str == 'time':
        return Time(**column_def)
    elif type_str == 'timeuuid':
        return TimeUUID(**column_def)
    elif type_str == 'timestamp':
        return TimeUUID(**column_def)
    elif type_str == 'tinyint':
        return TinyInt(**column_def)
    elif type_str == 'uuid':
        return UUID(**column_def)
    elif type_str == 'varint':
        return VarInt(**column_def)
    else:
        raise Exception('Type {} is not defined.'.format(type_str))
Пример #7
0
class Books(Model):
    id = UUID(primary_key=True, default=uuid.uuid4, partition_key=True)
    gid = Integer(primary_key=True, required=True, index=True)
    title = Text(required=True, index=True)
    isbn = Text()
    isbn13 = Text()
    publication_date = DateTime(index=True)
    description = Text()
    average_rating = Double(required=True, index=True)
    ratings_count = Integer(required=True)
    reviews_count = Integer()
    small_book = Boolean(
        default=True,
        index=True)  # no shelves, review_count, description, smilar_book
    author = UserDefinedType(author, default=author())
    #Specific to model
    reviews_retrieved = Boolean(default=False, required=False, index=True)
    shelves_retrieved = Boolean(default=False, required=False, index=True)
    #Lists
    list_shelves = List(UserDefinedType(shelve), required=False)
    list_reviews = List(UserDefinedType(review), required=False)
Пример #8
0
class PlayerGameLog(Model):
    name = Text(primary_key=True, required=True)
    team = Text(required=True)
    date = Date(primary_key=True, clustering_order="ASC")
    home = Boolean(required=True)
    opp = Text(required=True)
    win = Boolean(required=True)
    season = Text(required=True)
    season_type = Text(required=True)
    minutes = Integer()
    points = Integer()
    fgm = Integer()
    fga = Integer()
    fgp = Float()
    tm = Integer()  # 3's made
    ta = Integer()  # 3's attempted
    tp = Float()  # 3 percentage
    ftm = Integer()
    fta = Integer()
    ftp = Float()
    oreb = Integer()
    dreb = Integer()
    reb = Integer()
    ast = Integer()
    stl = Integer()
    blk = Integer()
    tov = Integer()
    pf = Integer()
    pm = Integer()

    @staticmethod
    def get_model_string():
        return 'player_game_log'

    def validate(self):
        super(PlayerGameLog, self).validate()
Пример #9
0
class Users(Model):
    id = UUID(primary_key=True, default=uuid.uuid4, partition_key=True)
    gid = Integer(required=True, index=True)
    name = Text(required=True, index=True)
    friends_count = Integer()
    reviews_count = Integer(index=True)
    age = Integer(index=True)
    gender = Text(index=True)
    location = Text(index=True)
    small_user = Boolean(default=False, index=True)
    private = Boolean(default=False, index=True)
    #specific to model
    friends_retrieved = Boolean(default=False, index=True)
    reviews_retrieved = Boolean(default=False, index=True)
    shelves_reviews_retrieved = Boolean(default=False, index=True)
    reviews_filtered = Boolean(default=False, index=True)
    test_set = Boolean(default=False, index=True)

    #Lists
    list_reviews = List(UserDefinedType(review))
    list_friends = List(UserDefinedType(user))
    short_list_reviews = List(UserDefinedType(review))
    most_common_shelves = List(UserDefinedType(shelve), required=False)
Пример #10
0
    class BoolDefaultValueTest(Model):

        test_id = Integer(primary_key=True)
        stuff = Boolean(default=True)
Пример #11
0
    class BoolValidationTest(Model):

        test_id = Integer(primary_key=True)
        bool_column = Boolean()
Пример #12
0
class textblob(UserType):
    instantiated = Boolean()
    tags = List(UserDefinedType(tb_tag))
    noun_phrases = List(Text)
    sentences = List(UserDefinedType(tb_sentence))