当前位置: 首页>>代码示例>>Python>>正文


Python wtdataset.SimpleDataSet类代码示例

本文整理汇总了Python中wtdataset.SimpleDataSet的典型用法代码示例。如果您正苦于以下问题:Python SimpleDataSet类的具体用法?Python SimpleDataSet怎么用?Python SimpleDataSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SimpleDataSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_truncate_cursor_order

    def test_truncate_cursor_order(self):
        uri = self.type + self.name

        # A simple, one-file file or table object.
        ds = SimpleDataSet(self, uri, 100, key_format=self.keyfmt)
        ds.populate()
        c1 = self.session.open_cursor(uri, None)
        c1.set_key(ds.key(1000))
        c2 = self.session.open_cursor(uri, None)
        c2.set_key(ds.key(2000))
        self.session.truncate(None, c1, c2, None)
        self.assertEqual(c1.close(), 0)
        self.assertEqual(c2.close(), 0)
        self.session.drop(uri)

        if self.type == "table:":
            ds = ComplexDataSet(self, uri, 100, key_format=self.keyfmt)
            ds.populate()
            c1 = self.session.open_cursor(uri, None)
            c1.set_key(ds.key(1000))
            c2 = self.session.open_cursor(uri, None)
            c2.set_key(ds.key(2000))
            self.session.truncate(None, c1, c2, None)
            self.assertEqual(c1.close(), 0)
            self.assertEqual(c2.close(), 0)
            self.session.drop(uri)
开发者ID:mongodb,项目名称:mongo,代码行数:26,代码来源:test_truncate01.py

示例2: test_drop

    def test_drop(self):
        uri = 'lsm:' + self.name
        ds = SimpleDataSet(self, uri, 100000)
        ds.populate()
        self.reopen_conn()

        self.session.drop(uri, None)
开发者ID:Machyne,项目名称:mongo,代码行数:7,代码来源:test_drop02.py

示例3: test_insert_over_delete_replace

    def test_insert_over_delete_replace(self):
        msg = '/WT_CACHE_FULL.*/'
        ds = SimpleDataSet(self, self.uri, 10000000, key_format=self.keyfmt,
            value_format=self.valuefmt, config=self.table_config)
        self.assertRaisesHavingMessage(wiredtiger.WiredTigerError,
            ds.populate, msg)

        cursor = self.session.open_cursor(self.uri, None)
        cursor.prev()
        last_key = int(cursor.get_key())

        # Now that the database contains as much data as will fit into
        # the configured cache, verify removes succeed.
        cursor = self.session.open_cursor(self.uri, None)
        for i in range(1, last_key / 4, 1):
            cursor.set_key(ds.key(i))
            cursor.remove()

        cursor.reset()
        # Spin inserting to give eviction a chance to reclaim space
        inserted = False
        for i in range(1, 1000):
            try:
                cursor[ds.key(1)] = ds.value(1)
            except wiredtiger.WiredTigerError:
                cursor.reset()
                sleep(1)
                continue
            inserted = True
            break
        self.assertTrue(inserted)
开发者ID:ksuarz,项目名称:mongo,代码行数:31,代码来源:test_inmem01.py

示例4: test_basic

 def test_basic(self):
     ds = SimpleDataSet(self, self.uri, self.nentries,
         config=self.config, key_format=self.keyfmt)
     ds.populate()
     self.reopen_conn()
     c = self.session.open_cursor(self.uri, None)
     self.forward(c, ds, self.nentries, [])
     self.backward(c, ds, self.nentries, [])
开发者ID:mongodb,项目名称:mongo,代码行数:8,代码来源:test_cursor_pin.py

示例5: test_modify_smoke_single

    def test_modify_smoke_single(self):
        if self.skip():
            return

        ds = SimpleDataSet(self,
            self.uri, 100, key_format=self.keyfmt, value_format='u')
        ds.populate()
        self.modify_load(ds, True)
开发者ID:DINKIN,项目名称:mongo,代码行数:8,代码来源:test_cursor12.py

示例6: test_checkpoint_target

    def test_checkpoint_target(self):
        # Create 3 objects, change one record to an easily recognizable string.
        uri = self.uri + '1'
        ds1 = SimpleDataSet(self, uri, 100, key_format=self.fmt)
        ds1.populate()
        self.update(uri, ds1, 'ORIGINAL')

        uri = self.uri + '2'
        ds2 = SimpleDataSet(self, uri, 100, key_format=self.fmt)
        ds2.populate()
        self.update(uri, ds2, 'ORIGINAL')

        uri = self.uri + '3'
        ds3 = SimpleDataSet(self, uri, 100, key_format=self.fmt)
        ds3.populate()
        self.update(uri, ds3, 'ORIGINAL')

        # Checkpoint all three objects.
        self.session.checkpoint("name=checkpoint-1")

        # Update all 3 objects, then checkpoint two of the objects with the
        # same checkpoint name.
        self.update(self.uri + '1', ds1, 'UPDATE')
        self.update(self.uri + '2', ds2, 'UPDATE')
        self.update(self.uri + '3', ds3, 'UPDATE')
        target = 'target=("' + self.uri + '1"' + ',"' + self.uri + '2")'
        self.session.checkpoint("name=checkpoint-1," + target)

        # Confirm the checkpoint has the old value in objects that weren't
        # checkpointed, and the new value in objects that were checkpointed.
        self.check(self.uri + '1', ds1, 'UPDATE')
        self.check(self.uri + '2', ds2, 'UPDATE')
        self.check(self.uri + '3', ds3, 'ORIGINAL')
开发者ID:ajdavis,项目名称:mongo,代码行数:33,代码来源:test_checkpoint01.py

示例7: test_insert_over_delete

    def test_insert_over_delete(self):
        msg = '/WT_CACHE_FULL.*/'
        ds = SimpleDataSet(self, self.uri, 10000000, key_format=self.keyfmt,
            value_format=self.valuefmt, config=self.table_config)
        self.assertRaisesHavingMessage(wiredtiger.WiredTigerError,
            ds.populate, msg)

        # Now that the database contains as much data as will fit into
        # the configured cache, verify removes succeed.
        cursor = self.session.open_cursor(self.uri, None)
        for i in range(1, 100):
            cursor.set_key(ds.key(i))
            cursor.remove()
开发者ID:ksuarz,项目名称:mongo,代码行数:13,代码来源:test_inmem01.py

示例8: test_truncate_cursor_order

    def test_truncate_cursor_order(self):
        uri = self.type + self.name
        ds = SimpleDataSet(self, uri, 100, key_format=self.keyfmt)
        ds.populate()
        c1 = self.session.open_cursor(uri, None)
        c2 = self.session.open_cursor(uri, None)

        c1.set_key(ds.key(20))
        c2.set_key(ds.key(10))
        msg = "/the start cursor position is after the stop cursor position/"
        self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda: self.session.truncate(None, c1, c2, None), msg)
        c2.set_key(ds.key(20))
        self.session.truncate(None, c1, c2, None)
开发者ID:Machyne,项目名称:mongo,代码行数:13,代码来源:test_truncate01.py

示例9: test_truncate_cursor_notset

    def test_truncate_cursor_notset(self):
        uri = self.type + self.name
        msg = "/requires key be set/"

        ds = SimpleDataSet(self, uri, 100)
        ds.populate()

        c1 = self.session.open_cursor(uri, None)
        c2 = self.session.open_cursor(uri, None)
        c2.set_key(ds.key(10))
        self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda: self.session.truncate(None, c1, c2, None), msg)
        self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda: self.session.truncate(None, c2, c1, None), msg)
        c1.close()
        c2.close()
开发者ID:Machyne,项目名称:mongo,代码行数:14,代码来源:test_truncate01.py

示例10: test_search_empty

    def test_search_empty(self):
        # Create the object and open a cursor.
        ds = SimpleDataSet(self, self.uri, 0, key_format=self.key_format,
                           value_format=self.value_format)
        ds.create()
        cursor = self.session.open_cursor(self.uri, None)

        # Search for a record past the end of the table, which should fail.
        cursor.set_key(ds.key(100))
        self.assertEqual(cursor.search(), wiredtiger.WT_NOTFOUND)

        # Search-near for a record past the end of the table, which should fail.
        cursor.set_key(ds.key(100))
        self.assertEqual(cursor.search_near(), wiredtiger.WT_NOTFOUND)
开发者ID:DINKIN,项目名称:mongo,代码行数:14,代码来源:test_bug008.py

示例11: test_las

    def test_las(self):
        # Create a small table.
        uri = "table:test_las"
        nrows = 100
        ds = SimpleDataSet(self, uri, nrows, key_format="S")
        ds.populate()
        bigvalue = "aaaaa" * 100

        # Initially load huge data
        cursor = self.session.open_cursor(uri)
        for i in range(1, 10000):
            cursor.set_key(ds.key(nrows + i))
            cursor.set_value(bigvalue)
            self.assertEquals(cursor.insert(), 0)
        cursor.close()
        self.session.checkpoint()

        # Scenario: 1
        # Check to see LAS working with old snapshot
        bigvalue1 = "bbbbb" * 100
        self.session.snapshot("name=xxx")
        # Update the values in different session after snapshot
        self.large_updates(self.session, uri, bigvalue1, ds, nrows)
        # Check to see the value after recovery
        self.durable_check(bigvalue1, uri, ds, nrows)
        self.session.snapshot("drop=(all)")

        # Scenario: 2
        # Check to see LAS working with old reader
        bigvalue2 = "ccccc" * 100
        session2 = self.conn.open_session()
        session2.begin_transaction('isolation=snapshot')
        self.large_updates(self.session, uri, bigvalue2, ds, nrows)
        # Check to see the value after recovery
        self.durable_check(bigvalue2, uri, ds, nrows)
        session2.rollback_transaction()
        session2.close()

        # Scenario: 3
        # Check to see LAS working with old timestamp
        bigvalue3 = "ddddd" * 100
        self.conn.set_timestamp('stable_timestamp=' + timestamp_str(1))
        self.large_updates(self.session, uri, bigvalue3, ds, nrows, timestamp=True)
        # Check to see data can be see only till the stable_timestamp
        self.durable_check(bigvalue2, uri, ds, nrows)

        self.conn.set_timestamp('stable_timestamp=' + timestamp_str(i + 1))
        # Check to see latest data can be seen
        self.durable_check(bigvalue3, uri, ds, nrows)
开发者ID:bsamek,项目名称:wiredtiger,代码行数:49,代码来源:test_las.py

示例12: test_insert_over_capacity

    def test_insert_over_capacity(self):
        msg = '/WT_CACHE_FULL.*/'
        ds = SimpleDataSet(self, self.uri, 10000000, key_format=self.keyfmt,
            value_format=self.valuefmt, config=self.table_config)
        self.assertRaisesHavingMessage(wiredtiger.WiredTigerError,
            ds.populate, msg)

        # Figure out the last key we successfully inserted, and check all
        # previous inserts are still there.
        cursor = self.session.open_cursor(self.uri, None)
        cursor.prev()
        last_key = int(cursor.get_key())
        ds = SimpleDataSet(self, self.uri, last_key, key_format=self.keyfmt,
            value_format=self.valuefmt, config=self.table_config)
        ds.check()
开发者ID:ksuarz,项目名称:mongo,代码行数:15,代码来源:test_inmem01.py

示例13: test_reconfig_fail

    def test_reconfig_fail(self):
        uri = 'table:reconfig_fail'
        ds = SimpleDataSet(self, uri, 100, key_format='S')
        ds.populate()

        self.session.begin_transaction("isolation=snapshot")
        c = self.session.open_cursor(uri, None)
        c.set_key(ds.key(20))
        c.set_value("abcde")
        self.assertEquals(c.update(), 0)

        compat_str = 'compatibility=(release="3.0.0")'
        msg = '/system must be quiescent/'
        self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
            lambda:self.conn.reconfigure(compat_str), msg)
开发者ID:DINKIN,项目名称:mongo,代码行数:15,代码来源:test_compat01.py

示例14: test_checkpoint_cursor_update

 def test_checkpoint_cursor_update(self):
     ds = SimpleDataSet(self, self.uri, 100, key_format=self.fmt)
     ds.populate()
     self.session.checkpoint("name=ckpt")
     cursor = self.session.open_cursor(self.uri, None, "checkpoint=ckpt")
     cursor.set_key(ds.key(10))
     cursor.set_value("XXX")
     msg = "/Unsupported cursor/"
     self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
         lambda: cursor.insert(), msg)
     self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
         lambda: cursor.remove(), msg)
     self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
         lambda: cursor.update(), msg)
     cursor.close()
开发者ID:ajdavis,项目名称:mongo,代码行数:15,代码来源:test_checkpoint01.py

示例15: test_modify_delete

    def test_modify_delete(self):
        ds = SimpleDataSet(self,
            self.uri, 20, key_format=self.keyfmt, value_format='u')
        ds.populate()

        c = self.session.open_cursor(self.uri, None)
        c.set_key(ds.key(10))
        self.assertEquals(c.remove(), 0)

        mods = []
        mod = wiredtiger.Modify('ABCD', 3, 3)
        mods.append(mod)

        c.set_key(ds.key(10))
        self.assertEqual(c.modify(mods), wiredtiger.WT_NOTFOUND)
开发者ID:bsamek,项目名称:wiredtiger,代码行数:15,代码来源:test_cursor12.py


注:本文中的wtdataset.SimpleDataSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。