2a437760c9344a20a5785f5b4706950c911534b6,conceptnet5/formats/sql.py,EdgeIndexReader,random,#EdgeIndexReader#,270

Before Change


        // will also contain byte 8D, and it turns out we have a lot of those.

        while True:
            try:
                curbyte = fileobj.read(1)
                while curbyte != b"\x8d":
                    byte_offset -= 1
                    fileobj.seek(byte_offset)
                    curbyte = fileobj.read(1)
                fileobj.seek(byte_offset)

                unpacker = Unpacker(fileobj, encoding=encoding)
                result = unpacker.unpack()
                if len(result) == 13 and "uri" in result:
                    return result
                else:
                    byte_offset -= 2
            except (ValueError, TypeError):
                byte_offset -= 2

After Change


            return fileobj

    def random(self):
        hashval = random.randrange(-2**31, 2**31)
        shard = hashval % self.nshards
        c = self.dbs[shard].cursor()
        offset = random.randrange(0, 100)
        rows = []
        while not rows:
            c.execute(
                "SELECT filenum, offset from text_index "
                "WHERE queryhash >= ? "
                "ORDER BY queryhash LIMIT 1 OFFSET ?",
                (hashval, offset)
            )
            rows = c.fetchall()

        filenum, offset = rows[0]
        return self.get_edge(filenum, offset)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 12

Instances


Project Name: commonsense/conceptnet5
Commit Name: 2a437760c9344a20a5785f5b4706950c911534b6
Time: 2015-04-08
Author: rob@luminoso.com
File Name: conceptnet5/formats/sql.py
Class Name: EdgeIndexReader
Method Name: random


Project Name: gboeing/osmnx
Commit Name: cc2c3376832df749fc386f31621eff0b9babc1ea
Time: 2018-05-03
Author: henrikki.tenkanen@helsinki.fi
File Name: osmnx/pois.py
Class Name:
Method Name: create_poi_gdf


Project Name: gboeing/osmnx
Commit Name: d66cfb74ac8c3b55f9728b57230387466e69e7d1
Time: 2017-12-25
Author: henrikki.tenkanen@helsinki.fi
File Name: osmnx/pois.py
Class Name:
Method Name: create_poi_gdf