本文整理汇总了Python中wtdataset.SimpleDataSet类的典型用法代码示例。如果您正苦于以下问题:Python SimpleDataSet类的具体用法?Python SimpleDataSet怎么用?Python SimpleDataSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleDataSet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_insert_over_allowed
def test_insert_over_allowed(self):
# Create a new table that is allowed to exceed the cache size, do this
# before filling the cache so that the create succeeds
self.session.create(self.uri + "_over", "ignore_in_memory_cache_size=true")
# Populate a table with enough data to fill the cache.
msg = "/WT_CACHE_FULL.*/"
ds = SimpleDataSet(self, self.uri, 10000000, config=self.table_config)
self.assertRaisesHavingMessage(wiredtiger.WiredTigerError, lambda: ds.populate(), msg)
# Add some content to the new table
cursor = self.session.open_cursor(self.uri + "_over", None)
for i in range(1, 1000):
cursor[str("%015d" % i)] = str(i) + ": abcdefghijklmnopqrstuvwxyz"
cursor.close()
开发者ID:Machyne,项目名称:mongo,代码行数:16,代码来源:test_inmem02.py
示例17: 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()
# Take a snapshot.
self.session.snapshot("name=xxx")
# Insert a large number of records, we'll hang if the lookaside table
# isn't doing its thing.
c = self.session.open_cursor(uri)
bigvalue = "abcde" * 100
for i in range(1, 1000000):
c.set_key(ds.key(nrows + i))
c.set_value(bigvalue)
self.assertEquals(c.insert(), 0)
开发者ID:DINKIN,项目名称:mongo,代码行数:18,代码来源:test_las.py
示例18: test_smoke
def test_smoke(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)
c.set_key(ds.key(100))
self.assertEqual(c.search(), 0)
self.assertEqual(c.get_value(), ds.value(100))
c.set_key(ds.key(101))
self.assertEqual(c.search(), 0)
self.assertEqual(c.get_value(), ds.value(101))
c.set_key(ds.key(9999))
self.assertEqual(c.search(), 0)
self.assertEqual(c.get_value(), ds.value(9999))
开发者ID:mongodb,项目名称:mongo,代码行数:15,代码来源:test_cursor_pin.py
示例19: test_cursor_random_reasonable_distribution
def test_cursor_random_reasonable_distribution(self):
uri = self.type
num_entries = self.records
if uri == 'table:random':
config = 'leaf_page_max=100MB'
else:
config = ''
# Set the leaf-page-max value, otherwise the page might split.
ds = SimpleDataSet(self, uri, num_entries, config=config)
ds.populate()
# Setup an array to track which keys are seen
visitedKeys = [0] * (num_entries + 1)
# Setup a counter to see when we find a sequential key
sequentialKeys = 0
cursor = self.session.open_cursor(uri, None, 'next_random=true')
lastKey = None
for i in range(0, num_entries):
self.assertEqual(cursor.next(), 0)
current = cursor.get_key()
current = int(current)
visitedKeys[current] = visitedKeys[current] + 1
if lastKey != None:
if current == (lastKey + 1):
sequentialKeys += 1
lastKey = current
differentKeys = sum(x > 0 for x in visitedKeys)
#print visitedKeys
#print differentKeys
'''
self.tty('differentKeys: ' + str(differentKeys) + ' of ' + \
str(num_entries) + ', ' + \
str((int)((differentKeys * 100) / num_entries)) + '%')
'''
# Can't test for non-sequential data when there is 1 item in the table
if num_entries > 1:
self.assertGreater(num_entries - 1, sequentialKeys,
'cursor is returning sequential data')
self.assertGreater(differentKeys, num_entries / 4,
'next_random random distribution not adequate')
开发者ID:ajdavis,项目名称:mongo,代码行数:43,代码来源:test_cursor_random02.py
示例20: test_modify_many
def test_modify_many(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))
orig = 'abcdefghijklmnopqrstuvwxyz'
c.set_value(orig)
self.assertEquals(c.update(), 0)
for i in range(0, 50000):
new = "".join([random.choice(string.digits) for i in xrange(5)])
orig = orig[:10] + new + orig[15:]
mods = []
mod = wiredtiger.Modify(new, 10, 5)
mods.append(mod)
self.assertEquals(c.modify(mods), 0)
c.set_key(ds.key(10))
self.assertEquals(c.search(), 0)
self.assertEquals(c.get_value(), orig)
开发者ID:bsamek,项目名称:wiredtiger,代码行数:21,代码来源:test_cursor12.py
注:本文中的wtdataset.SimpleDataSet类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论