Rename CompleteFullDataSource -> FullDataSourceV1

This commit is contained in:
James Seibel
2024-03-16 19:40:36 -05:00
parent 4ec1dea1ba
commit 98183a4e75
7 changed files with 45 additions and 38 deletions
@@ -38,11 +38,12 @@ import java.io.*;
import java.util.Arrays;
/**
* This data source contains every datapoint over its given {@link DhSectionPos}.
* Formerly "CompleteFullDataSource". <br>
* Should be fully populated, containing 1 data point for each column.
*
* @see FullDataPointUtilV1
*/
public class CompleteFullDataSource implements IDataSource<IDhLevel>
public class FullDataSourceV1 implements IDataSource<IDhLevel>
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
@@ -80,8 +81,8 @@ public class CompleteFullDataSource implements IDataSource<IDhLevel>
// constructors //
//==============//
public static CompleteFullDataSource createEmpty(DhSectionPos pos) { return new CompleteFullDataSource(pos); }
private CompleteFullDataSource(DhSectionPos sectionPos)
public static FullDataSourceV1 createEmpty(DhSectionPos pos) { return new FullDataSourceV1(pos); }
private FullDataSourceV1(DhSectionPos sectionPos)
{
this.dataArrays = new long[WIDTH * WIDTH][0];
this.mapping = new FullDataPointIdMap(sectionPos);
@@ -154,7 +155,7 @@ public class CompleteFullDataSource implements IDataSource<IDhLevel>
/**
* Clears and then overwrites any data in this object with the data from the given file and stream.
* This is expected to be used with an existing {@link CompleteFullDataSource} and can be used in place of a constructor to reuse an existing {@link CompleteFullDataSource} object.
* This is expected to be used with an existing {@link FullDataSourceV1} and can be used in place of a constructor to reuse an existing {@link FullDataSourceV1} object.
*/
public void repopulateFromStream(LegacyDataSourceDTO dto, DhDataInputStream inputStream, IDhLevel level) throws IOException, InterruptedException
{
@@ -168,7 +169,7 @@ public class CompleteFullDataSource implements IDataSource<IDhLevel>
/**
* Overwrites any data in this object with the data from the given file and stream.
* This is expected to be used with an empty {@link CompleteFullDataSource} and functions similar to a constructor.
* This is expected to be used with an empty {@link FullDataSourceV1} and functions similar to a constructor.
*/
public void populateFromStream(LegacyDataSourceDTO dto, DhDataInputStream inputStream, IDhLevel level) throws IOException, InterruptedException
{
@@ -48,7 +48,7 @@ import java.util.concurrent.locks.ReentrantLock;
* that can be pooled to reduce GC overhead
*
* @see FullDataPointUtil
* @see CompleteFullDataSource
* @see FullDataSourceV1
*/
public class NewFullDataSource implements IDataSource<IDhLevel>
{
@@ -128,14 +128,14 @@ public class NewFullDataSource implements IDataSource<IDhLevel>
public static NewFullDataSource createFromChunk(IChunkWrapper chunkWrapper) { return LodDataBuilder.createGeneratedDataSource(chunkWrapper); }
public static NewFullDataSource createFromCompleteDataSource(CompleteFullDataSource legacyData)
public static NewFullDataSource createFromCompleteDataSource(FullDataSourceV1 legacyData)
{
if (CompleteFullDataSource.WIDTH != WIDTH)
if (FullDataSourceV1.WIDTH != WIDTH)
{
throw new UnsupportedOperationException(
"Unable to convert CompleteFullDataSource into NewFullDataSource. " +
"Data sources have different data point widths and no converter is present. " +
"CompleteFullDataSource width ["+CompleteFullDataSource.WIDTH+"], NewFullDataSource width ["+WIDTH+"].");
"CompleteFullDataSource width ["+ FullDataSourceV1.WIDTH+"], NewFullDataSource width ["+WIDTH+"].");
}
@@ -780,12 +780,12 @@ public class NewFullDataSource implements IDataSource<IDhLevel>
private static class Pooling
{
/** used when pooling data sources */
private final ArrayList<CompleteFullDataSource> cachedSources = new ArrayList<>();
private final ArrayList<FullDataSourceV1> cachedSources = new ArrayList<>();
private final ReentrantLock cacheLock = new ReentrantLock();
/** @return null if no pooled source exists */
public CompleteFullDataSource tryGetPooledSource()
public FullDataSourceV1 tryGetPooledSource()
{
try
{
@@ -811,7 +811,7 @@ public class NewFullDataSource implements IDataSource<IDhLevel>
* Doesn't have to be called, if a data source isn't returned, nothing will be leaked.
* It just means a new source must be constructed next time {@link Pooling#tryGetPooledSource} is called.
*/
public void returnPooledDataSource(CompleteFullDataSource dataSource)
public void returnPooledDataSource(FullDataSourceV1 dataSource)
{
if (dataSource == null)
{
@@ -19,7 +19,7 @@
package com.seibel.distanthorizons.core.file.fullDatafile;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV1;
import com.seibel.distanthorizons.core.file.AbstractLegacyDataSourceHandler;
import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure;
import com.seibel.distanthorizons.core.level.IDhLevel;
@@ -36,8 +36,7 @@ import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
public class LegacyFullDataFileHandler
extends AbstractLegacyDataSourceHandler<CompleteFullDataSource, IDhLevel>
public class FullDataFileHandlerV1 extends AbstractLegacyDataSourceHandler<FullDataSourceV1, IDhLevel>
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
@@ -47,7 +46,7 @@ public class LegacyFullDataFileHandler
// constructor //
//=============//
public LegacyFullDataFileHandler(IDhLevel level, AbstractSaveStructure saveStructure, @Nullable File saveDirOverride)
public FullDataFileHandlerV1(IDhLevel level, AbstractSaveStructure saveStructure, @Nullable File saveDirOverride)
{
super(level, saveStructure, saveDirOverride);
}
@@ -74,21 +73,20 @@ public class LegacyFullDataFileHandler
}
@Override
protected CompleteFullDataSource createDataSourceFromDto(LegacyDataSourceDTO dto) throws InterruptedException, IOException
protected FullDataSourceV1 createDataSourceFromDto(LegacyDataSourceDTO dto) throws InterruptedException, IOException
{
CompleteFullDataSource dataSource = CompleteFullDataSource.createEmpty(dto.pos);
FullDataSourceV1 dataSource = FullDataSourceV1.createEmpty(dto.pos);
dataSource.populateFromStream(dto, dto.getInputStream(), this.level);
return dataSource;
}
/** Creates a new data source using any DTOs already present in the database. */
@Deprecated
@Override
protected CompleteFullDataSource createNewDataSourceFromExistingDtos(DhSectionPos pos) { return null; }
protected FullDataSourceV1 createNewDataSourceFromExistingDtos(DhSectionPos pos) { return null; }
@Deprecated
@Override
protected CompleteFullDataSource makeEmptyDataSource(DhSectionPos pos) { return null; }
protected FullDataSourceV1 makeEmptyDataSource(DhSectionPos pos) { return null; }
@@ -98,7 +96,7 @@ public class LegacyFullDataFileHandler
@Deprecated
@Override
public void writeDataSourceToFile(CompleteFullDataSource fullDataSource) throws IOException
public void writeDataSourceToFile(FullDataSourceV1 fullDataSource) throws IOException
{ throw new UnsupportedOperationException("Deprecated"); }
@@ -109,15 +107,15 @@ public class LegacyFullDataFileHandler
public int getDataSourceMigrationCount() { return ((LegacyFullDataRepo) this.repo).getMigrationCount(); }
public ArrayList<CompleteFullDataSource> getDataSourcesToMigrate(int limit)
public ArrayList<FullDataSourceV1> getDataSourcesToMigrate(int limit)
{
ArrayList<CompleteFullDataSource> dataSourceList = new ArrayList<>();
ArrayList<FullDataSourceV1> dataSourceList = new ArrayList<>();
ArrayList<DhSectionPos> migrationPosList = ((LegacyFullDataRepo) this.repo).getPositionsToMigrate(limit);
for (int i = 0; i < migrationPosList.size(); i++)
{
DhSectionPos pos = migrationPosList.get(i);
CompleteFullDataSource dataSource = this.get(pos);
FullDataSourceV1 dataSource = this.get(pos);
if (dataSource != null)
{
dataSourceList.add(dataSource);
@@ -21,7 +21,7 @@ package com.seibel.distanthorizons.core.file.fullDatafile;
import com.seibel.distanthorizons.api.enums.config.EDhApiDataCompressionMode;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV1;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource;
import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure;
import com.seibel.distanthorizons.core.file.AbstractNewDataSourceHandler;
@@ -72,7 +72,7 @@ public class NewFullDataFileHandler
* vs gracefully shutting down the thread ourselves.
*/
protected final AtomicBoolean migrationThreadRunning = new AtomicBoolean(true);
protected final LegacyFullDataFileHandler legacyFileHandler;
protected final FullDataFileHandlerV1 legacyFileHandler;
/**
* Tracks which positions are currently being updated
@@ -97,7 +97,7 @@ public class NewFullDataFileHandler
public NewFullDataFileHandler(IDhLevel level, AbstractSaveStructure saveStructure, @Nullable File saveDirOverride)
{
super(level, saveStructure, saveDirOverride);
this.legacyFileHandler = new LegacyFullDataFileHandler(level, saveStructure, saveDirOverride);
this.legacyFileHandler = new FullDataFileHandlerV1(level, saveStructure, saveDirOverride);
DebugRenderer.register(this, Config.Client.Advanced.Debugging.DebugWireframe.showFullDataUpdateStatus);
@@ -315,7 +315,7 @@ public class NewFullDataFileHandler
LOGGER.info("Found ["+totalCount+"] data sources that need migration.");
ArrayList<CompleteFullDataSource> legacyDataSourceList = this.legacyFileHandler.getDataSourcesToMigrate(MIGRATION_BATCH_COUNT);
ArrayList<FullDataSourceV1> legacyDataSourceList = this.legacyFileHandler.getDataSourcesToMigrate(MIGRATION_BATCH_COUNT);
if (!legacyDataSourceList.isEmpty())
{
// keep going until every data source has been migrated
@@ -327,7 +327,7 @@ public class NewFullDataFileHandler
ArrayList<CompletableFuture<Void>> updateFutureList = new ArrayList<>();
for (int i = 0; i < legacyDataSourceList.size() && this.migrationThreadRunning.get(); i++)
{
CompleteFullDataSource legacyDataSource = legacyDataSourceList.get(i);
FullDataSourceV1 legacyDataSource = legacyDataSourceList.get(i);
try
{
@@ -21,7 +21,7 @@ package com.seibel.distanthorizons.core.file.subDimMatching;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV1;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
@@ -229,9 +229,9 @@ public class SubDimensionLevelMatcher implements AutoCloseable
// compare the data sources
int equalDataPoints = 0;
int totalDataPointCount = 0;
for (int x = 0; x < CompleteFullDataSource.WIDTH; x++)
for (int x = 0; x < FullDataSourceV1.WIDTH; x++)
{
for (int z = 0; z < CompleteFullDataSource.WIDTH; z++)
for (int z = 0; z < FullDataSourceV1.WIDTH; z++)
{
long[] newColumn = newDataSource.get(x, z);
long[] testColumn = testFullDataSource.get(x, z);
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.core.sql.dto;
import com.seibel.distanthorizons.api.enums.config.EDhApiDataCompressionMode;
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV1;
import com.seibel.distanthorizons.core.dataObjects.render.ColumnRenderSource;
import com.seibel.distanthorizons.core.pos.DhSectionPos;
import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataInputStream;
@@ -30,7 +31,14 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicLong;
/** handles storing {@link ColumnRenderSource}'s in the database. */
/**
* Handles storing {@link ColumnRenderSource}'s and {@link FullDataSourceV1}'s in the database.
*
* @deprecated {@link ColumnRenderSource} should store the actual GPU buffer data,
* at that point this DTO should be just used for {@link FullDataSourceV1}
* and could be renamed to FullDataSourceV1DTO
*/
@Deprecated
public class LegacyDataSourceDTO implements IBaseDTO<DhSectionPos>
{
public DhSectionPos pos;
@@ -1,13 +1,13 @@
package com.seibel.distanthorizons.core.util;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV1;
/**
* <strong> Only for Legacy support </strong> <br>
* Used by DH versions 2.0.0 and 2.0.1. <br><br>
*
* Specifically used by the data sources: <br>
* - {@link CompleteFullDataSource} aka CompleteFullDataSource <br>
* - {@link FullDataSourceV1} aka CompleteFullDataSource <br>
* - (Deleted) HighDetailIncompleteFullDataSource <br>
* - (Deleted) LowDetailIncompleteFullDataSource <br><br>
*
@@ -30,7 +30,7 @@ import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFull
* ID ID ID ID ID ID ID ID <-- Bottom bits <br>
* </code>
*
* @see CompleteFullDataSource
* @see FullDataSourceV1
* @see FullDataPointUtil
*/
public class FullDataPointUtilV1