Merge pull request #31571 from frreiss:issue-lmdb-endian
PiperOrigin-RevId: 264453617
This commit is contained in:
commit
520a0edb41
tensorflow
contrib/data/python/kernel_tests
core
python/kernel_tests
@ -20,6 +20,7 @@ from __future__ import print_function
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from tensorflow.contrib.data.python.ops import readers
|
||||
from tensorflow.python.data.kernel_tests import test_base
|
||||
@ -40,7 +41,10 @@ class LMDBDatasetTest(test_base.DatasetTestBase):
|
||||
def setUp(self):
|
||||
super(LMDBDatasetTest, self).setUp()
|
||||
# Copy database out because we need the path to be writable to use locks.
|
||||
path = os.path.join(prefix_path, "lmdb", "testdata", "data.mdb")
|
||||
# The on-disk format of an LMDB database is different on big-endian
|
||||
# machines, because LMDB is a memory-mapped database.
|
||||
db_file = "data.mdb" if sys.byteorder == "little" else "data_bigendian.mdb"
|
||||
path = os.path.join(prefix_path, "lmdb", "testdata", db_file)
|
||||
self.db_path = os.path.join(self.get_temp_dir(), "data.mdb")
|
||||
shutil.copy(path, self.db_path)
|
||||
|
||||
|
@ -5482,11 +5482,19 @@ filegroup(
|
||||
testonly = 1,
|
||||
srcs = [
|
||||
# A simple key-value store:
|
||||
# 0 : 'b'
|
||||
# 1 : 'b'
|
||||
# ...
|
||||
# 9 : 'b'
|
||||
# Which is then overwritten with:
|
||||
# 0 : 'a'
|
||||
# 1 : 'b'
|
||||
# ...
|
||||
# 9 : 'j'
|
||||
"lib/lmdb/testdata/data.mdb",
|
||||
# LMDB, being a memory-mapped database, uses a different file format on
|
||||
# big-endian systems.
|
||||
"lib/lmdb/testdata/data_bigendian.mdb",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
BIN
tensorflow/core/lib/lmdb/testdata/data_bigendian.mdb
vendored
Normal file
BIN
tensorflow/core/lib/lmdb/testdata/data_bigendian.mdb
vendored
Normal file
Binary file not shown.
@ -22,6 +22,7 @@ import collections
|
||||
import gzip
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import threading
|
||||
import zlib
|
||||
|
||||
@ -754,7 +755,10 @@ class LMDBReaderTest(test.TestCase):
|
||||
def setUp(self):
|
||||
super(LMDBReaderTest, self).setUp()
|
||||
# Copy database out because we need the path to be writable to use locks.
|
||||
path = os.path.join(prefix_path, "lmdb", "testdata", "data.mdb")
|
||||
# The on-disk format of an LMDB file is different on big-endian machines,
|
||||
# because LMDB is a memory-mapped database.
|
||||
db_file = "data.mdb" if sys.byteorder == "little" else "data_bigendian.mdb"
|
||||
path = os.path.join(prefix_path, "lmdb", "testdata", db_file)
|
||||
self.db_path = os.path.join(self.get_temp_dir(), "data.mdb")
|
||||
shutil.copy(path, self.db_path)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user