]>
Commit | Line | Data |
---|---|---|
1d09f67e TL |
1 | // Licensed to the Apache Software Foundation (ASF) under one |
2 | // or more contributor license agreements. See the NOTICE file | |
3 | // distributed with this work for additional information | |
4 | // regarding copyright ownership. The ASF licenses this file | |
5 | // to you under the Apache License, Version 2.0 (the | |
6 | // "License"); you may not use this file except in compliance | |
7 | // with the License. You may obtain a copy of the License at | |
8 | // | |
9 | // http://www.apache.org/licenses/LICENSE-2.0 | |
10 | // | |
11 | // Unless required by applicable law or agreed to in writing, software | |
12 | // distributed under the License is distributed on an "AS IS" BASIS, | |
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | // See the License for the specific language governing permissions and | |
15 | // limitations under the License. | |
16 | // | |
17 | // automatically generated by the FlatBuffers compiler, do not modify | |
18 | ||
19 | package org.apache.arrow.flatbuf; | |
20 | ||
21 | import java.nio.*; | |
22 | import java.lang.*; | |
23 | import java.util.*; | |
24 | import com.google.flatbuffers.*; | |
25 | ||
26 | @SuppressWarnings("unused") | |
27 | /** | |
28 | * Compressed Sparse Fiber (CSF) sparse tensor index. | |
29 | */ | |
30 | public final class SparseTensorIndexCSF extends Table { | |
31 | public static void ValidateVersion() { Constants.FLATBUFFERS_1_12_0(); } | |
32 | public static SparseTensorIndexCSF getRootAsSparseTensorIndexCSF(ByteBuffer _bb) { return getRootAsSparseTensorIndexCSF(_bb, new SparseTensorIndexCSF()); } | |
33 | public static SparseTensorIndexCSF getRootAsSparseTensorIndexCSF(ByteBuffer _bb, SparseTensorIndexCSF obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | |
34 | public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); } | |
35 | public SparseTensorIndexCSF __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } | |
36 | ||
37 | /** | |
38 | * CSF is a generalization of compressed sparse row (CSR) index. | |
39 | * See [smith2017knl](http://shaden.io/pub-files/smith2017knl.pdf) | |
40 | * | |
41 | * CSF index recursively compresses each dimension of a tensor into a set | |
42 | * of prefix trees. Each path from a root to leaf forms one tensor | |
43 | * non-zero index. CSF is implemented with two arrays of buffers and one | |
44 | * arrays of integers. | |
45 | * | |
46 | * For example, let X be a 2x3x4x5 tensor and let it have the following | |
47 | * 8 non-zero values: | |
48 | * ```text | |
49 | * X[0, 0, 0, 1] := 1 | |
50 | * X[0, 0, 0, 2] := 2 | |
51 | * X[0, 1, 0, 0] := 3 | |
52 | * X[0, 1, 0, 2] := 4 | |
53 | * X[0, 1, 1, 0] := 5 | |
54 | * X[1, 1, 1, 0] := 6 | |
55 | * X[1, 1, 1, 1] := 7 | |
56 | * X[1, 1, 1, 2] := 8 | |
57 | * ``` | |
58 | * As a prefix tree this would be represented as: | |
59 | * ```text | |
60 | * 0 1 | |
61 | * / \ | | |
62 | * 0 1 1 | |
63 | * / / \ | | |
64 | * 0 0 1 1 | |
65 | * /| /| | /| | | |
66 | * 1 2 0 2 0 0 1 2 | |
67 | * ``` | |
68 | * The type of values in indptrBuffers | |
69 | */ | |
70 | public org.apache.arrow.flatbuf.Int indptrType() { return indptrType(new org.apache.arrow.flatbuf.Int()); } | |
71 | public org.apache.arrow.flatbuf.Int indptrType(org.apache.arrow.flatbuf.Int obj) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; } | |
72 | /** | |
73 | * indptrBuffers stores the sparsity structure. | |
74 | * Each two consecutive dimensions in a tensor correspond to a buffer in | |
75 | * indptrBuffers. A pair of consecutive values at `indptrBuffers[dim][i]` | |
76 | * and `indptrBuffers[dim][i + 1]` signify a range of nodes in | |
77 | * `indicesBuffers[dim + 1]` who are children of `indicesBuffers[dim][i]` node. | |
78 | * | |
79 | * For example, the indptrBuffers for the above X is: | |
80 | * ```text | |
81 | * indptrBuffer(X) = [ | |
82 | * [0, 2, 3], | |
83 | * [0, 1, 3, 4], | |
84 | * [0, 2, 4, 5, 8] | |
85 | * ]. | |
86 | * ``` | |
87 | */ | |
88 | public org.apache.arrow.flatbuf.Buffer indptrBuffers(int j) { return indptrBuffers(new org.apache.arrow.flatbuf.Buffer(), j); } | |
89 | public org.apache.arrow.flatbuf.Buffer indptrBuffers(org.apache.arrow.flatbuf.Buffer obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o) + j * 16, bb) : null; } | |
90 | public int indptrBuffersLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; } | |
91 | public org.apache.arrow.flatbuf.Buffer.Vector indptrBuffersVector() { return indptrBuffersVector(new org.apache.arrow.flatbuf.Buffer.Vector()); } | |
92 | public org.apache.arrow.flatbuf.Buffer.Vector indptrBuffersVector(org.apache.arrow.flatbuf.Buffer.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 16, bb) : null; } | |
93 | /** | |
94 | * The type of values in indicesBuffers | |
95 | */ | |
96 | public org.apache.arrow.flatbuf.Int indicesType() { return indicesType(new org.apache.arrow.flatbuf.Int()); } | |
97 | public org.apache.arrow.flatbuf.Int indicesType(org.apache.arrow.flatbuf.Int obj) { int o = __offset(8); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; } | |
98 | /** | |
99 | * indicesBuffers stores values of nodes. | |
100 | * Each tensor dimension corresponds to a buffer in indicesBuffers. | |
101 | * For example, the indicesBuffers for the above X is: | |
102 | * ```text | |
103 | * indicesBuffer(X) = [ | |
104 | * [0, 1], | |
105 | * [0, 1, 1], | |
106 | * [0, 0, 1, 1], | |
107 | * [1, 2, 0, 2, 0, 0, 1, 2] | |
108 | * ]. | |
109 | * ``` | |
110 | */ | |
111 | public org.apache.arrow.flatbuf.Buffer indicesBuffers(int j) { return indicesBuffers(new org.apache.arrow.flatbuf.Buffer(), j); } | |
112 | public org.apache.arrow.flatbuf.Buffer indicesBuffers(org.apache.arrow.flatbuf.Buffer obj, int j) { int o = __offset(10); return o != 0 ? obj.__assign(__vector(o) + j * 16, bb) : null; } | |
113 | public int indicesBuffersLength() { int o = __offset(10); return o != 0 ? __vector_len(o) : 0; } | |
114 | public org.apache.arrow.flatbuf.Buffer.Vector indicesBuffersVector() { return indicesBuffersVector(new org.apache.arrow.flatbuf.Buffer.Vector()); } | |
115 | public org.apache.arrow.flatbuf.Buffer.Vector indicesBuffersVector(org.apache.arrow.flatbuf.Buffer.Vector obj) { int o = __offset(10); return o != 0 ? obj.__assign(__vector(o), 16, bb) : null; } | |
116 | /** | |
117 | * axisOrder stores the sequence in which dimensions were traversed to | |
118 | * produce the prefix tree. | |
119 | * For example, the axisOrder for the above X is: | |
120 | * ```text | |
121 | * axisOrder(X) = [0, 1, 2, 3]. | |
122 | * ``` | |
123 | */ | |
124 | public int axisOrder(int j) { int o = __offset(12); return o != 0 ? bb.getInt(__vector(o) + j * 4) : 0; } | |
125 | public int axisOrderLength() { int o = __offset(12); return o != 0 ? __vector_len(o) : 0; } | |
126 | public IntVector axisOrderVector() { return axisOrderVector(new IntVector()); } | |
127 | public IntVector axisOrderVector(IntVector obj) { int o = __offset(12); return o != 0 ? obj.__assign(__vector(o), bb) : null; } | |
128 | public ByteBuffer axisOrderAsByteBuffer() { return __vector_as_bytebuffer(12, 4); } | |
129 | public ByteBuffer axisOrderInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 12, 4); } | |
130 | ||
131 | public static int createSparseTensorIndexCSF(FlatBufferBuilder builder, | |
132 | int indptrTypeOffset, | |
133 | int indptrBuffersOffset, | |
134 | int indicesTypeOffset, | |
135 | int indicesBuffersOffset, | |
136 | int axisOrderOffset) { | |
137 | builder.startTable(5); | |
138 | SparseTensorIndexCSF.addAxisOrder(builder, axisOrderOffset); | |
139 | SparseTensorIndexCSF.addIndicesBuffers(builder, indicesBuffersOffset); | |
140 | SparseTensorIndexCSF.addIndicesType(builder, indicesTypeOffset); | |
141 | SparseTensorIndexCSF.addIndptrBuffers(builder, indptrBuffersOffset); | |
142 | SparseTensorIndexCSF.addIndptrType(builder, indptrTypeOffset); | |
143 | return SparseTensorIndexCSF.endSparseTensorIndexCSF(builder); | |
144 | } | |
145 | ||
146 | public static void startSparseTensorIndexCSF(FlatBufferBuilder builder) { builder.startTable(5); } | |
147 | public static void addIndptrType(FlatBufferBuilder builder, int indptrTypeOffset) { builder.addOffset(0, indptrTypeOffset, 0); } | |
148 | public static void addIndptrBuffers(FlatBufferBuilder builder, int indptrBuffersOffset) { builder.addOffset(1, indptrBuffersOffset, 0); } | |
149 | public static void startIndptrBuffersVector(FlatBufferBuilder builder, int numElems) { builder.startVector(16, numElems, 8); } | |
150 | public static void addIndicesType(FlatBufferBuilder builder, int indicesTypeOffset) { builder.addOffset(2, indicesTypeOffset, 0); } | |
151 | public static void addIndicesBuffers(FlatBufferBuilder builder, int indicesBuffersOffset) { builder.addOffset(3, indicesBuffersOffset, 0); } | |
152 | public static void startIndicesBuffersVector(FlatBufferBuilder builder, int numElems) { builder.startVector(16, numElems, 8); } | |
153 | public static void addAxisOrder(FlatBufferBuilder builder, int axisOrderOffset) { builder.addOffset(4, axisOrderOffset, 0); } | |
154 | public static int createAxisOrderVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addInt(data[i]); return builder.endVector(); } | |
155 | public static void startAxisOrderVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); } | |
156 | public static int endSparseTensorIndexCSF(FlatBufferBuilder builder) { | |
157 | int o = builder.endTable(); | |
158 | builder.required(o, 4); // indptrType | |
159 | builder.required(o, 6); // indptrBuffers | |
160 | builder.required(o, 8); // indicesType | |
161 | builder.required(o, 10); // indicesBuffers | |
162 | builder.required(o, 12); // axisOrder | |
163 | return o; | |
164 | } | |
165 | ||
166 | public static final class Vector extends BaseVector { | |
167 | public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; } | |
168 | ||
169 | public SparseTensorIndexCSF get(int j) { return get(new SparseTensorIndexCSF(), j); } | |
170 | public SparseTensorIndexCSF get(SparseTensorIndexCSF obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); } | |
171 | } | |
172 | } | |
173 |