mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-04-24 00:21:11 -04:00
Rework shell stores, other various small changes
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
package io.xpipe.api;
|
||||
|
||||
import io.xpipe.core.source.DataSourceInfo;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface DataRaw extends DataSource {
|
||||
|
||||
DataSourceInfo.Raw getInfo();
|
||||
|
||||
InputStream open();
|
||||
|
||||
byte[] readAll();
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
package io.xpipe.api;
|
||||
|
||||
import io.xpipe.core.data.node.DataStructureNode;
|
||||
import io.xpipe.core.source.DataSourceInfo;
|
||||
|
||||
public interface DataStructure extends DataSource {
|
||||
|
||||
DataSourceInfo.Structure getInfo();
|
||||
|
||||
DataStructureNode read();
|
||||
}
|
||||
|
||||
@@ -2,15 +2,12 @@ package io.xpipe.api;
|
||||
|
||||
import io.xpipe.core.data.node.ArrayNode;
|
||||
import io.xpipe.core.data.node.TupleNode;
|
||||
import io.xpipe.core.source.DataSourceInfo;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface DataTable extends Iterable<TupleNode>, DataSource {
|
||||
|
||||
DataSourceInfo.Table getInfo();
|
||||
|
||||
Stream<TupleNode> stream();
|
||||
|
||||
ArrayNode readAll();
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
package io.xpipe.api;
|
||||
|
||||
import io.xpipe.core.source.DataSourceInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface DataText extends DataSource {
|
||||
|
||||
DataSourceInfo.Text getInfo();
|
||||
|
||||
List<String> readAllLines();
|
||||
|
||||
List<String> readLines(int maxLines);
|
||||
|
||||
@@ -3,27 +3,17 @@ package io.xpipe.api.impl;
|
||||
import io.xpipe.api.DataRaw;
|
||||
import io.xpipe.api.DataSourceConfig;
|
||||
import io.xpipe.core.source.DataSourceId;
|
||||
import io.xpipe.core.source.DataSourceInfo;
|
||||
import io.xpipe.core.source.DataSourceType;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class DataRawImpl extends DataSourceImpl implements DataRaw {
|
||||
|
||||
private final DataSourceInfo.Raw info;
|
||||
|
||||
public DataRawImpl(
|
||||
DataSourceId sourceId,
|
||||
DataSourceConfig sourceConfig,
|
||||
DataSourceInfo.Raw info,
|
||||
io.xpipe.core.source.DataSource<?> internalSource) {
|
||||
super(sourceId, sourceConfig, internalSource);
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceInfo.Raw getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,27 +29,23 @@ public abstract class DataSourceImpl implements DataSource {
|
||||
var req = QueryDataSourceExchange.Request.builder().ref(ds).build();
|
||||
QueryDataSourceExchange.Response res = con.performSimpleExchange(req);
|
||||
var config = new DataSourceConfig(res.getProvider(), res.getConfig());
|
||||
return switch (res.getInfo().getType()) {
|
||||
return switch (res.getType()) {
|
||||
case TABLE -> {
|
||||
var data = res.getInfo().asTable();
|
||||
yield new DataTableImpl(res.getId(), config, data, res.getInternalSource());
|
||||
yield new DataTableImpl(res.getId(), config, res.getInternalSource());
|
||||
}
|
||||
case STRUCTURE -> {
|
||||
var info = res.getInfo().asStructure();
|
||||
yield new DataStructureImpl(res.getId(), config, info, res.getInternalSource());
|
||||
yield new DataStructureImpl(res.getId(), config, res.getInternalSource());
|
||||
}
|
||||
case TEXT -> {
|
||||
var info = res.getInfo().asText();
|
||||
yield new DataTextImpl(res.getId(), config, info, res.getInternalSource());
|
||||
yield new DataTextImpl(res.getId(), config, res.getInternalSource());
|
||||
}
|
||||
case RAW -> {
|
||||
var info = res.getInfo().asRaw();
|
||||
yield new DataRawImpl(res.getId(), config, info, res.getInternalSource());
|
||||
yield new DataRawImpl(res.getId(), config, res.getInternalSource());
|
||||
}
|
||||
case COLLECTION -> throw new UnsupportedOperationException(
|
||||
"Unimplemented case: " + res.getInfo().getType());
|
||||
"Unimplemented case: " + res.getType());
|
||||
default -> throw new IllegalArgumentException(
|
||||
"Unexpected value: " + res.getInfo().getType());
|
||||
"Unexpected value: " + res.getType());
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,20 +4,15 @@ import io.xpipe.api.DataSourceConfig;
|
||||
import io.xpipe.api.DataStructure;
|
||||
import io.xpipe.core.data.node.DataStructureNode;
|
||||
import io.xpipe.core.source.DataSourceId;
|
||||
import io.xpipe.core.source.DataSourceInfo;
|
||||
import io.xpipe.core.source.DataSourceType;
|
||||
|
||||
public class DataStructureImpl extends DataSourceImpl implements DataStructure {
|
||||
|
||||
private final DataSourceInfo.Structure info;
|
||||
|
||||
public DataStructureImpl(
|
||||
DataStructureImpl(
|
||||
DataSourceId sourceId,
|
||||
DataSourceConfig sourceConfig,
|
||||
DataSourceInfo.Structure info,
|
||||
io.xpipe.core.source.DataSource<?> internalSource) {
|
||||
super(sourceId, sourceConfig, internalSource);
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,11 +25,6 @@ public class DataStructureImpl extends DataSourceImpl implements DataStructure {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceInfo.Structure getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataStructureNode read() {
|
||||
return null;
|
||||
|
||||
@@ -13,7 +13,6 @@ import io.xpipe.core.data.typed.TypedAbstractReader;
|
||||
import io.xpipe.core.data.typed.TypedDataStreamParser;
|
||||
import io.xpipe.core.data.typed.TypedDataStructureNodeReader;
|
||||
import io.xpipe.core.source.DataSourceId;
|
||||
import io.xpipe.core.source.DataSourceInfo;
|
||||
import io.xpipe.core.source.DataSourceReference;
|
||||
import io.xpipe.core.source.DataSourceType;
|
||||
|
||||
@@ -25,15 +24,11 @@ import java.util.stream.StreamSupport;
|
||||
|
||||
public class DataTableImpl extends DataSourceImpl implements DataTable {
|
||||
|
||||
private final DataSourceInfo.Table info;
|
||||
|
||||
DataTableImpl(
|
||||
DataSourceId id,
|
||||
DataSourceConfig sourceConfig,
|
||||
DataSourceInfo.Table info,
|
||||
io.xpipe.core.source.DataSource<?> internalSource) {
|
||||
super(id, sourceConfig, internalSource);
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,11 +36,6 @@ public class DataTableImpl extends DataSourceImpl implements DataTable {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceInfo.Table getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public Stream<TupleNode> stream() {
|
||||
var iterator = new TableIterator();
|
||||
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED), false)
|
||||
@@ -93,16 +83,17 @@ public class DataTableImpl extends DataSourceImpl implements DataTable {
|
||||
private TupleNode node;
|
||||
|
||||
{
|
||||
nodeReader = TypedDataStructureNodeReader.of(info.getDataType());
|
||||
parser = new TypedDataStreamParser(info.getDataType());
|
||||
|
||||
connection = XPipeConnection.open();
|
||||
var req = QueryTableDataExchange.Request.builder()
|
||||
.ref(DataSourceReference.id(getId()))
|
||||
.maxRows(Integer.MAX_VALUE)
|
||||
.build();
|
||||
connection.sendRequest(req);
|
||||
connection.receiveResponse();
|
||||
QueryTableDataExchange.Response response = connection.receiveResponse();
|
||||
|
||||
nodeReader = TypedDataStructureNodeReader.of(response.getDataType());
|
||||
parser = new TypedDataStreamParser(response.getDataType());
|
||||
|
||||
connection.receiveBody();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import io.xpipe.beacon.BeaconConnection;
|
||||
import io.xpipe.beacon.BeaconException;
|
||||
import io.xpipe.beacon.exchange.api.QueryTextDataExchange;
|
||||
import io.xpipe.core.source.DataSourceId;
|
||||
import io.xpipe.core.source.DataSourceInfo;
|
||||
import io.xpipe.core.source.DataSourceReference;
|
||||
import io.xpipe.core.source.DataSourceType;
|
||||
|
||||
@@ -25,15 +24,11 @@ import java.util.stream.StreamSupport;
|
||||
|
||||
public class DataTextImpl extends DataSourceImpl implements DataText {
|
||||
|
||||
private final DataSourceInfo.Text info;
|
||||
|
||||
public DataTextImpl(
|
||||
DataTextImpl(
|
||||
DataSourceId sourceId,
|
||||
DataSourceConfig sourceConfig,
|
||||
DataSourceInfo.Text info,
|
||||
io.xpipe.core.source.DataSource<?> internalSource) {
|
||||
super(sourceId, sourceConfig, internalSource);
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,11 +41,6 @@ public class DataTextImpl extends DataSourceImpl implements DataText {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceInfo.Text getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> readAllLines() {
|
||||
return readLines(Integer.MAX_VALUE);
|
||||
|
||||
Reference in New Issue
Block a user