From 98183a4e7584f2533c5f35baae3b64c4a076fb8d Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 16 Mar 2024 19:40:36 -0500 Subject: [PATCH] Rename CompleteFullDataSource -> FullDataSourceV1 --- ...lDataSource.java => FullDataSourceV1.java} | 13 +++++----- .../fullData/sources/NewFullDataSource.java | 14 +++++------ ...andler.java => FullDataFileHandlerV1.java} | 24 +++++++++---------- .../fullDatafile/NewFullDataFileHandler.java | 10 ++++---- .../SubDimensionLevelMatcher.java | 6 ++--- .../core/sql/dto/LegacyDataSourceDTO.java | 10 +++++++- .../core/util/FullDataPointUtilV1.java | 6 ++--- 7 files changed, 45 insertions(+), 38 deletions(-) rename core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/{CompleteFullDataSource.java => FullDataSourceV1.java} (95%) rename core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/{LegacyFullDataFileHandler.java => FullDataFileHandlerV1.java} (77%) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/CompleteFullDataSource.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV1.java similarity index 95% rename from core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/CompleteFullDataSource.java rename to core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV1.java index 8b691279b..f15ae49a6 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/CompleteFullDataSource.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV1.java @@ -38,11 +38,12 @@ import java.io.*; import java.util.Arrays; /** - * This data source contains every datapoint over its given {@link DhSectionPos}. + * Formerly "CompleteFullDataSource".
+ * Should be fully populated, containing 1 data point for each column. * * @see FullDataPointUtilV1 */ -public class CompleteFullDataSource implements IDataSource +public class FullDataSourceV1 implements IDataSource { private static final Logger LOGGER = DhLoggerBuilder.getLogger(); @@ -80,8 +81,8 @@ public class CompleteFullDataSource implements IDataSource // 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 /** * 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 /** * 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 { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/NewFullDataSource.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/NewFullDataSource.java index 4c529157d..4227ed3d1 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/NewFullDataSource.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/NewFullDataSource.java @@ -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 { @@ -128,14 +128,14 @@ public class NewFullDataSource implements IDataSource 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 private static class Pooling { /** used when pooling data sources */ - private final ArrayList cachedSources = new ArrayList<>(); + private final ArrayList 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 * 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) { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/LegacyFullDataFileHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataFileHandlerV1.java similarity index 77% rename from core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/LegacyFullDataFileHandler.java rename to core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataFileHandlerV1.java index c95eeade1..441364b9d 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/LegacyFullDataFileHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataFileHandlerV1.java @@ -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 +public class FullDataFileHandlerV1 extends AbstractLegacyDataSourceHandler { 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 getDataSourcesToMigrate(int limit) + public ArrayList getDataSourcesToMigrate(int limit) { - ArrayList dataSourceList = new ArrayList<>(); + ArrayList dataSourceList = new ArrayList<>(); ArrayList 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); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/NewFullDataFileHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/NewFullDataFileHandler.java index 4c1dc582e..43e5bf85e 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/NewFullDataFileHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/NewFullDataFileHandler.java @@ -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 legacyDataSourceList = this.legacyFileHandler.getDataSourcesToMigrate(MIGRATION_BATCH_COUNT); + ArrayList 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> 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 { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/subDimMatching/SubDimensionLevelMatcher.java b/core/src/main/java/com/seibel/distanthorizons/core/file/subDimMatching/SubDimensionLevelMatcher.java index 3ed6b977e..61ceaed91 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/subDimMatching/SubDimensionLevelMatcher.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/subDimMatching/SubDimensionLevelMatcher.java @@ -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); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/LegacyDataSourceDTO.java b/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/LegacyDataSourceDTO.java index f68869e49..e89a3c7c7 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/LegacyDataSourceDTO.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/LegacyDataSourceDTO.java @@ -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 { public DhSectionPos pos; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV1.java b/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV1.java index aa40ee8a3..d6b4274bd 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV1.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV1.java @@ -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; /** * Only for Legacy support
* Used by DH versions 2.0.0 and 2.0.1.

* * Specifically used by the data sources:
- * - {@link CompleteFullDataSource} aka CompleteFullDataSource
+ * - {@link FullDataSourceV1} aka CompleteFullDataSource
* - (Deleted) HighDetailIncompleteFullDataSource
* - (Deleted) LowDetailIncompleteFullDataSource

* @@ -30,7 +30,7 @@ import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFull * ID ID ID ID ID ID ID ID <-- Bottom bits
* * - * @see CompleteFullDataSource + * @see FullDataSourceV1 * @see FullDataPointUtil */ public class FullDataPointUtilV1