-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
tech.v3.datatype.struct.html
54 lines (53 loc) · 16 KB
/
tech.v3.datatype.struct.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>tech.v3.datatype.struct documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="highlight/solarized-light.css" /><script type="text/javascript" src="highlight/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a> with <a href="https://github.com/xsc/codox-theme-rdash">RDash UI</a> theme</h2><h1><a href="index.html"><span class="project-title"><span class="project-name">dtype-next</span> <span class="project-version">8.042</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="buffered-image.html"><div class="inner"><span>Buffered Image Support</span></div></a></li><li class="depth-1 "><a href="cheatsheet.html"><div class="inner"><span>Cheatsheet</span></div></a></li><li class="depth-1 "><a href="datatype-to-dtype-next.html"><div class="inner"><span>Why dtype-next?</span></div></a></li><li class="depth-1 "><a href="dimensions-bytecode-gen.html"><div class="inner"><span>Dimensions and Bytecode Generation</span></div></a></li><li class="depth-1 "><a href="overview.html"><div class="inner"><span>Overview</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>tech</span></div></div></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>v3</span></div></div></li><li class="depth-3"><a href="tech.v3.datatype.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>datatype</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.argops.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>argops</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.bitmap.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>bitmap</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.convolve.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>convolve</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.datetime.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>datetime</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.errors.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>errors</span></div></a></li><li class="depth-4"><a href="tech.v3.datatype.ffi.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>ffi</span></div></a></li><li class="depth-5 branch"><a href="tech.v3.datatype.ffi.clang.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>clang</span></div></a></li><li class="depth-5"><a href="tech.v3.datatype.ffi.graalvm.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>graalvm</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.functional.html"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>functional</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.gradient.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gradient</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.jna.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>jna</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.jvm-map.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>jvm-map</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.list.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>list</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.locker.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>locker</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.mmap.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>mmap</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.mmap-writer.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>mmap-writer</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.native-buffer.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>native-buffer</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.nippy.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>nippy</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.packing.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>packing</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.reductions.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>reductions</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.rolling.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>rolling</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.datatype.sampling.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>sampling</span></div></a></li><li class="depth-4 branch current"><a href="tech.v3.datatype.struct.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>struct</span></div></a></li><li class="depth-4"><a href="tech.v3.datatype.wavelet.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>wavelet</span></div></a></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree" style="top: -765px;"><span class="top" style="height: 774px;"></span><span class="bottom"></span></span><span>libs</span></div></div></li><li class="depth-4 branch"><a href="tech.v3.libs.buffered-image.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>buffered-image</span></div></a></li><li class="depth-4"><a href="tech.v3.libs.neanderthal.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>neanderthal</span></div></a></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>parallel</span></div></div></li><li class="depth-4"><a href="tech.v3.parallel.for.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>for</span></div></a></li><li class="depth-3"><a href="tech.v3.tensor.html"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>tensor</span></div></a></li><li class="depth-4 branch"><a href="tech.v3.tensor.color-gradients.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>color-gradients</span></div></a></li><li class="depth-4"><a href="tech.v3.tensor.dimensions.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>dimensions</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="tech.v3.datatype.struct.html#var-datatype-size"><div class="inner"><span>datatype-size</span></div></a></li><li class="depth-1"><a href="tech.v3.datatype.struct.html#var-datatype-width"><div class="inner"><span>datatype-width</span></div></a></li><li class="depth-1"><a href="tech.v3.datatype.struct.html#var-define-datatype.21"><div class="inner"><span>define-datatype!</span></div></a></li><li class="depth-1"><a href="tech.v3.datatype.struct.html#var-get-struct-def"><div class="inner"><span>get-struct-def</span></div></a></li><li class="depth-1"><a href="tech.v3.datatype.struct.html#var-inplace-new-struct"><div class="inner"><span>inplace-new-struct</span></div></a></li><li class="depth-1"><a href="tech.v3.datatype.struct.html#var-new-struct"><div class="inner"><span>new-struct</span></div></a></li><li class="depth-1"><a href="tech.v3.datatype.struct.html#var-offset-of"><div class="inner"><span>offset-of</span></div></a></li><li class="depth-1"><a href="tech.v3.datatype.struct.html#var-struct-datatype.3F"><div class="inner"><span>struct-datatype?</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">tech.v3.datatype.struct</h1><div class="doc"><div class="markdown"><p>Structs are datatypes composed of primitive datatypes or other structs. Similar to records except they do not support string or object columns, only numeric values. They have memset-0 initialization, memcpy copy semantics. For correct equals, hashing, convert struct into a normal persistent map via <code>into</code>.</p>
<p>Example:</p>
<pre><code class="clojure">user> (require '[tech.v3.datatype :as dtype])
nil
user> (require '[tech.v3.datatype.struct :as dt-struct])
nil
user> (define-datatype! :vec3 [{:name :x :datatype :float32}
{:name :y :datatype :float32}
{:name :z :datatype :float32}])
Syntax error compiling at (*cider-repl cnuernber/dtype-next:localhost:36129(clj)*:47:7).
Unable to resolve symbol: define-datatype! in this context
user> (dt-struct/define-datatype! :vec3 [{:name :x :datatype :float32}
{:name :y :datatype :float32}
{:name :z :datatype :float32}])
{:datatype-size 12,
:datatype-width 4,
:data-layout
[{:name :x, :datatype :float32, :offset 0, :n-elems 1}
{:name :y, :datatype :float32, :offset 4, :n-elems 1}
{:name :z, :datatype :float32, :offset 8, :n-elems 1}],
:layout-map
{:x {:name :x, :datatype :float32, :offset 0, :n-elems 1},
:y {:name :y, :datatype :float32, :offset 4, :n-elems 1},
:z {:name :z, :datatype :float32, :offset 8, :n-elems 1}},
:datatype-name :vec3}
user> (dt-struct/new-struct :vec3)
{:x 0.0, :y 0.0, :z 0.0}
user> (.put *1 :x 2.0)
nil
user> *2
{:x 2.0, :y 0.0, :z 0.0}
</code></pre></div></div><div class="public anchor" id="var-datatype-size"><h3>datatype-size</h3><div class="usage"><code>(datatype-size datatype)</code></div><div class="doc"><div class="markdown"><p>Return the size, in bytes, of a datatype.</p></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/struct.clj#L60">view source</a></div></div><div class="public anchor" id="var-datatype-width"><h3>datatype-width</h3><div class="usage"><code>(datatype-width datatype)</code></div><div class="doc"><div class="markdown"><p>Return the width or the of a datatype. The width dictates what address the datatype can start at when embedded in another datatype.</p></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/struct.clj#L69">view source</a></div></div><div class="public anchor" id="var-define-datatype.21"><h3>define-datatype!</h3><div class="usage"><code>(define-datatype! datatype-name datatype-seq)</code></div><div class="doc"><div class="markdown"><p>Define a new struct datatype.</p>
<ul>
<li><code>datatype-name</code> - keyword datatype name.</li>
<li><code>datatype-seq</code> - Sequence of maps with the keys <code>{:name :datatype}</code> which describe the new datatype.</li>
</ul>
<p>Returns the new struct defintion.</p>
<p>Example:</p>
<pre><code class="clojure">(define-datatype! :vec3 [{:name :x :datatype :float32}
{:name :y :datatype :float32}
{:name :z :datatype :float32}])
(define-datatype! :segment [{:name :begin :datatype :vec3}
{:name :end :datatype :vec3}])
</code></pre></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/struct.clj#L190">view source</a></div></div><div class="public anchor" id="var-get-struct-def"><h3>get-struct-def</h3><div class="usage"><code>(get-struct-def datatype)</code></div><div class="doc"><div class="markdown"><p>Get a previously constructed struct definition.</p></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/struct.clj#L129">view source</a></div></div><div class="public anchor" id="var-inplace-new-struct"><h3>inplace-new-struct</h3><div class="usage"><code>(inplace-new-struct datatype backing-store options)</code><code>(inplace-new-struct datatype backing-store)</code></div><div class="doc"><div class="markdown"><p>Create a new struct in-place in the backing store. The backing store must either be convertible to a native buffer or a byte-array.</p>
<p>Returns a new Struct datatype.</p></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/struct.clj#L339">view source</a></div></div><div class="public anchor" id="var-new-struct"><h3>new-struct</h3><div class="usage"><code>(new-struct datatype options)</code><code>(new-struct datatype)</code></div><div class="doc"><div class="markdown"><p>Create a new struct. By default this will use a byte array (:jvm-heap memory). Returns a new struct.</p>
<p>Options are passed into dtype/make-container so container-specific options apply.</p>
<p>Options:</p>
<ul>
<li><code>:container-type</code> - Defaults to <code>:jvm-heap</code> but often you want <code>:native-heap</code></li>
<li><code>:resource-type</code> - If <code>:native-heap</code> <code>:container-type</code> is chosen, this dictates the resource strategy. Options are the same as <code>tech.v3.datatype.native-buffer/malloc</code>.</li>
</ul></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/struct.clj#L351">view source</a></div></div><div class="public anchor" id="var-offset-of"><h3>offset-of</h3><div class="usage"><code>(offset-of struct-dtype-or-struct-def property-vec)</code></div><div class="doc"><div class="markdown"><p>Returns a tuple of [offset dtype].</p></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/struct.clj#L143">view source</a></div></div><div class="public anchor" id="var-struct-datatype.3F"><h3>struct-datatype?</h3><div class="usage"><code>(struct-datatype? datatype)</code></div><div class="doc"><div class="markdown"><p>Returns true of this datatype denotes a struct datatype.</p></div></div><div class="src-link"><a href="https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/struct.clj#L88">view source</a></div></div></div></body></html>