kawasin73 / bitset Goto Github PK
View Code? Open in Web Editor NEWBi-Endian Bit Vector (Array) in Golang
License: MIT License
Bi-Endian Bit Vector (Array) in Golang
License: MIT License
参考実装となる https://github.com/willf/bitset では、ビットベクトル作成時に全体のサイズを指定するものの、サイズを超過する値が設定されたときにスライス([]uint64
)を自動拡張する。
bitset での自動拡張を行うかどうかを検討する
gometalinter
の gosec
で下記の警告が発生する
bitvec.go:50::warning: Use of unsafe calls should be audited,LOW,HIGH (gosec)
bitvec.go:55::warning: Use of unsafe calls should be audited,LOW,HIGH (gosec)
[]byte
から []uint64
へのキャストのために unsafe
パッケージを使用している。
この警告をどのように無視するかを調査する
このパッケージでは、設定された状態(マシンのバイトオーダーと操作時に設定されているバイトオーダーが同じか異なるか)によってビットベクトルの操作を2種類から選択して切り替える。
この2種類の操作の抽象化をインターフェイスを用いて行うか、struct のフィールドの関数ポインターを差し替えることによって行うかを以下の観点から調査する。
Little Endian と Big Endian のエミュレート #5 を github.com/multiarch/qemu-user-static からダウンロードした qemu-ppc64-static
バイナリを利用することによって行った。
ただし、このリポジトリ自体の信頼性の問題もあるため、パッケージマネージャーによってダウンロードする方法を検討する。
zcbit はバイトオーダーの異なるマシン間で作成されたビットベクトルのファイルを利用可能にするために作成されている。
PC で広く利用されている Intel CPU は主に Little Endian であるが、Big Endian のマシンでも正常に動作することをテストする必要がある。
Little Endian と Big Endian のどちらでもテストを実行する手法を調査する。
[]byte
から []uint64
へ unsafe
パッケージを使って変換している。 #7
その後、[]byte
の参照を消すと、[]uint64
の参照が残っているにも関わらず []byte
が参照している先のメモリ列 GC されてしまい、別の処理によって値が上書きされてしまうバグがあった。
現在は、BitSet
に orig []byte
というフィールドを持たせ、 []byte
の参照を残すことで GC を抑制している。
バイト列の拡張 #6 に対応するにあたり、orig
を残すと古いメモリ列が GC されなくなる課題がある。
(orig
を更新することで解決可能)
[]uint64
のスライスがうまく GC の考慮に含まれるようにするためにはどうすればいいかを調査する。
[]byte
から []uint64
への変換方法を調査する
Little Endian の値を Big Endian に変換する、またはその逆の変換を行う実装の高速な実装を調査する。
動いているマシンのバイトオーダーを Go 言語で検出する方法を調査する。
bitset では、[]byte
を []uint64
に変換する。もし、バイト列の長さが 8 の倍数でない場合にどのように対応するかを考察する
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.