@Test public void testConcatDatset() throws Exception { Map<String, Datasource> nameToDatasource = new HashMap<>(); nameToDatasource.put("mock", new MockDatasource("mock", List.of("column", "join"), List.of(new MockDataset("ds", Map.of("column", "value", "join", "join")), new MockDataset("ds3", Map.of("column", "value3", "join", "nojoin"))))); nameToDatasource.put("mock2", new MockDatasource("mock2", List.of("column2", "join"), List.of(new MockDataset("ds2", Map.of("column2", "value2", "join", "join"))))); Datasource ds = new AttachDatasource(nameToDatasource, new ConfigThingy("", "NAME \"attach\" SOURCE \"mock\" ATTACH \"mock2\" MATCH (\"join\", \"join\")"), null); QueryResults results = ds.find(List.of(new QueryPart("column", "value"))); assertEquals(1, results.size()); Dataset data = results.iterator().next(); assertEquals("ds", data.getKey()); assertEquals("value", data.get("column")); assertEquals("value2", data.get("mock2__column2")); assertThrows(ColumnNotFoundException.class, () -> data.get("unkown")); Dataset data2 = ds.find(List.of(new QueryPart("column", "value3"))).iterator().next(); assertNull(data2.get("mock2__column2")); }
@Override public QueryResults find(List<QueryPart> query) { List<QueryPart> query1 = new ArrayList<>(query.size() / 2); List<QueryPart> query2 = new ArrayList<>(query.size() / 2); List<QueryPart> query2WithPrefix = new ArrayList<>(query.size() / 2); for (QueryPart p : query) { if (p.getColumnName().startsWith(source2Prefix)) { query2.add(new QueryPart(p.getColumnName().substring(source2Prefix.length()), p.getSearchString())); query2WithPrefix.add(p); } else { query1.add(p); } } if (!query1.isEmpty()) { QueryResults results = source1.find(query1); return attachColumns(results, DatasetPredicate.makePredicate(query2WithPrefix)); } else { return attachColumnsReversed(source2.find(query2)); } }
AttachDatasource extends Datasource { @Override public QueryResults find(List<QueryPart> query) { List<QueryPart> query1 = new ArrayList<>(query.size() / 2); List<QueryPart> query2 = new ArrayList<>(query.size() / 2); List<QueryPart> query2WithPrefix = new ArrayList<>(query.size() / 2); for (QueryPart p : query) { if (p.getColumnName().startsWith(source2Prefix)) { query2.add(new QueryPart(p.getColumnName().substring(source2Prefix.length()), p.getSearchString())); query2WithPrefix.add(p); } else { query1.add(p); } } if (!query1.isEmpty()) { QueryResults results = source1.find(query1); return attachColumns(results, DatasetPredicate.makePredicate(query2WithPrefix)); } else { return attachColumnsReversed(source2.find(query2)); } } }
AttachDatasource extends Datasource { @Override public QueryResults find(List<QueryPart> query) { List<QueryPart> query1 = new ArrayList<>(query.size() / 2); List<QueryPart> query2 = new ArrayList<>(query.size() / 2); List<QueryPart> query2WithPrefix = new ArrayList<>(query.size() / 2); for (QueryPart p : query) { if (p.getColumnName().startsWith(source2Prefix)) { query2.add(new QueryPart(p.getColumnName().substring(source2Prefix.length()), p.getSearchString())); query2WithPrefix.add(p); } else { query1.add(p); } } if (!query1.isEmpty()) { QueryResults results = source1.find(query1); return attachColumns(results, DatasetPredicate.makePredicate(query2WithPrefix)); } else { return attachColumnsReversed(source2.find(query2)); } } AttachDatasource(Map<String, Datasource> nameToDatasource, ConfigThingy sourceDesc,
      URL context); }
AttachDatasource extends Datasource { @Override public QueryResults find(List<QueryPart> query) { List<QueryPart> query1 = new ArrayList<>(query.size() / 2); List<QueryPart> query2 = new ArrayList<>(query.size() / 2); List<QueryPart> query2WithPrefix = new ArrayList<>(query.size() / 2); for (QueryPart p : query) { if (p.getColumnName().startsWith(source2Prefix)) { query2.add(new QueryPart(p.getColumnName().substring(source2Prefix.length()), p.getSearchString())); query2WithPrefix.add(p); } else { query1.add(p); } } if (!query1.isEmpty()) { QueryResults results = source1.find(query1); return attachColumns(results, DatasetPredicate.makePredicate(query2WithPrefix)); } else { return attachColumnsReversed(source2.find(query2)); } } AttachDatasource(Map<String, Datasource> nameToDatasource, ConfigThingy sourceDesc,
      URL context); @Override List<String> getSchema(); @Override QueryResults getDatasetsByKey(Collection<String> keys); @Override QueryResults getContents(); @Override QueryResults find(List<QueryPart> query); @Override String getName(); }
AttachDatasource extends Datasource { @Override public QueryResults find(List<QueryPart> query) { List<QueryPart> query1 = new ArrayList<>(query.size() / 2); List<QueryPart> query2 = new ArrayList<>(query.size() / 2); List<QueryPart> query2WithPrefix = new ArrayList<>(query.size() / 2); for (QueryPart p : query) { if (p.getColumnName().startsWith(source2Prefix)) { query2.add(new QueryPart(p.getColumnName().substring(source2Prefix.length()), p.getSearchString())); query2WithPrefix.add(p); } else { query1.add(p); } } if (!query1.isEmpty()) { QueryResults results = source1.find(query1); return attachColumns(results, DatasetPredicate.makePredicate(query2WithPrefix)); } else { return attachColumnsReversed(source2.find(query2)); } } AttachDatasource(Map<String, Datasource> nameToDatasource, ConfigThingy sourceDesc,
      URL context); @Override List<String> getSchema(); @Override QueryResults getDatasetsByKey(Collection<String> keys); @Override QueryResults getContents(); @Override QueryResults find(List<QueryPart> query); @Override String getName();  }