remove IDataSource
This commit is contained in:
+1
-2
@@ -49,7 +49,6 @@ import com.seibel.distanthorizons.coreapi.util.BitShiftUtil;
|
||||
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
||||
import com.seibel.distanthorizons.core.util.math.Vec3i;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -259,7 +258,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
//===============================//
|
||||
|
||||
FullDataPointIdMap mapping = dataSource.mapping;
|
||||
LongArrayList dataColumn = dataSource.get(relativePos.x, relativePos.z);
|
||||
LongArrayList dataColumn = dataSource.getColumnAtRelPos(relativePos.x, relativePos.z);
|
||||
if (dataColumn != null)
|
||||
{
|
||||
int dataColumnIndexCount = dataColumn.size();
|
||||
|
||||
+1
-28
@@ -20,7 +20,6 @@
|
||||
package com.seibel.distanthorizons.core.dataObjects.fullData.sources;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
|
||||
import com.seibel.distanthorizons.core.file.IDataSource;
|
||||
import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
@@ -34,7 +33,6 @@ import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataOutputStre
|
||||
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.util.BitShiftUtil;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
@@ -48,7 +46,7 @@ import java.util.Arrays;
|
||||
* @see FullDataPointUtil
|
||||
* @see FullDataSourceV2
|
||||
*/
|
||||
public class FullDataSourceV1 implements IDataSource
|
||||
public class FullDataSourceV1
|
||||
{
|
||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||
|
||||
@@ -95,28 +93,13 @@ public class FullDataSourceV1 implements IDataSource
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//======//
|
||||
// data //
|
||||
//======//
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean update(FullDataSourceV2 dataSource) { throw new UnsupportedOperationException("Deprecated"); }
|
||||
|
||||
|
||||
|
||||
//=====================//
|
||||
// setters and getters //
|
||||
//=====================//
|
||||
|
||||
@Override
|
||||
public Long getKey() { return this.pos; }
|
||||
@Override
|
||||
public String getKeyDisplayString() { return DhSectionPos.toString(this.pos); }
|
||||
|
||||
@Override
|
||||
public long getPos() { return this.pos; }
|
||||
|
||||
public void resizeDataStructuresForRepopulation(long pos)
|
||||
@@ -125,7 +108,6 @@ public class FullDataSourceV1 implements IDataSource
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getDataDetailLevel() { return (byte) (DhSectionPos.getDetailLevel(this.pos) - SECTION_SIZE_OFFSET); }
|
||||
|
||||
public boolean isEmpty() { return this.isEmpty; }
|
||||
@@ -378,15 +360,6 @@ public class FullDataSourceV1 implements IDataSource
|
||||
public void setIdMapping(FullDataPointIdMap mappings) { this.mapping.mergeAndReturnRemappedEntityIds(mappings); }
|
||||
|
||||
|
||||
//==================//
|
||||
// override methods //
|
||||
//==================//
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{ /* not currently needed */ }
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// helper classes //
|
||||
|
||||
+14
-30
@@ -27,9 +27,7 @@ import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
|
||||
import com.seibel.distanthorizons.core.dataObjects.transformers.FullDataOcclusionCuller;
|
||||
import com.seibel.distanthorizons.core.dataObjects.transformers.LodDataBuilder;
|
||||
import com.seibel.distanthorizons.core.file.AbstractDataSourceHandler;
|
||||
import com.seibel.distanthorizons.core.file.IDataSource;
|
||||
import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||
import com.seibel.distanthorizons.core.file.fullDatafile.FullDataSourceProviderV2;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.pooling.AbstractPhantomArrayList;
|
||||
@@ -45,7 +43,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import it.unimi.dsi.fastutil.bytes.ByteArrayList;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -61,7 +58,7 @@ import java.util.List;
|
||||
*/
|
||||
public class FullDataSourceV2
|
||||
extends AbstractPhantomArrayList
|
||||
implements IDataSource, IDhApiFullDataSource
|
||||
implements IDhApiFullDataSource
|
||||
{
|
||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||
/** useful for debugging, but can slow down update operations quite a bit due to being called so often. */
|
||||
@@ -87,10 +84,6 @@ public class FullDataSourceV2
|
||||
private int cachedHashCode = 0;
|
||||
|
||||
private final long pos;
|
||||
@Override
|
||||
public Long getKey() { return this.pos; }
|
||||
@Override
|
||||
public String getKeyDisplayString() { return DhSectionPos.toString(this.pos); }
|
||||
|
||||
|
||||
public final FullDataPointIdMap mapping;
|
||||
@@ -226,7 +219,7 @@ public class FullDataSourceV2
|
||||
private FullDataSourceV2(
|
||||
long pos,
|
||||
FullDataPointIdMap mapping, @Nullable LongArrayList[] data,
|
||||
@Nullable byte[] columnGenerationSteps, @Nullable byte[] columnWorldCompressionMode,
|
||||
byte @Nullable [] columnGenerationSteps, byte @Nullable [] columnWorldCompressionMode,
|
||||
boolean empty)
|
||||
{
|
||||
super(ARRAY_LIST_POOL, 2, 0, WIDTH * WIDTH);
|
||||
@@ -287,11 +280,11 @@ public class FullDataSourceV2
|
||||
// getters //
|
||||
//=========//
|
||||
|
||||
public LongArrayList get(int relX, int relZ) throws IndexOutOfBoundsException
|
||||
public LongArrayList getColumnAtRelPos(int relX, int relZ) throws IndexOutOfBoundsException
|
||||
{ return this.dataPoints[relativePosToIndex(relX, relZ)]; }
|
||||
|
||||
@Nullable
|
||||
public LongArrayList tryGet(int relX, int relZ)
|
||||
public LongArrayList tryGetColumnAtRelPos(int relX, int relZ)
|
||||
{
|
||||
int index = tryGetRelativePosToIndex(relX, relZ);
|
||||
if (index == -1)
|
||||
@@ -306,7 +299,7 @@ public class FullDataSourceV2
|
||||
* returns {@link FullDataPointUtil#EMPTY_DATA_POINT} if the given {@link DhBlockPos}
|
||||
* is outside this data source's boundaries.
|
||||
*/
|
||||
public long getAtBlockPos(DhBlockPos blockPos)
|
||||
public long getDataPointAtBlockPos(DhBlockPos blockPos)
|
||||
{
|
||||
DhLodPos requestedPos = new DhLodPos(LodUtil.BLOCK_DETAIL_LEVEL, blockPos.getX(), blockPos.getZ());
|
||||
|
||||
@@ -330,7 +323,7 @@ public class FullDataSourceV2
|
||||
DhLodPos relativePos = requestedPos.getDhSectionRelativePositionForDetailLevel(requestDetailLevel);
|
||||
|
||||
// get the data column
|
||||
LongArrayList dataColumn = this.get(relativePos.x, relativePos.z);
|
||||
LongArrayList dataColumn = this.getColumnAtRelPos(relativePos.x, relativePos.z);
|
||||
if (dataColumn == null)
|
||||
{
|
||||
return FullDataPointUtil.EMPTY_DATA_POINT;
|
||||
@@ -374,8 +367,7 @@ public class FullDataSourceV2
|
||||
// updating //
|
||||
//==========//
|
||||
|
||||
@Override
|
||||
public boolean update(@NotNull FullDataSourceV2 inputDataSource)
|
||||
public boolean updateFromChunk(@NotNull FullDataSourceV2 inputDataSource)
|
||||
{
|
||||
// don't try updating if the input is empty
|
||||
if (inputDataSource.mapping.isEmpty())
|
||||
@@ -403,7 +395,7 @@ public class FullDataSourceV2
|
||||
// copy over application flag if either are set to continue propagating
|
||||
(BoolUtil.falseIfNull(this.applyToParent) || BoolUtil.falseIfNull(inputDataSource.applyToParent))
|
||||
// don't propagate past the top of the tree
|
||||
&& (DhSectionPos.getDetailLevel(this.pos) < AbstractDataSourceHandler.TOP_SECTION_DETAIL_LEVEL);
|
||||
&& (DhSectionPos.getDetailLevel(this.pos) < FullDataSourceProviderV2.TOP_SECTION_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
// null check to prevent setting a flag we don't want to save in the DB
|
||||
@@ -412,7 +404,7 @@ public class FullDataSourceV2
|
||||
this.applyToChildren =
|
||||
(BoolUtil.falseIfNull(this.applyToChildren) || BoolUtil.falseIfNull(inputDataSource.applyToChildren))
|
||||
// don't propagate past the bottom of the tree
|
||||
&& (DhSectionPos.getDetailLevel(this.pos) > AbstractDataSourceHandler.MIN_SECTION_DETAIL_LEVEL);
|
||||
&& (DhSectionPos.getDetailLevel(this.pos) > FullDataSourceProviderV2.MIN_SECTION_DETAIL_LEVEL);
|
||||
}
|
||||
}
|
||||
else if (inputDetailLevel + 1 == thisDetailLevel)
|
||||
@@ -423,7 +415,7 @@ public class FullDataSourceV2
|
||||
this.applyToParent =
|
||||
dataChanged
|
||||
&& (BoolUtil.falseIfNull(this.applyToParent) || BoolUtil.falseIfNull(inputDataSource.applyToParent))
|
||||
&& (DhSectionPos.getDetailLevel(this.pos) < AbstractDataSourceHandler.TOP_SECTION_DETAIL_LEVEL);
|
||||
&& (DhSectionPos.getDetailLevel(this.pos) < FullDataSourceProviderV2.TOP_SECTION_DETAIL_LEVEL);
|
||||
|
||||
}
|
||||
else if (inputDetailLevel - 1 == thisDetailLevel)
|
||||
@@ -435,7 +427,7 @@ public class FullDataSourceV2
|
||||
this.applyToChildren =
|
||||
dataChanged
|
||||
&& (BoolUtil.falseIfNull(this.applyToChildren) || BoolUtil.falseIfNull(inputDataSource.applyToChildren))
|
||||
&& (DhSectionPos.getDetailLevel(this.pos) > AbstractDataSourceHandler.MIN_SECTION_DETAIL_LEVEL);
|
||||
&& (DhSectionPos.getDetailLevel(this.pos) > FullDataSourceProviderV2.MIN_SECTION_DETAIL_LEVEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -460,7 +452,7 @@ public class FullDataSourceV2
|
||||
{
|
||||
for (int z = 0; z < WIDTH; z++)
|
||||
{
|
||||
LongArrayList dataColumn = this.get(x, z);
|
||||
LongArrayList dataColumn = this.getColumnAtRelPos(x, z);
|
||||
if (dataColumn != null
|
||||
&& dataColumn.size() > 1)
|
||||
{
|
||||
@@ -1202,18 +1194,10 @@ public class FullDataSourceV2
|
||||
// setters and getters //
|
||||
//=====================//
|
||||
|
||||
@Override
|
||||
public long getPos() { return this.pos; }
|
||||
|
||||
@Override
|
||||
public byte getDataDetailLevel() { return (byte) (DhSectionPos.getDetailLevel(this.pos) - DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL); }
|
||||
|
||||
public EDhApiWorldGenerationStep getWorldGenStepAtRelativePos(int relX, int relZ)
|
||||
{
|
||||
int index = relativePosToIndex(relX, relZ);
|
||||
return EDhApiWorldGenerationStep.fromValue(this.columnGenerationSteps.getByte(index));
|
||||
}
|
||||
|
||||
public void setSingleColumn(LongArrayList longArray, int relX, int relZ, EDhApiWorldGenerationStep worldGenStep, EDhApiWorldCompressionMode worldCompressionMode)
|
||||
{
|
||||
int index = relativePosToIndex(relX, relZ);
|
||||
@@ -1277,7 +1261,7 @@ public class FullDataSourceV2
|
||||
@Override
|
||||
public List<DhApiTerrainDataPoint> getApiDataPointColumn(int relX, int relZ) throws IndexOutOfBoundsException
|
||||
{
|
||||
LongArrayList dataColumn = this.get(relX, relZ);
|
||||
LongArrayList dataColumn = this.getColumnAtRelPos(relX, relZ);
|
||||
|
||||
ArrayList<DhApiTerrainDataPoint> apiList = new ArrayList<>();
|
||||
for (int i = 0; i < dataColumn.size(); i++)
|
||||
|
||||
+5
-5
@@ -22,11 +22,11 @@ public class FullDataOcclusionCuller
|
||||
int relX, int relZ
|
||||
)
|
||||
{
|
||||
LongArrayList centerColumn = dataSource.get(relX, relZ);
|
||||
LongArrayList posXColumn = dataSource.tryGet(relX + 1, relZ);
|
||||
LongArrayList negXColumn = dataSource.tryGet(relX - 1, relZ);
|
||||
LongArrayList posZColumn = dataSource.tryGet(relX, relZ + 1);
|
||||
LongArrayList negZColumn = dataSource.tryGet(relX, relZ - 1);
|
||||
LongArrayList centerColumn = dataSource.getColumnAtRelPos(relX, relZ);
|
||||
LongArrayList posXColumn = dataSource.tryGetColumnAtRelPos(relX + 1, relZ);
|
||||
LongArrayList negXColumn = dataSource.tryGetColumnAtRelPos(relX - 1, relZ);
|
||||
LongArrayList posZColumn = dataSource.tryGetColumnAtRelPos(relX, relZ + 1);
|
||||
LongArrayList negZColumn = dataSource.tryGetColumnAtRelPos(relX, relZ - 1);
|
||||
|
||||
if (posXColumn == null || posXColumn.size() == 0
|
||||
|| negXColumn == null || negXColumn.size() == 0
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ public class FullDataToRenderDataTransformer
|
||||
for (int z = 0; z < FullDataSourceV2.WIDTH; z++)
|
||||
{
|
||||
ColumnArrayView columnArrayView = columnSource.getVerticalDataPointView(x, z);
|
||||
LongArrayList dataColumn = fullDataSource.get(x, z);
|
||||
LongArrayList dataColumn = fullDataSource.getColumnAtRelPos(x, z);
|
||||
|
||||
updateOrReplaceRenderDataViewColumnWithFullDataColumn(
|
||||
levelWrapper, fullDataSource,
|
||||
|
||||
+1
-4
@@ -24,8 +24,6 @@ import java.util.List;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiWorldCompressionMode;
|
||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
|
||||
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBiomeWrapper;
|
||||
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper;
|
||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiChunkProcessingEvent;
|
||||
import com.seibel.distanthorizons.api.objects.data.DhApiChunk;
|
||||
import com.seibel.distanthorizons.api.objects.data.DhApiTerrainDataPoint;
|
||||
@@ -47,7 +45,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class LodDataBuilder
|
||||
@@ -142,7 +139,7 @@ public class LodDataBuilder
|
||||
int columnZ = relBlockZ + chunkOffsetZ;
|
||||
|
||||
// Get column data
|
||||
LongArrayList longs = dataSource.get(columnX, columnZ);
|
||||
LongArrayList longs = dataSource.getColumnAtRelPos(columnX, columnZ);
|
||||
if (longs == null)
|
||||
{
|
||||
longs = new LongArrayList(dataCapacity);
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.seibel.distanthorizons.core.file;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.EDhApiDetailLevel;
|
||||
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
||||
import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||
import com.seibel.distanthorizons.core.sql.dto.IBaseDTO;
|
||||
|
||||
/**
|
||||
* Base for all data sources. <br><br>
|
||||
*
|
||||
* AutoCloseable Can be implemented to allow for disposing of pooled data sources.
|
||||
*/
|
||||
public interface IDataSource extends IBaseDTO<Long>, AutoCloseable
|
||||
{
|
||||
long getPos();
|
||||
|
||||
/** @return true if the data was changed */
|
||||
boolean update(FullDataSourceV2 chunkData);
|
||||
|
||||
|
||||
|
||||
//===========//
|
||||
// meta data //
|
||||
//===========//
|
||||
|
||||
/**
|
||||
* Returns the detail level of the data contained by this data source.
|
||||
* IE: 0 for block, 1 for 2x2 blocks, etc.
|
||||
*
|
||||
* @see EDhApiDetailLevel
|
||||
*/
|
||||
byte getDataDetailLevel();
|
||||
|
||||
}
|
||||
+1
-1
@@ -104,7 +104,7 @@ public class DelayedFullDataSourceSaveCache implements AutoCloseable
|
||||
}
|
||||
|
||||
// write the new data into memory
|
||||
memoryDataSource.update(inputDataSource);
|
||||
memoryDataSource.updateFromChunk(inputDataSource);
|
||||
// keep track of when the last time we saved something was
|
||||
pair.updateLastWrittenTimestamp();
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ public class DhLightingEngine
|
||||
{
|
||||
for (int x = 0; x < FullDataSourceV2.WIDTH; x++)
|
||||
{
|
||||
LongArrayList dataPoints = dataSource.get(x, z);
|
||||
LongArrayList dataPoints = dataSource.getColumnAtRelPos(x, z);
|
||||
if (dataPoints != null && !dataPoints.isEmpty())
|
||||
{
|
||||
// iterate through the data points in this column top-down
|
||||
@@ -564,7 +564,7 @@ public class DhLightingEngine
|
||||
// check if the adjacent position is within the bounds of this data source...
|
||||
if (adjacentX >= 0 && adjacentX < FullDataSourceV2.WIDTH && adjacentZ >= 0 && adjacentZ < FullDataSourceV2.WIDTH)
|
||||
{
|
||||
LongArrayList adjacentDataPoints = chunk.get(adjacentX, adjacentZ);
|
||||
LongArrayList adjacentDataPoints = chunk.getColumnAtRelPos(adjacentX, adjacentZ);
|
||||
// ...and also check to make sure we have some data points
|
||||
// (potentially transparent ones) to propagate through in the adjacent column.
|
||||
if (adjacentDataPoints != null)
|
||||
|
||||
@@ -121,6 +121,7 @@ public class FullDataSourceV2DTO
|
||||
|
||||
/** Should only be used for subsequent decoding */
|
||||
public static FullDataSourceV2DTO CreateEmptyDataSourceForDecoding() { return new FullDataSourceV2DTO(); }
|
||||
|
||||
private FullDataSourceV2DTO()
|
||||
{
|
||||
super(ARRAY_LIST_POOL, 4, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user