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


Python Text.readString方法代码示例

本文整理汇总了Python中Text.Text.readString方法的典型用法代码示例。如果您正苦于以下问题:Python Text.readString方法的具体用法?Python Text.readString怎么用?Python Text.readString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Text.Text的用法示例。


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

示例1: readFields

# 需要导入模块: from Text import Text [as 别名]
# 或者: from Text.Text import readString [as 别名]
    def readFields(self, data_input):
        count = data_input.readInt()
        if count < 0:
            raise IOError("Invalid size: %d for file metadata object" % count)

        for i in xrange(count):
            key = Text.readString(data_input)
            value = Text.readString(data_input)
            self._meta[key] = value
开发者ID:KimYoungDeok,项目名称:Hadoop,代码行数:11,代码来源:SequenceFile.py

示例2: _initialize

# 需要导入模块: from Text import Text [as 别名]
# 或者: from Text.Text import readString [as 别名]
    def _initialize(self, path, start, length):
        self._stream = self.getStream(path)

        if length == 0:
            self._end = self._stream.getPos() + self._stream.length()
        else:
            self._end = self._stream.getPos() + length

        # Parse Header
        version_block = self._stream.read(len(VERSION))

        self._version = version_block[len(VERSION_PREFIX)]
        if not self._version.startswith(VERSION_PREFIX):
            raise VersionPrefixException(VERSION_PREFIX,
                                         self._version[0:len(VERSION_PREFIX)])

        if self._version > VERSION[len(VERSION_PREFIX)]:
            raise VersionMismatchException(VERSION[len(VERSION_PREFIX)],
                                           self._version)

        if self._version < BLOCK_COMPRESS_VERSION:
            # Same as below, but with UTF8 Deprecated Class
            raise NotImplementedError
        else:
            self._key_class_name = Text.readString(self._stream)
            self._value_class_name = Text.readString(self._stream)

        if ord(self._version) > 2:
            self._decompress = self._stream.readBoolean()
        else:
            self._decompress = False

        if self._version >= BLOCK_COMPRESS_VERSION:
            self._block_compressed = self._stream.readBoolean()
        else:
            self._block_compressed = False

        # setup compression codec
        if self._decompress:
            if self._version >= CUSTOM_COMPRESS_VERSION:
                codec_class = Text.readString(self._stream)
                self._codec = CodecPool().getDecompressor(codec_class)
            else:
                self._codec = CodecPool().getDecompressor()

        self._metadata = Metadata()
        if self._version >= VERSION_WITH_METADATA:
            self._metadata.readFields(self._stream)

        if self._version > 1:
            self._sync = self._stream.read(SYNC_HASH_SIZE)
            self._header_end = self._stream.getPos()
开发者ID:KimYoungDeok,项目名称:Hadoop,代码行数:54,代码来源:SequenceFile.py


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