[
https://issues.apache.org/jira/browse/JENA-1107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15073015#comment-15073015
]
ASF GitHub Bot commented on JENA-1107:
--------------------------------------
Github user ajs6f commented on a diff in the pull request:
https://github.com/apache/jena/pull/115#discussion_r48498210
--- Diff:
jena-base/src/main/java/org/apache/jena/atlas/lib/tuple/Tuple.java ---
@@ -0,0 +1,73 @@
+/*
+ * 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.atlas.lib.tuple;
+
+import java.util.List ;
+import java.util.function.Consumer ;
+import java.util.stream.Stream ;
+
+import org.apache.jena.atlas.lib.ArrayUtils ;
+
+/** A Tuple is the same class of item */
+public interface Tuple<X> extends Iterable<X> {
+ /** Get the i'th element, for i in the range 0 to len()-1
+ * @throws IndexOutOfBoundsException for i out of range
+ */
+ public X get(int i) ;
+
+ /** length : elements are 0 to len()-1 */
+ public int len() ;
+
+ /** Convert to a List */
+ public default List<X> asList() {
+ return new TupleList<>(this) ;
+ }
+
+ /** stream */
+ public default Stream<X> stream() {
--- End diff --
`Iterable` has a `default` impl for `::spliterator` that could be used to
make a `Stream`. I think that could avoid the extra object creation in
`Tuple::asList`. That's how the `default` works for `Collection::stream`.
> Improve jena-base lib.Tuple
> ---------------------------
>
> Key: JENA-1107
> URL: https://issues.apache.org/jira/browse/JENA-1107
> Project: Apache Jena
> Issue Type: Improvement
> Reporter: Andy Seaborne
> Assignee: Andy Seaborne
> Priority: Minor
>
> Tuples, which are immutable, value-equality fixed length sequences of
> instances of the same type, accessed by index.
> They are like {{T[]}} but immutable, with .equals based on contents, and
> could be improved to work independently of their original use in TDB.
> Proposal:
> # Make Tuple an interface (simpler than current), with special
> implementations for low number of elements.
> # {{ColumnMap}} ==> {{TupleMap}} and sort out the naming as much as possible
> to use as a way to manage index mapping, not just rewriting Tuples.
> An intermediate step is to move {{ColumnMap}} into TDB.
> This is not a proposal to add it to {{Triple}} or {{Quad}}.
> {{Triple}} is not the same as a 3-length {{Tuple<Node>}}. Triple elements
> are accessed by name ({{getSubject}} etc), not index. SPO is just one
> possible order in which to think about triples but it has no special status.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)