gianm commented on a change in pull request #9235: Add join-related DataSource 
types, and analysis functionality.
URL: https://github.com/apache/druid/pull/9235#discussion_r369336798
 
 

 ##########
 File path: 
processing/src/main/java/org/apache/druid/query/InlineDataSource.java
 ##########
 @@ -0,0 +1,241 @@
+/*
+ * 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.druid.query;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import org.apache.druid.java.util.common.IAE;
+import org.apache.druid.segment.RowAdapter;
+import org.apache.druid.segment.column.ColumnHolder;
+import org.apache.druid.segment.column.ValueType;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.function.ToLongFunction;
+
+/**
+ * Represents an inline datasource, where the rows are embedded within the 
DataSource object itself.
+ *
+ * The rows are backed by an Iterable, which can be lazy or not. Lazy 
datasources will only be iterated if someone calls
+ * {@link #getRows()} and iterates the result, or until someone calls {@link 
#getRowsAsList()}.
+ */
+public class InlineDataSource implements DataSource
+{
+  private final List<String> columnNames;
+  private final List<ValueType> columnTypes;
+  private final Iterable<Object[]> rows;
+
+  private InlineDataSource(
+      final List<String> columnNames,
+      final List<ValueType> columnTypes,
+      final Iterable<Object[]> rows
+  )
+  {
+    this.columnNames = Preconditions.checkNotNull(columnNames, "'columnNames' 
must be nonnull");
+    this.columnTypes = Preconditions.checkNotNull(columnTypes, "'columnTypes' 
must be nonnull");
+    this.rows = Preconditions.checkNotNull(rows, "'rows' must be nonnull");
+
+    if (columnNames.size() != columnTypes.size()) {
+      throw new IAE("columnNames and columnTypes must be the same length");
+    }
+  }
+
+  /**
+   * Factory method for Jackson. Used for inline datasources that were 
originally encoded as JSON. Private because
+   * non-Jackson callers should use {@link #fromIterable}.
+   */
+  @JsonCreator
+  public static InlineDataSource fromJson(
 
 Review comment:
   Oops, yes, it should. I'll fix it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to