mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-11 12:00:59 +00:00
Performance improvements
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
package io.xpipe.core.store;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import io.xpipe.core.util.DataStateProvider;
|
||||
import io.xpipe.core.util.JacksonizedValue;
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.UUID;
|
||||
|
||||
@JsonTypeName("internalStream")
|
||||
@SuperBuilder
|
||||
@Jacksonized
|
||||
@Getter
|
||||
public class InternalStreamStore extends JacksonizedValue implements StreamDataStore {
|
||||
|
||||
private final UUID uuid;
|
||||
|
||||
public InternalStreamStore() {
|
||||
this.uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
private Path getFile() {
|
||||
return DataStateProvider.get().getInternalStreamStore(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream openInput() throws Exception {
|
||||
return Files.newInputStream(getFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream openOutput() throws Exception {
|
||||
return Files.newOutputStream(getFile());
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,7 @@ package io.xpipe.core.util;
|
||||
import io.xpipe.core.store.DataStore;
|
||||
import io.xpipe.core.store.DataStoreState;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class DataStateProvider {
|
||||
@@ -31,6 +29,4 @@ public abstract class DataStateProvider {
|
||||
public abstract <T> T getCache(DataStore store, String key, Class<T> c, Supplier<T> def);
|
||||
|
||||
public abstract boolean isInStorage(DataStore store);
|
||||
|
||||
public abstract Path getInternalStreamStore(UUID id);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package io.xpipe.core.util;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UuidHelper {
|
||||
|
||||
public static UUID generateFromObject(Object o) {
|
||||
return UUID.nameUUIDFromBytes(o.toString().getBytes(StandardCharsets.UTF_8));
|
||||
public static UUID generateFromObject(Object... o) {
|
||||
return UUID.nameUUIDFromBytes(Arrays.toString(o).getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public static Optional<UUID> parse(String s) {
|
||||
|
||||
Reference in New Issue
Block a user