ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/result/MergedResult.java

Path
ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/result/MergedResult.java
Status
scanned
Type
file
Name
MergedResult.java
Extension
.java
Programming language
Java
Mime type
text/x-java
File type
Java source, ASCII text
Tag

      
    
Rootfs path

      
    
Size
2875 (2.8 KB)
MD5
074f5df401f7d806634bdbf16622ec67
SHA1
8c519d7a2470ad64527503c2cd6c9d79678d6a58
SHA256
064ac64556fabb4c573a8d758522bedcda4f1ff23e2d1a9937e61ad1a4cce865
SHA512

      
    
SHA1_git
173a676fc00a54347c03edadc48ace3a6842a4f3
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
MergedResult.java | 2.8 KB |

/* * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (https://h2database.com/html/license.html). * Initial Developer: H2 Group */ package org.h2.result; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.h2.util.Utils; import org.h2.value.Value; /** * Merged result. Used to combine several results into one. Merged result will * contain rows from all appended results. Results are not required to have the * same lists of columns, but required to have compatible column definitions, * for example, if one result has a {@link java.sql.Types#VARCHAR} column * {@code NAME} then another results that have {@code NAME} column should also * define it with the same type. */ public final class MergedResult { private final ArrayList<Map<SimpleResult.Column, Value>> data = Utils.newSmallArrayList(); private final ArrayList<SimpleResult.Column> columns = Utils.newSmallArrayList(); /** * Appends a result. * * @param result * result to append */ public void add(ResultInterface result) { int count = result.getVisibleColumnCount(); if (count == 0) { return; } SimpleResult.Column[] cols = new SimpleResult.Column[count]; for (int i = 0; i < count; i++) { SimpleResult.Column c = new SimpleResult.Column(result.getAlias(i), result.getColumnName(i), result.getColumnType(i)); cols[i] = c; if (!columns.contains(c)) { columns.add(c); } } while (result.next()) { if (count == 1) { data.add(Collections.singletonMap(cols[0], result.currentRow()[0])); } else { HashMap<SimpleResult.Column, Value> map = new HashMap<>(); for (int i = 0; i < count; i++) { SimpleResult.Column ci = cols[i]; map.put(ci, result.currentRow()[i]); } data.add(map); } } } /** * Returns merged results. * * @return result with rows from all appended result sets */ public SimpleResult getResult() { SimpleResult result = new SimpleResult(); for (SimpleResult.Column c : columns) { result.addColumn(c); } for (Map<SimpleResult.Column, Value> map : data) { Value[] row = new Value[columns.size()]; for (Map.Entry<SimpleResult.Column, Value> entry : map.entrySet()) { row[columns.indexOf(entry.getKey())] = entry.getValue(); } result.addRow(row); } return result; } @Override public String toString() { return columns + ": " + data.size(); } }
Detected license expression
mpl-2.0 AND epl-1.0
Detected license expression (SPDX)
MPL-2.0 AND EPL-1.0
Percentage of license text
2.9
Copyrights
- end_line: 2
  copyright: Copyright 2004-2023 H2 Group. Multiple-Licensed
  start_line: 2
Holders
- holder: H2 Group. Multiple-Licensed
  end_line: 2
  start_line: 2
Authors

      
    
License detections License expression License expression SPDX
mpl_2_0_and_epl_1_0-796bf8d7-f485-3520-923d-e6a4b1ecd2f3 mpl-2.0 AND epl-1.0 MPL-2.0 AND EPL-1.0
URL Start line End line
https://h2database.com/html/license.html 3 3
Package URL License Primary language
pkg:osgi/com.h2database.source@2.2.220