@@ -165,191 +165,107 @@ public static IndexEntryWriters.MatcherFactory matcherFactory(String fieldSeq) {
165165 }
166166 }
167167
168- /**
169- * Writes two unsigned varint-encoded long values consecutively.
170- *
171- * @param bb buffer for writing bytes
172- * @param first first value
173- * @param second second value
174- */
175- public static void writePair (final ByteBuffer bb , final long first , final long second ) {
176- Varint .writeUnsigned (bb , first );
177- Varint .writeUnsigned (bb , second );
168+ static void write (ByteBuffer key , ByteBuffer value , long first , long second , long third , long fourth ) {
169+ Varint .writeUnsigned (key , first );
170+ Varint .writeUnsigned (key , second );
171+ Varint .writeUnsigned (value , third );
172+ Varint .writeUnsigned (value , fourth );
178173 }
179174
180175 static void spoc (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
181- writePair (key , subj , pred );
182- int pos = value .position ();
183- writePair (value , obj , context );
184- fill (value , pos );
176+ write (key , value , subj , pred , obj , context );
185177 }
186178
187179 static void spco (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
188- writePair (key , subj , pred );
189- int pos = value .position ();
190- writePair (value , context , obj );
191- fill (value , pos );
180+ write (key , value , subj , pred , context , obj );
192181 }
193182
194183 static void sopc (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
195- writePair (key , subj , obj );
196- int pos = value .position ();
197- writePair (value , pred , context );
198- fill (value , pos );
184+ write (key , value , subj , obj , pred , context );
199185 }
200186
201187 static void socp (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
202- writePair (key , subj , obj );
203- int pos = value .position ();
204- writePair (value , context , pred );
205- fill (value , pos );
188+ write (key , value , subj , obj , context , pred );
206189 }
207190
208191 static void scpo (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
209- writePair (key , subj , context );
210- int pos = value .position ();
211- writePair (value , pred , obj );
212- fill (value , pos );
192+ write (key , value , subj , context , pred , obj );
213193 }
214194
215195 static void scop (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
216- writePair (key , subj , context );
217- int pos = value .position ();
218- writePair (value , obj , pred );
219- fill (value , pos );
196+ write (key , value , subj , context , obj , pred );
220197 }
221198
222199 static void psoc (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
223- writePair (key , pred , subj );
224- int pos = value .position ();
225- writePair (value , obj , context );
226- fill (value , pos );
200+ write (key , value , pred , subj , obj , context );
227201 }
228202
229203 static void psco (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
230- writePair (key , pred , subj );
231- int pos = value .position ();
232- writePair (value , context , obj );
233- fill (value , pos );
204+ write (key , value , pred , subj , context , obj );
234205 }
235206
236207 static void posc (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
237- writePair (key , pred , obj );
238- int pos = value .position ();
239- writePair (value , subj , context );
240- fill (value , pos );
208+ write (key , value , pred , obj , subj , context );
241209 }
242210
243211 static void pocs (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
244- writePair (key , pred , obj );
245- int pos = value .position ();
246- writePair (value , context , subj );
247- fill (value , pos );
212+ write (key , value , pred , obj , context , subj );
248213 }
249214
250215 static void pcso (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
251- writePair (key , pred , context );
252- int pos = value .position ();
253- writePair (value , subj , obj );
254- fill (value , pos );
216+ write (key , value , pred , context , subj , obj );
255217 }
256218
257219 static void pcos (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
258- writePair (key , pred , context );
259- int pos = value .position ();
260- writePair (value , obj , subj );
261- fill (value , pos );
220+ write (key , value , pred , context , obj , subj );
262221 }
263222
264223 static void ospc (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
265- writePair (key , obj , subj );
266- int pos = value .position ();
267- writePair (value , pred , context );
268- fill (value , pos );
224+ write (key , value , obj , subj , pred , context );
269225 }
270226
271227 static void oscp (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
272- writePair (key , obj , subj );
273- int pos = value .position ();
274- writePair (value , context , pred );
275- fill (value , pos );
228+ write (key , value , obj , subj , context , pred );
276229 }
277230
278231 static void opsc (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
279- writePair (key , obj , pred );
280- int pos = value .position ();
281- writePair (value , subj , context );
282- fill (value , pos );
232+ write (key , value , obj , pred , subj , context );
283233 }
284234
285235 static void opcs (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
286- writePair (key , obj , pred );
287- int pos = value .position ();
288- writePair (value , context , subj );
289- fill (value , pos );
236+ write (key , value , obj , pred , context , subj );
290237 }
291238
292239 static void ocsp (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
293- writePair (key , obj , context );
294- int pos = value .position ();
295- writePair (value , subj , pred );
296- fill (value , pos );
240+ write (key , value , obj , context , subj , pred );
297241 }
298242
299243 static void ocps (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
300- writePair (key , obj , context );
301- int pos = value .position ();
302- writePair (value , pred , subj );
303- fill (value , pos );
244+ write (key , value , obj , context , pred , subj );
304245 }
305246
306247 static void cspo (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
307- writePair (key , context , subj );
308- int pos = value .position ();
309- writePair (value , pred , obj );
310- fill (value , pos );
248+ write (key , value , context , subj , pred , obj );
311249 }
312250
313251 static void csop (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
314- writePair (key , context , subj );
315- int pos = value .position ();
316- writePair (value , obj , pred );
317- fill (value , pos );
252+ write (key , value , context , subj , obj , pred );
318253 }
319254
320255 static void cpso (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
321- writePair (key , context , pred );
322- int pos = value .position ();
323- writePair (value , subj , obj );
324- fill (value , pos );
256+ write (key , value , context , pred , subj , obj );
325257 }
326258
327259 static void cpos (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
328- writePair (key , context , pred );
329- int pos = value .position ();
330- writePair (value , obj , subj );
331- fill (value , pos );
260+ write (key , value , context , pred , obj , subj );
332261 }
333262
334263 static void cosp (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
335- writePair (key , context , obj );
336- int pos = value .position ();
337- writePair (value , subj , pred );
338- fill (value , pos );
264+ write (key , value , context , obj , subj , pred );
339265 }
340266
341267 static void cops (ByteBuffer key , ByteBuffer value , long subj , long pred , long obj , long context ) {
342- writePair (key , context , obj );
343- int pos = value .position ();
344- writePair (value , pred , subj );
345- fill (value , pos );
346- }
347-
348- static void fill (ByteBuffer buffer , int fromPos ) {
349- /*
350- * int count = 2 * (Long.BYTES + 1) - (buffer.position() - fromPos); while (count-- > 0) { buffer.put((byte) 0);
351- * }
352- */
268+ write (key , value , context , obj , pred , subj );
353269 }
354270
355271 static boolean [] spocShouldMatch (long subj , long pred , long obj , long context ) {
0 commit comments