[
https://issues.apache.org/jira/browse/JENA-1440?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16267220#comment-16267220
]
ASF GitHub Bot commented on JENA-1440:
--------------------------------------
Github user ajs6f commented on a diff in the pull request:
https://github.com/apache/jena/pull/317#discussion_r153284608
--- Diff:
jena-db/jena-dboe-base/src/main/java/org/apache/jena/dboe/base/buffer/RecordBufferIteratorMapper.java
---
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.dboe.base.buffer;
+
+import static org.apache.jena.atlas.lib.Alg.decodeIndex ;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.apache.jena.atlas.lib.Bytes;
+import org.apache.jena.dboe.base.record.Record;
+import org.apache.jena.dboe.base.record.RecordMapper;
+
+// Iterate over one RecordBuffer
+public class RecordBufferIteratorMapper<X> implements Iterator<X>
+{
+ private RecordBuffer rBuff ;
+ private int nextIdx ;
+ private X slot = null ;
+ private final byte[] keySlot ;
+ private final Record maxRec ;
+ private final Record minRec ;
+ private final RecordMapper<X> mapper;
+
+// RecordBufferIteratorMapper(RecordBuffer rBuff)
+// { this(rBuff, null, null); }
+
+ RecordBufferIteratorMapper(RecordBuffer rBuff, Record minRecord,
Record maxRecord, int keyLen, RecordMapper<X> mapper)
+ {
+ this.rBuff = rBuff ;
+ this.mapper = mapper ;
+ this.keySlot = (maxRecord==null) ? null : new byte[keyLen];
+ nextIdx = 0 ;
+ minRec = minRecord ;
+ if ( minRec != null )
+ {
+ nextIdx = rBuff.find(minRec) ;
+ if ( nextIdx < 0 )
+ nextIdx = decodeIndex(nextIdx) ;
+ }
+
+ maxRec = maxRecord ;
+ }
+
+ private void finish()
+ {
+ rBuff = null ;
+ nextIdx = -99 ;
--- End diff --
Might be nice to call this out as a constant, like `NO_NEXT_INDEX` or the
like.
> Map ByteBuffer direct to NodeIds, avoiding a Record object (TupleIndexRecord)
> -----------------------------------------------------------------------------
>
> Key: JENA-1440
> URL: https://issues.apache.org/jira/browse/JENA-1440
> Project: Apache Jena
> Issue Type: Improvement
> Components: TDB2
> Affects Versions: Jena 3.5.0, Jena 3.6.0
> Reporter: Andy Seaborne
> Assignee: Andy Seaborne
> Priority: Minor
> Fix For: Jena 3.7.0
>
>
> Avoiding going {{bytes-> Record->Tuple<NodeId>}} can save about 25% of time
> in a large index scan (but there are lots of other things going on in a
> typical query and this change would be negligible).
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)