rename objects from data -> fullData

Also rename SpottyDataSource to singleChunkDataSource
This commit is contained in:
James Seibel
2023-02-13 20:43:55 -06:00
parent 4697f942e2
commit 0cb46c9b57
26 changed files with 184 additions and 174 deletions
@@ -7,7 +7,7 @@ import com.seibel.lod.api.objects.data.DhApiTerrainDataPoint;
import com.seibel.lod.api.interfaces.data.IDhApiTerrainDataRepo;
import com.seibel.lod.api.objects.math.DhApiVec3i;
import com.seibel.lod.core.api.internal.SharedApi;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.full.FullDataPoint;
import com.seibel.lod.core.datatype.full.FullDataPointIdMap;
import com.seibel.lod.core.datatype.full.accessor.SingleFullArrayView;
@@ -195,7 +195,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
try
{
// attempt to get/generate the data source for this section
ILodDataSource dataSource = level.getFileHandler().read(sectionPos).get();
IFullDataSource dataSource = level.getFileHandler().read(sectionPos).get();
if (dataSource == null)
{
return DhApiResult.createFail("Unable to find/generate any data at the " + DhSectionPos.class.getSimpleName() + " [" + sectionPos + "].");
@@ -11,9 +11,9 @@ import java.util.*;
public abstract class AbstractDataSourceLoader
{
public static final HashMultimap<Class<? extends ILodDataSource>, AbstractDataSourceLoader> loaderRegistry = HashMultimap.create();
public final Class<? extends ILodDataSource> clazz;
public static final HashMap<Long, Class<? extends ILodDataSource>> datatypeIdRegistry = new HashMap<>();
public static final HashMultimap<Class<? extends IFullDataSource>, AbstractDataSourceLoader> loaderRegistry = HashMultimap.create();
public final Class<? extends IFullDataSource> clazz;
public static final HashMap<Long, Class<? extends IFullDataSource>> datatypeIdRegistry = new HashMap<>();
public static AbstractDataSourceLoader getLoader(long dataTypeId, byte dataVersion)
{
@@ -22,7 +22,7 @@ public abstract class AbstractDataSourceLoader
.findFirst().orElse(null);
}
public static AbstractDataSourceLoader getLoader(Class<? extends ILodDataSource> clazz, byte dataVersion)
public static AbstractDataSourceLoader getLoader(Class<? extends IFullDataSource> clazz, byte dataVersion)
{
return loaderRegistry.get(clazz).stream()
.filter(l -> Arrays.binarySearch(l.loaderSupportedVersions, dataVersion) >= 0)
@@ -32,7 +32,7 @@ public abstract class AbstractDataSourceLoader
public final long datatypeId;
public final byte[] loaderSupportedVersions;
public AbstractDataSourceLoader(Class<? extends ILodDataSource> clazz, long datatypeId, byte[] loaderSupportedVersions)
public AbstractDataSourceLoader(Class<? extends IFullDataSource> clazz, long datatypeId, byte[] loaderSupportedVersions)
{
this.datatypeId = datatypeId;
this.loaderSupportedVersions = loaderSupportedVersions;
@@ -62,7 +62,7 @@ public abstract class AbstractDataSourceLoader
}
/** Can return null as meaning the requirement is not met */
public abstract ILodDataSource loadData(FullDataMetaFile dataFile, InputStream data, IDhLevel level) throws IOException;
public abstract IFullDataSource loadData(FullDataMetaFile dataFile, InputStream data, IDhLevel level) throws IOException;
}
@@ -11,7 +11,7 @@ import java.util.*;
/**
* Abstract for loading and creating {@link ILodRenderSource} objects
* from {@link RenderMetaDataFile}'s and {@link ILodDataSource}'s. <br><Br>
* from {@link RenderMetaDataFile}'s and {@link IFullDataSource}'s. <br><Br>
*
* Also holds all {@link AbstractRenderSourceLoader}'s
* that have been created to allow for migrating old render data formats.
@@ -101,6 +101,6 @@ public abstract class AbstractRenderSourceLoader
*/
public abstract ILodRenderSource loadRenderSource(RenderMetaDataFile renderFile, InputStream data, IDhLevel level) throws IOException;
/** Should not return null */
public abstract ILodRenderSource createRenderSource(ILodDataSource dataSource, IDhClientLevel level);
public abstract ILodRenderSource createRenderSource(IFullDataSource dataSource, IDhClientLevel level);
}
@@ -10,7 +10,7 @@ import com.seibel.lod.core.pos.DhSectionPos;
import java.io.IOException;
import java.io.OutputStream;
public interface ILodDataSource
public interface IFullDataSource
{
DhSectionPos getSectionPos();
@@ -1,11 +0,0 @@
package com.seibel.lod.core.datatype;
import com.seibel.lod.core.datatype.full.accessor.SingleFullArrayView;
public interface IIncompleteDataSource extends ILodDataSource
{
void sampleFrom(ILodDataSource source);
ILodDataSource trySelfPromote();
}
@@ -0,0 +1,9 @@
package com.seibel.lod.core.datatype;
public interface IIncompleteFullDataSource extends IFullDataSource
{
void sampleFrom(IFullDataSource source);
IFullDataSource trySelfPromote();
}
@@ -1,7 +1,7 @@
package com.seibel.lod.core.datatype.column;
import com.seibel.lod.core.datatype.IIncompleteDataSource;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IIncompleteFullDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.column.accessor.ColumnFormat;
import com.seibel.lod.core.datatype.full.FullDataSource;
import com.seibel.lod.core.datatype.transform.FullToColumnTransformer;
@@ -49,15 +49,15 @@ public class ColumnRenderLoader extends AbstractRenderSourceLoader
}
@Override
public ILodRenderSource createRenderSource(ILodDataSource dataSource, IDhClientLevel level)
public ILodRenderSource createRenderSource(IFullDataSource dataSource, IDhClientLevel level)
{
if (dataSource instanceof FullDataSource) // TODO replace with Java 7 method
{
return FullToColumnTransformer.transformFullDataToColumnData(level, (FullDataSource) dataSource);
}
else if (dataSource instanceof IIncompleteDataSource)
else if (dataSource instanceof IIncompleteFullDataSource)
{
return FullToColumnTransformer.transformIncompleteDataToColumnData(level, (IIncompleteDataSource) dataSource);
return FullToColumnTransformer.transformIncompleteDataToColumnData(level, (IIncompleteFullDataSource) dataSource);
}
LodUtil.assertNotReach();
return null;
@@ -1,6 +1,6 @@
package com.seibel.lod.core.datatype.full;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.full.accessor.SingleFullArrayView;
import com.seibel.lod.core.file.fullDatafile.IFullDataSourceProvider;
import com.seibel.lod.core.pos.DhLodPos;
@@ -14,21 +14,21 @@ import java.util.concurrent.CompletableFuture;
public class FullDataDownSampler {
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
public static CompletableFuture<ILodDataSource> createDownSamplingFuture(DhSectionPos newTarget, IFullDataSourceProvider provider) {
public static CompletableFuture<IFullDataSource> createDownSamplingFuture(DhSectionPos newTarget, IFullDataSourceProvider provider) {
// TODO: Make this future somehow run with lowest priority (to ensure ram usage stays low)
return createDownSamplingFuture(FullDataSource.createEmpty(newTarget), provider);
}
public static CompletableFuture<ILodDataSource> createDownSamplingFuture(FullDataSource target, IFullDataSourceProvider provider) {
public static CompletableFuture<IFullDataSource> createDownSamplingFuture(FullDataSource target, IFullDataSourceProvider provider) {
int sectionSizeNeeded = 1 << target.getDataDetail();
ArrayList<CompletableFuture<ILodDataSource>> futures;
ArrayList<CompletableFuture<IFullDataSource>> futures;
DhLodPos basePos = target.getSectionPos().getSectionBBoxPos().getCornerLodPos(FullDataSource.SECTION_SIZE_OFFSET);
if (sectionSizeNeeded <= FullDataSource.SECTION_SIZE_OFFSET) {
futures = new ArrayList<>(sectionSizeNeeded * sectionSizeNeeded);
for (int ox = 0; ox < sectionSizeNeeded; ox++) {
for (int oz = 0; oz < sectionSizeNeeded; oz++) {
CompletableFuture<ILodDataSource> future = provider.read(new DhSectionPos(
CompletableFuture<IFullDataSource> future = provider.read(new DhSectionPos(
FullDataSource.SECTION_SIZE_OFFSET, basePos.x + ox, basePos.z + oz));
future = future.whenComplete((source, ex) -> {
if (ex == null && source != null && source instanceof FullDataSource) {
@@ -45,7 +45,7 @@ public class FullDataDownSampler {
int multiplier = sectionSizeNeeded / FullDataSource.SECTION_SIZE;
for (int ox = 0; ox < FullDataSource.SECTION_SIZE; ox++) {
for (int oz = 0; oz < FullDataSource.SECTION_SIZE; oz++) {
CompletableFuture<ILodDataSource> future = provider.read(new DhSectionPos(
CompletableFuture<IFullDataSource> future = provider.read(new DhSectionPos(
FullDataSource.SECTION_SIZE_OFFSET, basePos.x + ox * multiplier, basePos.z + oz * multiplier));
future = future.whenComplete((source, ex) -> {
if (ex == null && source != null && source instanceof FullDataSource) {
@@ -1,7 +1,7 @@
package com.seibel.lod.core.datatype.full;
import com.seibel.lod.core.datatype.AbstractDataSourceLoader;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.file.fullDatafile.FullDataMetaFile;
import com.seibel.lod.core.level.IDhLevel;
@@ -16,7 +16,7 @@ public class FullDataLoader extends AbstractDataSourceLoader
}
@Override
public ILodDataSource loadData(FullDataMetaFile dataFile, InputStream data, IDhLevel level) throws IOException
public IFullDataSource loadData(FullDataMetaFile dataFile, InputStream data, IDhLevel level) throws IOException
{
//TODO: Add decompressor here
return FullDataSource.loadData(dataFile, data, level);
@@ -1,12 +1,12 @@
package com.seibel.lod.core.datatype.full;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.full.accessor.FullArrayView;
import com.seibel.lod.core.datatype.full.accessor.SingleFullArrayView;
import com.seibel.lod.core.level.IDhLevel;
import com.seibel.lod.core.pos.DhBlockPos2D;
import com.seibel.lod.core.pos.DhLodPos;
import com.seibel.lod.core.file.fullDatafile.FullDataMetaFile;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.pos.DhSectionPos;
import com.seibel.lod.core.util.BitShiftUtil;
import com.seibel.lod.core.util.objects.UnclosableInputStream;
@@ -19,7 +19,7 @@ import java.io.*;
/**
* 1 chunk
*/
public class FullDataSource extends FullArrayView implements ILodDataSource
public class FullDataSource extends FullArrayView implements IFullDataSource
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
public static final byte SECTION_SIZE_OFFSET = 6;
@@ -1,12 +0,0 @@
package com.seibel.lod.core.datatype.full;
import com.seibel.lod.core.pos.DhSectionPos;
public class SampledDataSource extends FullDataSource {
private boolean[] isGenerated;
protected SampledDataSource(DhSectionPos sectionPos) {
super(sectionPos);
}
}
@@ -0,0 +1,11 @@
package com.seibel.lod.core.datatype.full;
import com.seibel.lod.core.pos.DhSectionPos;
public class SampledFullDataSource extends FullDataSource
{
private boolean[] isGenerated;
protected SampledFullDataSource(DhSectionPos sectionPos) { super(sectionPos); }
}
@@ -1,7 +1,7 @@
package com.seibel.lod.core.datatype.full;
import com.seibel.lod.core.datatype.IIncompleteDataSource;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.IIncompleteFullDataSource;
import com.seibel.lod.core.datatype.full.accessor.FullArrayView;
import com.seibel.lod.core.datatype.full.accessor.SingleFullArrayView;
import com.seibel.lod.core.file.fullDatafile.FullDataMetaFile;
@@ -17,29 +17,29 @@ import java.io.*;
import java.util.BitSet;
/**
* 1 chunk
* 1 chunk of full data (formerly SpottyDataSource)
*/
public class SpottyDataSource extends FullArrayView implements IIncompleteDataSource
public class SingleChunkFullDataSource extends FullArrayView implements IIncompleteFullDataSource
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
public static final byte SECTION_SIZE_OFFSET = 6;
public static final int SECTION_SIZE = 1 << SECTION_SIZE_OFFSET;
public static final byte LATEST_VERSION = 0;
public static final long TYPE_ID = "SpottyDataSource".hashCode();
public static final long TYPE_ID = "SingleChunkFullDataSource".hashCode();
private final DhSectionPos sectionPos;
private boolean isEmpty = true;
private final BitSet isColumnNotEmpty;
protected SpottyDataSource(DhSectionPos sectionPos)
protected SingleChunkFullDataSource(DhSectionPos sectionPos)
{
super(new FullDataPointIdMap(), new long[SECTION_SIZE*SECTION_SIZE][0], SECTION_SIZE);
LodUtil.assertTrue(sectionPos.sectionDetailLevel > SparseDataSource.MAX_SECTION_DETAIL);
LodUtil.assertTrue(sectionPos.sectionDetailLevel > SparseFullDataSource.MAX_SECTION_DETAIL);
this.sectionPos = sectionPos;
this.isColumnNotEmpty = new BitSet(SECTION_SIZE*SECTION_SIZE);
}
@Override
public DhSectionPos getSectionPos() { return this.sectionPos; }
public DhSectionPos getSectionPos() { return this.sectionPos; }
@Override
public byte getDataDetail() { return (byte) (this.sectionPos.sectionDetailLevel -SECTION_SIZE_OFFSET); }
@@ -118,7 +118,7 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
}
public static SpottyDataSource loadData(FullDataMetaFile dataFile, InputStream dataStream, IDhLevel level) throws IOException
public static SingleChunkFullDataSource loadData(FullDataMetaFile dataFile, InputStream dataStream, IDhLevel level) throws IOException
{
DataInputStream dos = new DataInputStream(dataStream); // DO NOT CLOSE
{
@@ -140,7 +140,7 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
if (end == 0x00000001)
{
// Section is empty
return new SpottyDataSource(dataFile.pos);
return new SingleChunkFullDataSource(dataFile.pos);
}
// Is column not empty
@@ -182,11 +182,11 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
if (end != 0xFFFFFFFF)
throw new IOException("invalid id mapping end guard");
return new SpottyDataSource(dataFile.pos, mapping, isColumnNotEmpty, data);
return new SingleChunkFullDataSource(dataFile.pos, mapping, isColumnNotEmpty, data);
}
}
private SpottyDataSource(DhSectionPos pos, FullDataPointIdMap mapping, BitSet isColumnNotEmpty, long[][] data)
private SingleChunkFullDataSource(DhSectionPos pos, FullDataPointIdMap mapping, BitSet isColumnNotEmpty, long[][] data)
{
super(mapping, data, SECTION_SIZE);
LodUtil.assertTrue(data.length == SECTION_SIZE*SECTION_SIZE);
@@ -195,7 +195,7 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
this.isEmpty = false;
}
public static SpottyDataSource createEmpty(DhSectionPos pos) { return new SpottyDataSource(pos); }
public static SingleChunkFullDataSource createEmpty(DhSectionPos pos) { return new SingleChunkFullDataSource(pos); }
public static boolean neededForPosition(DhSectionPos posToWrite, DhSectionPos posToTest)
{
@@ -210,7 +210,7 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
}
@Override
public void sampleFrom(ILodDataSource source)
public void sampleFrom(IFullDataSource source)
{
DhSectionPos pos = source.getSectionPos();
LodUtil.assertTrue(pos.sectionDetailLevel < this.sectionPos.sectionDetailLevel);
@@ -218,9 +218,9 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
if (source.isEmpty())
return;
if (source instanceof SparseDataSource)
if (source instanceof SparseFullDataSource)
{
this.sampleFrom((SparseDataSource) source);
this.sampleFrom((SparseFullDataSource) source);
}
else if (source instanceof FullDataSource)
{
@@ -232,7 +232,7 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
}
}
private void sampleFrom(SparseDataSource sparseSource)
private void sampleFrom(SparseFullDataSource sparseSource)
{
DhSectionPos pos = sparseSource.getSectionPos();
this.isEmpty = false;
@@ -244,7 +244,7 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
int offsetX = dataPos.x - basePos.x;
int offsetZ = dataPos.z - basePos.z;
LodUtil.assertTrue(offsetX >= 0 && offsetX < SECTION_SIZE && offsetZ >= 0 && offsetZ < SECTION_SIZE);
int chunksPerData = 1 << (this.getDataDetail() - SparseDataSource.SPARSE_UNIT_DETAIL);
int chunksPerData = 1 << (this.getDataDetail() - SparseFullDataSource.SPARSE_UNIT_DETAIL);
int dataSpan = this.sectionPos.getWidth(this.getDataDetail()).numberOfLodSectionsWide;
for (int ox = 0; ox < dataSpan; ox++)
@@ -316,7 +316,7 @@ public class SpottyDataSource extends FullArrayView implements IIncompleteDataSo
}
@Override
public ILodDataSource trySelfPromote()
public IFullDataSource trySelfPromote()
{
if (this.isEmpty)
return this;
@@ -1,7 +1,7 @@
package com.seibel.lod.core.datatype.full;
import com.seibel.lod.core.datatype.AbstractDataSourceLoader;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.file.fullDatafile.FullDataMetaFile;
import com.seibel.lod.core.level.IDhLevel;
@@ -12,12 +12,12 @@ public class SparseDataLoader extends AbstractDataSourceLoader
{
public SparseDataLoader()
{
super(SparseDataSource.class, SparseDataSource.TYPE_ID, new byte[] { SparseDataSource.LATEST_VERSION });
super(SparseFullDataSource.class, SparseFullDataSource.TYPE_ID, new byte[] { SparseFullDataSource.LATEST_VERSION });
}
@Override
public ILodDataSource loadData(FullDataMetaFile dataFile, InputStream data, IDhLevel level) throws IOException
public IFullDataSource loadData(FullDataMetaFile dataFile, InputStream data, IDhLevel level) throws IOException
{
return SparseDataSource.loadData(dataFile, data, level);
return SparseFullDataSource.loadData(dataFile, data, level);
}
}
@@ -1,7 +1,7 @@
package com.seibel.lod.core.datatype.full;
import com.seibel.lod.core.datatype.IIncompleteDataSource;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IIncompleteFullDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.full.accessor.FullArrayView;
import com.seibel.lod.core.datatype.full.accessor.SingleFullArrayView;
import com.seibel.lod.core.file.fullDatafile.FullDataMetaFile;
@@ -17,9 +17,9 @@ import java.io.*;
import java.util.BitSet;
/**
* Handles full data with the detail level {@link SparseDataSource#SPARSE_UNIT_DETAIL}
* Handles full data with the detail level {@link SparseFullDataSource#SPARSE_UNIT_DETAIL}
*/
public class SparseDataSource implements IIncompleteDataSource
public class SparseFullDataSource implements IIncompleteFullDataSource
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
public static final byte SPARSE_UNIT_DETAIL = 4;
@@ -29,7 +29,7 @@ public class SparseDataSource implements IIncompleteDataSource
public static final int SECTION_SIZE = (byte) BitShiftUtil.powerOfTwo(SECTION_SIZE_OFFSET);
public static final byte MAX_SECTION_DETAIL = SECTION_SIZE_OFFSET + SPARSE_UNIT_DETAIL;
public static final byte LATEST_VERSION = 0;
public static final long TYPE_ID = "SparseDataSource".hashCode();
public static final long TYPE_ID = "SparseFullDataSource".hashCode();
/**
* This is the byte put between different sections in the binary save file.
@@ -49,9 +49,9 @@ public class SparseDataSource implements IIncompleteDataSource
public static SparseDataSource createEmpty(DhSectionPos pos) { return new SparseDataSource(pos); }
public static SparseFullDataSource createEmpty(DhSectionPos pos) { return new SparseFullDataSource(pos); }
protected SparseDataSource(DhSectionPos sectionPos)
protected SparseFullDataSource(DhSectionPos sectionPos)
{
LodUtil.assertTrue(sectionPos.sectionDetailLevel > SPARSE_UNIT_DETAIL);
LodUtil.assertTrue(sectionPos.sectionDetailLevel <= MAX_SECTION_DETAIL);
@@ -62,7 +62,7 @@ public class SparseDataSource implements IIncompleteDataSource
this.chunkPos = sectionPos.getCorner(SPARSE_UNIT_DETAIL);
this.mapping = new FullDataPointIdMap();
}
protected SparseDataSource(DhSectionPos sectionPos, FullDataPointIdMap mapping, FullArrayView[] data)
protected SparseFullDataSource(DhSectionPos sectionPos, FullDataPointIdMap mapping, FullArrayView[] data)
{
LodUtil.assertTrue(sectionPos.sectionDetailLevel > SPARSE_UNIT_DETAIL);
LodUtil.assertTrue(sectionPos.sectionDetailLevel <= MAX_SECTION_DETAIL);
@@ -104,7 +104,7 @@ public class SparseDataSource implements IIncompleteDataSource
if (data.dataDetail != 0)
{
//TODO: Disable the throw and instead just ignore the data.
throw new IllegalArgumentException("SparseDataSource only supports dataDetail 0!");
throw new IllegalArgumentException("SparseFullDataSource only supports dataDetail 0!");
}
int arrayOffset = this.calculateOffset(data.x, data.z);
@@ -136,7 +136,7 @@ public class SparseDataSource implements IIncompleteDataSource
@Override
public void sampleFrom(ILodDataSource source)
public void sampleFrom(IFullDataSource source)
{
DhSectionPos pos = source.getSectionPos();
LodUtil.assertTrue(pos.sectionDetailLevel < this.sectionPos.sectionDetailLevel);
@@ -144,9 +144,9 @@ public class SparseDataSource implements IIncompleteDataSource
if (source.isEmpty())
return;
if (source instanceof SparseDataSource)
if (source instanceof SparseFullDataSource)
{
this.sampleFrom((SparseDataSource) source);
this.sampleFrom((SparseFullDataSource) source);
}
else if (source instanceof FullDataSource)
{
@@ -158,7 +158,7 @@ public class SparseDataSource implements IIncompleteDataSource
}
}
private void sampleFrom(SparseDataSource sparseSource)
private void sampleFrom(SparseFullDataSource sparseSource)
{
DhSectionPos pos = sparseSource.getSectionPos();
this.isEmpty = false;
@@ -279,7 +279,7 @@ public class SparseDataSource implements IIncompleteDataSource
}
}
public static SparseDataSource loadData(FullDataMetaFile dataFile, InputStream dataStream, IDhLevel level) throws IOException
public static SparseFullDataSource loadData(FullDataMetaFile dataFile, InputStream dataStream, IDhLevel level) throws IOException
{
LodUtil.assertTrue(dataFile.pos.sectionDetailLevel > SPARSE_UNIT_DETAIL);
LodUtil.assertTrue(dataFile.pos.sectionDetailLevel <= MAX_SECTION_DETAIL);
@@ -436,7 +436,7 @@ public class SparseDataSource implements IIncompleteDataSource
}
}
return new SparseDataSource(dataFile.pos, mapping, fullDataArrays);
return new SparseFullDataSource(dataFile.pos, mapping, fullDataArrays);
}
}
}
@@ -461,7 +461,7 @@ public class SparseDataSource implements IIncompleteDataSource
}
}
public ILodDataSource trySelfPromote()
public IFullDataSource trySelfPromote()
{
if (this.isEmpty)
{
@@ -1,7 +1,7 @@
package com.seibel.lod.core.datatype.full;
import com.seibel.lod.core.datatype.AbstractDataSourceLoader;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.file.fullDatafile.FullDataMetaFile;
import com.seibel.lod.core.level.IDhLevel;
@@ -11,11 +11,11 @@ import java.io.InputStream;
public class SpottyDataLoader extends AbstractDataSourceLoader
{
public SpottyDataLoader() {
super(SpottyDataSource.class, SpottyDataSource.TYPE_ID, new byte[]{SpottyDataSource.LATEST_VERSION});
super(SingleChunkFullDataSource.class, SingleChunkFullDataSource.TYPE_ID, new byte[]{ SingleChunkFullDataSource.LATEST_VERSION});
}
@Override
public ILodDataSource loadData(FullDataMetaFile dataFile, InputStream data, IDhLevel level) throws IOException {
return SpottyDataSource.loadData(dataFile, data, level);
public IFullDataSource loadData(FullDataMetaFile dataFile, InputStream data, IDhLevel level) throws IOException {
return SingleChunkFullDataSource.loadData(dataFile, data, level);
}
}
@@ -1,6 +1,6 @@
package com.seibel.lod.core.datatype.transform;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.ILodRenderSource;
import com.seibel.lod.core.datatype.column.ColumnRenderLoader;
import com.seibel.lod.core.datatype.column.ColumnRenderSource;
@@ -16,17 +16,17 @@ public class DataRenderTransformer
public static final ExecutorService TRANSFORMER_THREADS
= LodUtil.makeThreadPool(4, "Data/Render Transformer");
public static CompletableFuture<ILodRenderSource> transformDataSource(ILodDataSource data, IDhClientLevel level)
public static CompletableFuture<ILodRenderSource> transformDataSource(IFullDataSource data, IDhClientLevel level)
{
return CompletableFuture.supplyAsync(() -> transform(data, level), TRANSFORMER_THREADS);
}
public static CompletableFuture<ILodRenderSource> asyncTransformDataSource(CompletableFuture<ILodDataSource> data, IDhClientLevel level)
public static CompletableFuture<ILodRenderSource> asyncTransformDataSource(CompletableFuture<IFullDataSource> data, IDhClientLevel level)
{
return data.thenApplyAsync((d) -> transform(d, level), TRANSFORMER_THREADS);
}
private static ILodRenderSource transform(ILodDataSource dataSource, IDhClientLevel level)
private static ILodRenderSource transform(IFullDataSource dataSource, IDhClientLevel level)
{
if (dataSource == null)
{
@@ -1,6 +1,6 @@
package com.seibel.lod.core.datatype.transform;
import com.seibel.lod.core.datatype.IIncompleteDataSource;
import com.seibel.lod.core.datatype.IIncompleteFullDataSource;
import com.seibel.lod.core.datatype.ILodRenderSource;
import com.seibel.lod.core.datatype.column.accessor.ColumnFormat;
import com.seibel.lod.core.datatype.column.ColumnRenderSource;
@@ -66,7 +66,7 @@ public class FullToColumnTransformer {
return columnSource;
}
public static ILodRenderSource transformIncompleteDataToColumnData(IDhClientLevel level, IIncompleteDataSource data) {
public static ILodRenderSource transformIncompleteDataToColumnData(IDhClientLevel level, IIncompleteFullDataSource data) {
final DhSectionPos pos = data.getSectionPos();
final byte dataDetail = data.getDataDetail();
final int vertSize = Config.Client.Graphics.Quality.verticalQuality.get().calculateMaxVerticalData(data.getDataDetail());
@@ -1,12 +1,12 @@
package com.seibel.lod.core.file.fullDatafile;
import com.google.common.collect.HashMultimap;
import com.seibel.lod.core.datatype.IIncompleteDataSource;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.IIncompleteFullDataSource;
import com.seibel.lod.core.datatype.full.ChunkSizedData;
import com.seibel.lod.core.datatype.full.FullDataSource;
import com.seibel.lod.core.datatype.full.SparseDataSource;
import com.seibel.lod.core.datatype.full.SpottyDataSource;
import com.seibel.lod.core.datatype.full.SingleChunkFullDataSource;
import com.seibel.lod.core.datatype.full.SparseFullDataSource;
import com.seibel.lod.core.file.FileUtil;
import com.seibel.lod.core.file.metaData.MetaData;
import com.seibel.lod.core.level.IDhLevel;
@@ -261,7 +261,7 @@ public class FullDataFileHandler implements IFullDataSourceProvider
* This call is concurrent. I.e. it supports being called by multiple threads at the same time.
*/
@Override
public CompletableFuture<ILodDataSource> read(DhSectionPos pos)
public CompletableFuture<IFullDataSource> read(DhSectionPos pos)
{
this.topDetailLevel.updateAndGet(intVal -> Math.max(intVal, pos.sectionDetailLevel));
FullDataMetaFile metaFile = this.getOrMakeFile(pos);
@@ -272,7 +272,7 @@ public class FullDataFileHandler implements IFullDataSourceProvider
// future wrapper necessary in order to handle file read errors
CompletableFuture<ILodDataSource> futureWrapper = new CompletableFuture<>();
CompletableFuture<IFullDataSource> futureWrapper = new CompletableFuture<>();
metaFile.loadOrGetCachedAsync().exceptionally((e) ->
{
FullDataMetaFile newMetaFile = this.removeCorruptedFile(pos, metaFile, e);
@@ -347,7 +347,7 @@ public class FullDataFileHandler implements IFullDataSourceProvider
}
@Override
public CompletableFuture<ILodDataSource> onCreateDataFile(FullDataMetaFile file)
public CompletableFuture<IFullDataSource> onCreateDataFile(FullDataMetaFile file)
{
DhSectionPos pos = file.pos;
ArrayList<FullDataMetaFile> existFiles = new ArrayList<>();
@@ -357,8 +357,8 @@ public class FullDataFileHandler implements IFullDataSourceProvider
if (missing.size() == 1 && existFiles.isEmpty() && missing.get(0).equals(pos))
{
// None exist.
IIncompleteDataSource incompleteDataSource = pos.sectionDetailLevel <= SparseDataSource.MAX_SECTION_DETAIL ?
SparseDataSource.createEmpty(pos) : SpottyDataSource.createEmpty(pos);
IIncompleteFullDataSource incompleteDataSource = pos.sectionDetailLevel <= SparseFullDataSource.MAX_SECTION_DETAIL ?
SparseFullDataSource.createEmpty(pos) : SingleChunkFullDataSource.createEmpty(pos);
return CompletableFuture.completedFuture(incompleteDataSource);
}
else
@@ -372,9 +372,9 @@ public class FullDataFileHandler implements IFullDataSourceProvider
}
}
final ArrayList<CompletableFuture<Void>> futures = new ArrayList<>(existFiles.size());
final IIncompleteDataSource dataSource = pos.sectionDetailLevel <= SparseDataSource.MAX_SECTION_DETAIL ?
SparseDataSource.createEmpty(pos) :
SpottyDataSource.createEmpty(pos);
final IIncompleteFullDataSource dataSource = pos.sectionDetailLevel <= SparseFullDataSource.MAX_SECTION_DETAIL ?
SparseFullDataSource.createEmpty(pos) :
SingleChunkFullDataSource.createEmpty(pos);
for (FullDataMetaFile metaFile : existFiles)
{
@@ -411,8 +411,8 @@ public class FullDataFileHandler implements IFullDataSourceProvider
}
@Override
public ILodDataSource onDataFileLoaded(ILodDataSource source, MetaData metaData,
Consumer<ILodDataSource> onUpdated, Function<ILodDataSource, Boolean> updater)
public IFullDataSource onDataFileLoaded(IFullDataSource source, MetaData metaData,
Consumer<IFullDataSource> onUpdated, Function<IFullDataSource, Boolean> updater)
{
boolean changed = updater.apply(source);
if (changed)
@@ -420,9 +420,9 @@ public class FullDataFileHandler implements IFullDataSourceProvider
metaData.dataVersion.incrementAndGet();
}
if (source instanceof IIncompleteDataSource)
if (source instanceof IIncompleteFullDataSource)
{
ILodDataSource newSource = ((IIncompleteDataSource) source).trySelfPromote();
IFullDataSource newSource = ((IIncompleteFullDataSource) source).trySelfPromote();
changed |= newSource != source;
source = newSource;
}
@@ -434,16 +434,16 @@ public class FullDataFileHandler implements IFullDataSourceProvider
return source;
}
@Override
public CompletableFuture<ILodDataSource> onDataFileRefresh(ILodDataSource source, MetaData metaData, Function<ILodDataSource, Boolean> updater, Consumer<ILodDataSource> onUpdated)
public CompletableFuture<IFullDataSource> onDataFileRefresh(IFullDataSource source, MetaData metaData, Function<IFullDataSource, Boolean> updater, Consumer<IFullDataSource> onUpdated)
{
return CompletableFuture.supplyAsync(() ->
{
ILodDataSource sourceLocal = source;
IFullDataSource sourceLocal = source;
boolean changed = updater.apply(sourceLocal);
if (changed) metaData.dataVersion.incrementAndGet();
if (sourceLocal instanceof IIncompleteDataSource)
if (sourceLocal instanceof IIncompleteFullDataSource)
{
ILodDataSource newSource = ((IIncompleteDataSource) sourceLocal).trySelfPromote();
IFullDataSource newSource = ((IIncompleteFullDataSource) sourceLocal).trySelfPromote();
changed |= newSource != sourceLocal;
sourceLocal = newSource;
}
@@ -8,7 +8,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.AbstractDataSourceLoader;
import com.seibel.lod.core.datatype.full.ChunkSizedData;
import com.seibel.lod.core.file.metaData.MetaData;
@@ -33,7 +33,7 @@ public class FullDataMetaFile extends AbstractMetaDataFile
private boolean doesFileExist;
public AbstractDataSourceLoader loader;
public Class<? extends ILodDataSource> dataType;
public Class<? extends IFullDataSource> dataType;
// The '?' type should either be:
// SoftReference<LodDataSource>, or - Non-dirty file that can be GCed
// CompletableFuture<LodDataSource>, or - File that is being loaded. No guarantee that the type is promotable or not
@@ -52,16 +52,16 @@ public class FullDataMetaFile extends AbstractMetaDataFile
GuardedMultiAppendQueue _backQueue = new GuardedMultiAppendQueue();
// ===========================
private AtomicReference<CompletableFuture<ILodDataSource>> inCacheWriteAccessFuture = new AtomicReference<>(null);
private AtomicReference<CompletableFuture<IFullDataSource>> inCacheWriteAccessFuture = new AtomicReference<>(null);
// ===Object lifetime stuff===
private static final ReferenceQueue<ILodDataSource> lifeCycleDebugQueue = new ReferenceQueue<>();
private static final ReferenceQueue<IFullDataSource> lifeCycleDebugQueue = new ReferenceQueue<>();
private static final Set<DataObjTracker> lifeCycleDebugSet = ConcurrentHashMap.newKeySet();
private static class DataObjTracker extends PhantomReference<ILodDataSource> implements Closeable
private static class DataObjTracker extends PhantomReference<IFullDataSource> implements Closeable
{
private final DhSectionPos pos;
DataObjTracker(ILodDataSource data)
DataObjTracker(IFullDataSource data)
{
super(data, lifeCycleDebugQueue);
//LOGGER.info("Phantom created on {}! count: {}", data.getSectionPos(), lifeCycleDebugSet.size());
@@ -150,18 +150,18 @@ public class FullDataMetaFile extends AbstractMetaDataFile
// Cause: Generic Type runtime casting cannot safety check it.
// However, the Union type ensures the 'data' should only contain the listed type.
public CompletableFuture<ILodDataSource> loadOrGetCachedAsync()
public CompletableFuture<IFullDataSource> loadOrGetCachedAsync()
{
debugCheck();
Object obj = this.data.get();
CompletableFuture<ILodDataSource> cached = this._readCachedAsync(obj);
CompletableFuture<IFullDataSource> cached = this._readCachedAsync(obj);
if (cached != null)
{
return cached;
}
CompletableFuture<ILodDataSource> future = new CompletableFuture<>();
CompletableFuture<IFullDataSource> future = new CompletableFuture<>();
// Would use faster and non-nesting Compare and exchange. But java 8 doesn't have it! :(
boolean worked = this.data.compareAndSet(obj, future); // TODO obj and future are different object types, would this ever return true?
@@ -206,7 +206,7 @@ public class FullDataMetaFile extends AbstractMetaDataFile
}
// Load the file.
ILodDataSource data;
IFullDataSource data;
try (FileInputStream fio = this.getDataContent())
{
data = this.loader.loadData(this, fio, this.level);
@@ -246,7 +246,7 @@ public class FullDataMetaFile extends AbstractMetaDataFile
return future;
}
private static MetaData makeMetaData(ILodDataSource data) {
private static MetaData makeMetaData(IFullDataSource data) {
AbstractDataSourceLoader loader = AbstractDataSourceLoader.getLoader(data.getClass(), data.getDataVersion());
return new MetaData(data.getSectionPos(), -1, 1,
data.getDataDetail(), loader == null ? 0 : loader.datatypeId, data.getDataVersion());
@@ -255,24 +255,24 @@ public class FullDataMetaFile extends AbstractMetaDataFile
// "unchecked": Suppress casting of CompletableFuture<?> to CompletableFuture<LodDataSource>
// "PointlessBooleanExpression": Suppress explicit (boolean == false) check for more understandable CAS operation code.
@SuppressWarnings({"unchecked"})
private CompletableFuture<ILodDataSource> _readCachedAsync(Object obj) {
private CompletableFuture<IFullDataSource> _readCachedAsync(Object obj) {
// Has file cached in RAM and not freed yet.
if ((obj instanceof SoftReference<?>)) {
Object inner = ((SoftReference<?>)obj).get();
if (inner != null) {
LodUtil.assertTrue(inner instanceof ILodDataSource);
LodUtil.assertTrue(inner instanceof IFullDataSource);
boolean isEmpty = writeQueue.get().queue.isEmpty();
// If the queue is empty, and the CAS on inCacheWriteLock succeeds, then we are the thread
// that will be applying the changes to the cache.
if (!isEmpty) {
// Do a CAS on inCacheWriteLock to ensure that we are the only thread that is writing to the cache,
// or if we fail, then that means someone else is already doing it, and we can just return the future
CompletableFuture<ILodDataSource> future = new CompletableFuture<>();
CompletableFuture<ILodDataSource> cas = AtomicsUtil.compareAndExchange(inCacheWriteAccessFuture, null, future);
CompletableFuture<IFullDataSource> future = new CompletableFuture<>();
CompletableFuture<IFullDataSource> cas = AtomicsUtil.compareAndExchange(inCacheWriteAccessFuture, null, future);
if (cas == null) {
try {
data.set(future);
handler.onDataFileRefresh((ILodDataSource) inner, metaData, this::applyWriteQueue, this::saveChanges).handle((v, e) -> {
handler.onDataFileRefresh((IFullDataSource) inner, metaData, this::applyWriteQueue, this::saveChanges).handle((v, e) -> {
if (e != null) {
LOGGER.error("Error refreshing data {}: ", pos, e);
future.complete(null);
@@ -288,7 +288,7 @@ public class FullDataMetaFile extends AbstractMetaDataFile
return future;
} catch (Exception e) {
LOGGER.error("Error while doing refreshes to LodDataSource at {}: ", pos, e);
return CompletableFuture.completedFuture((ILodDataSource) inner);
return CompletableFuture.completedFuture((IFullDataSource) inner);
}
} else {
// or, return the future that will be completed when the write is done.
@@ -296,7 +296,7 @@ public class FullDataMetaFile extends AbstractMetaDataFile
}
} else {
// or, return the cached data.
return CompletableFuture.completedFuture((ILodDataSource) inner);
return CompletableFuture.completedFuture((IFullDataSource) inner);
}
}
}
@@ -304,7 +304,7 @@ public class FullDataMetaFile extends AbstractMetaDataFile
//==== Cached file out of scrope. ====
// Someone is already trying to complete it. so just return the obj.
if ((obj instanceof CompletableFuture<?>)) {
return (CompletableFuture<ILodDataSource>)obj;
return (CompletableFuture<IFullDataSource>)obj;
}
return null;
}
@@ -321,14 +321,22 @@ public class FullDataMetaFile extends AbstractMetaDataFile
queue.appendLock.writeLock().unlock();
_backQueue = queue;
}
private void saveChanges(ILodDataSource data) {
if (data.isEmpty()) {
if (path.exists()) if (!path.delete()) LOGGER.warn("Failed to delete data file at {}", path);
private void saveChanges(IFullDataSource data)
{
if (data.isEmpty())
{
if (path.exists() && !path.delete())
{
LOGGER.warn("Failed to delete data file at {}", path);
}
doesFileExist = false;
} else {
LOGGER.info("Saving data file of {}", data.getSectionPos());
try {
}
else
{
//LOGGER.info("Saving data file of {}", data.getSectionPos());
try
{
// Write/Update data
LodUtil.assertTrue(metaData != null);
metaData.dataLevel = data.getDataDetail();
@@ -339,22 +347,27 @@ public class FullDataMetaFile extends AbstractMetaDataFile
metaData.loaderVersion = data.getDataVersion();
super.writeData((out) -> data.saveData(level, this, out));
doesFileExist = true;
} catch (IOException e) {
}
catch (IOException e)
{
LOGGER.error("Failed to save updated data file at {} for sect {}", path, pos, e);
}
}
}
// Return whether any write has happened to the data
private boolean applyWriteQueue(ILodDataSource data) {
private boolean applyWriteQueue(IFullDataSource data)
{
// Poll the write queue
// First check if write queue is empty, then swap the write queue.
// Must be done in this order to ensure isMemoryAddressValid work properly. See isMemoryAddressValid() for details.
boolean isEmpty = writeQueue.get().queue.isEmpty();
if (!isEmpty) {
if (!isEmpty)
{
swapWriteQueue();
int count = _backQueue.queue.size();
for (ChunkSizedData chunk : _backQueue.queue) {
for (ChunkSizedData chunk : _backQueue.queue)
{
data.update(chunk);
}
_backQueue.queue.clear();
@@ -1,10 +1,10 @@
package com.seibel.lod.core.file.fullDatafile;
import com.seibel.lod.core.datatype.IIncompleteDataSource;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.IIncompleteFullDataSource;
import com.seibel.lod.core.datatype.full.ChunkSizedData;
import com.seibel.lod.core.datatype.full.SparseDataSource;
import com.seibel.lod.core.datatype.full.SpottyDataSource;
import com.seibel.lod.core.datatype.full.SparseFullDataSource;
import com.seibel.lod.core.datatype.full.SingleChunkFullDataSource;
import com.seibel.lod.core.generation.tasks.AbstractWorldGenTaskTracker;
import com.seibel.lod.core.generation.WorldGenerationQueue;
import com.seibel.lod.core.level.IDhServerLevel;
@@ -44,7 +44,7 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler
@Override
public CompletableFuture<ILodDataSource> onCreateDataFile(FullDataMetaFile file)
public CompletableFuture<IFullDataSource> onCreateDataFile(FullDataMetaFile file)
{
DhSectionPos pos = file.pos;
@@ -56,9 +56,9 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler
LodUtil.assertTrue(!missingPositions.isEmpty() || !existingFiles.isEmpty());
// determine the type of dataSource that should be used for this position
IIncompleteDataSource dataSource = pos.sectionDetailLevel <= SparseDataSource.MAX_SECTION_DETAIL ?
SparseDataSource.createEmpty(pos) :
SpottyDataSource.createEmpty(pos);
IIncompleteFullDataSource dataSource = pos.sectionDetailLevel <= SparseFullDataSource.MAX_SECTION_DETAIL ?
SparseFullDataSource.createEmpty(pos) :
SingleChunkFullDataSource.createEmpty(pos);
if (missingPositions.size() == 1 && existingFiles.isEmpty() && missingPositions.get(0).equals(pos))
@@ -141,12 +141,12 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler
class GenTask extends AbstractWorldGenTaskTracker
{
private final DhSectionPos pos;
private final WeakReference<ILodDataSource> targetData;
private ILodDataSource loadedTargetData = null;
private final WeakReference<IFullDataSource> targetData;
private IFullDataSource loadedTargetData = null;
GenTask(DhSectionPos pos, WeakReference<ILodDataSource> targetData)
GenTask(DhSectionPos pos, WeakReference<IFullDataSource> targetData)
{
this.pos = pos;
this.targetData = targetData;
@@ -1,6 +1,6 @@
package com.seibel.lod.core.file.fullDatafile;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.full.ChunkSizedData;
import com.seibel.lod.core.file.metaData.MetaData;
import com.seibel.lod.core.pos.DhSectionPos;
@@ -15,16 +15,16 @@ import java.util.function.Function;
public interface IFullDataSourceProvider extends AutoCloseable {
void addScannedFile(Collection<File> detectedFiles);
CompletableFuture<ILodDataSource> read(DhSectionPos pos);
CompletableFuture<IFullDataSource> read(DhSectionPos pos);
void write(DhSectionPos sectionPos, ChunkSizedData chunkData);
CompletableFuture<Void> flushAndSave();
long getCacheVersion(DhSectionPos sectionPos);
boolean isCacheVersionValid(DhSectionPos sectionPos, long cacheVersion);
CompletableFuture<ILodDataSource> onCreateDataFile(FullDataMetaFile file);
ILodDataSource onDataFileLoaded(ILodDataSource source, MetaData metaData, Consumer<ILodDataSource> onUpdated, Function<ILodDataSource, Boolean> updater);
CompletableFuture<ILodDataSource> onDataFileRefresh(ILodDataSource source, MetaData metaData, Function<ILodDataSource, Boolean> updater, Consumer<ILodDataSource> onUpdated);
CompletableFuture<IFullDataSource> onCreateDataFile(FullDataMetaFile file);
IFullDataSource onDataFileLoaded(IFullDataSource source, MetaData metaData, Consumer<IFullDataSource> onUpdated, Function<IFullDataSource, Boolean> updater);
CompletableFuture<IFullDataSource> onDataFileRefresh(IFullDataSource source, MetaData metaData, Function<IFullDataSource, Boolean> updater, Consumer<IFullDataSource> onUpdated);
File computeDataFilePath(DhSectionPos pos);
Executor getIOExecutor();
@@ -1,7 +1,7 @@
package com.seibel.lod.core.file.renderfile;
import com.google.common.collect.HashMultimap;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.PlaceHolderRenderSource;
import com.seibel.lod.core.datatype.ILodRenderSource;
import com.seibel.lod.core.datatype.AbstractRenderSourceLoader;
@@ -279,8 +279,8 @@ public class RenderFileHandler implements ILodRenderSourceProvider
}
final WeakReference<ILodRenderSource> dataRef = new WeakReference<>(data);
CompletableFuture<ILodDataSource> dataFuture = this.dataSourceProvider.read(data.getSectionPos());
dataFuture = dataFuture.thenApply((dataSource) ->
CompletableFuture<IFullDataSource> fullDataSourceFuture = this.dataSourceProvider.read(data.getSectionPos());
fullDataSourceFuture = fullDataSourceFuture.thenApply((dataSource) ->
{
if (dataRef.get() == null)
{
@@ -295,7 +295,7 @@ public class RenderFileHandler implements ILodRenderSourceProvider
});
LOGGER.info("Recreating cache for {}", data.getSectionPos());
DataRenderTransformer.asyncTransformDataSource(dataFuture, this.level)
DataRenderTransformer.asyncTransformDataSource(fullDataSourceFuture, this.level)
.thenAccept((newRenderDataSource) -> this.write(dataRef.get(), file, newRenderDataSource, this.dataSourceProvider.getCacheVersion(data.getSectionPos())))
.exceptionally((ex) ->
{
@@ -41,7 +41,7 @@ public class RenderMetaDataFile extends AbstractMetaDataFile
// @FunctionalInterface
// public interface CacheSourceProducer
// {
// CompletableFuture<ILodDataSource> getSourceFuture(DhSectionPos sectionPos);
// CompletableFuture<IFullDataSource> getSourceFuture(DhSectionPos sectionPos);
// }
// CacheValidator validator;
// CacheSourceProducer source;
@@ -1,7 +1,7 @@
package com.seibel.lod.core.file.subDimMatching;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.datatype.full.ChunkSizedData;
import com.seibel.lod.core.datatype.full.FullDataPoint;
import com.seibel.lod.core.datatype.full.accessor.SingleFullArrayView;
@@ -221,8 +221,8 @@ public class SubDimensionLevelMatcher implements AutoCloseable
}
IDhLevel tempLevel = new DhClientLevel(new ClientOnlySaveStructure(), clientLevelWrapper);
IFullDataSourceProvider fileHandler = new FullDataFileHandler(tempLevel, testLevelFolder);
CompletableFuture<ILodDataSource> testDataSource = fileHandler.read(new DhSectionPos(playerChunkPos));
ILodDataSource lodDataSource = testDataSource.get();
CompletableFuture<IFullDataSource> testDataSource = fileHandler.read(new DhSectionPos(playerChunkPos));
IFullDataSource lodDataSource = testDataSource.get();
// convert the data source into a raw LOD data array
@@ -1,6 +1,6 @@
package com.seibel.lod.core.pos;
import com.seibel.lod.core.datatype.ILodDataSource;
import com.seibel.lod.core.datatype.IFullDataSource;
import com.seibel.lod.core.util.BitShiftUtil;
import com.seibel.lod.core.util.LodUtil;
import org.jetbrains.annotations.NotNull;
@@ -91,7 +91,7 @@ public class DhLodPos implements Comparable<DhLodPos>
public DhLodPos getDhSectionRelativePositionForDetailLevel() throws IllegalArgumentException { return this.getDhSectionRelativePositionForDetailLevel(this.detailLevel); }
/**
* Returns a DhLodPos with the given detail level and an X/Z position somewhere between (0,0) and (63,63).
* This is done to access specific sections from a {@link ILodDataSource} where LOD columns are stored
* This is done to access specific sections from a {@link IFullDataSource} where LOD columns are stored
* in 64 x 64 blocks.
*
* @throws IllegalArgumentException if this position's detail level is lower than the output detail level