Comment out metaData versioning
This commit is contained in:
@@ -98,7 +98,9 @@ public class FullDataFileHandler implements IFullDataSourceProvider
|
||||
FullDataMetaFile fileToUse;
|
||||
if (metaFiles.size() > 1)
|
||||
{
|
||||
fileToUse = Collections.max(metaFiles, Comparator.comparingLong(a -> a.metaData.dataVersion.get()));
|
||||
// fileToUse = Collections.max(metaFiles, Comparator.comparingLong(a -> a.metaData.dataVersion.get()));
|
||||
|
||||
fileToUse = Collections.max(metaFiles, Comparator.comparingLong(fullDataMetaFile -> fullDataMetaFile.path.lastModified()));
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Multiple files with the same pos: ");
|
||||
@@ -324,27 +326,27 @@ public class FullDataFileHandler implements IFullDataSourceProvider
|
||||
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCacheVersion(DhSectionPos sectionPos)
|
||||
{
|
||||
FullDataMetaFile file = this.files.get(sectionPos);
|
||||
if (file == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return file.getCacheVersion();
|
||||
}
|
||||
// @Override
|
||||
// public long getCacheVersion(DhSectionPos sectionPos)
|
||||
// {
|
||||
// FullDataMetaFile file = this.files.get(sectionPos);
|
||||
// if (file == null)
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
// return file.getCacheVersion();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean isCacheVersionValid(DhSectionPos sectionPos, long cacheVersion)
|
||||
{
|
||||
FullDataMetaFile file = this.files.get(sectionPos);
|
||||
if (file == null)
|
||||
{
|
||||
return cacheVersion >= 0;
|
||||
}
|
||||
return file.isCacheVersionValid(cacheVersion);
|
||||
}
|
||||
// @Override
|
||||
// public boolean isCacheVersionValid(DhSectionPos sectionPos, long cacheVersion)
|
||||
// {
|
||||
// FullDataMetaFile file = this.files.get(sectionPos);
|
||||
// if (file == null)
|
||||
// {
|
||||
// return cacheVersion >= 0;
|
||||
// }
|
||||
// return file.isCacheVersionValid(cacheVersion);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public CompletableFuture<IFullDataSource> onCreateDataFile(FullDataMetaFile file)
|
||||
@@ -415,10 +417,10 @@ public class FullDataFileHandler implements IFullDataSourceProvider
|
||||
Consumer<IFullDataSource> onUpdated, Function<IFullDataSource, Boolean> updater)
|
||||
{
|
||||
boolean changed = updater.apply(source);
|
||||
if (changed)
|
||||
{
|
||||
metaData.dataVersion.incrementAndGet();
|
||||
}
|
||||
// if (changed)
|
||||
// {
|
||||
// metaData.dataVersion.incrementAndGet();
|
||||
// }
|
||||
|
||||
if (source instanceof IIncompleteFullDataSource)
|
||||
{
|
||||
@@ -439,8 +441,14 @@ public class FullDataFileHandler implements IFullDataSourceProvider
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
{
|
||||
IFullDataSource sourceLocal = source;
|
||||
|
||||
boolean changed = updater.apply(sourceLocal);
|
||||
if (changed) metaData.dataVersion.incrementAndGet();
|
||||
// if (changed)
|
||||
// {
|
||||
// metaData.dataVersion.incrementAndGet();
|
||||
// }
|
||||
|
||||
|
||||
if (sourceLocal instanceof IIncompleteFullDataSource)
|
||||
{
|
||||
IFullDataSource newSource = ((IIncompleteFullDataSource) sourceLocal).trySelfPromote();
|
||||
|
||||
@@ -119,26 +119,26 @@ public class FullDataMetaFile extends AbstractMetaDataFile
|
||||
}
|
||||
}
|
||||
|
||||
public long getCacheVersion() {
|
||||
debugCheck();
|
||||
return (this.metaData == null) ? 0 : this.metaData.dataVersion.get();
|
||||
}
|
||||
// public long getCacheVersion() {
|
||||
// debugCheck();
|
||||
// return (this.metaData == null) ? 0 : this.metaData.dataVersion.get();
|
||||
// }
|
||||
|
||||
public boolean isCacheVersionValid(long cacheVersion)
|
||||
{
|
||||
debugCheck();
|
||||
boolean noWrite = this.writeQueue.get().queue.isEmpty();
|
||||
if (!noWrite)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
MetaData getData = this.metaData;
|
||||
//NOTE: Do this instead of direct compare so values that wrapped around still work correctly.
|
||||
return (getData == null ? 0 : this.metaData.dataVersion.get()) - cacheVersion <= 0;
|
||||
}
|
||||
}
|
||||
// public boolean isCacheVersionValid(long cacheVersion)
|
||||
// {
|
||||
// debugCheck();
|
||||
// boolean noWrite = this.writeQueue.get().queue.isEmpty();
|
||||
// if (!noWrite)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// MetaData getData = this.metaData;
|
||||
// //NOTE: Do this instead of direct compare so values that wrapped around still work correctly.
|
||||
// return (getData == null ? 0 : this.metaData.dataVersion.get()) - cacheVersion <= 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
public void addToWriteQueue(ChunkSizedData datatype) {
|
||||
debugCheck();
|
||||
@@ -259,7 +259,7 @@ public class FullDataMetaFile extends AbstractMetaDataFile
|
||||
|
||||
private static MetaData makeMetaData(IFullDataSource data) {
|
||||
AbstractDataSourceLoader loader = AbstractDataSourceLoader.getLoader(data.getClass(), data.getDataVersion());
|
||||
return new MetaData(data.getSectionPos(), -1, 1,
|
||||
return new MetaData(data.getSectionPos(), -1,
|
||||
data.getDataDetail(), loader == null ? 0 : loader.datatypeId, data.getDataVersion());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler
|
||||
|
||||
if (exception == null && genTaskCompleted)
|
||||
{
|
||||
this.files.get(task.pos).metaData.dataVersion.incrementAndGet();
|
||||
// this.files.get(task.pos).metaData.dataVersion.incrementAndGet();
|
||||
return;
|
||||
}
|
||||
task.releaseStrongReference();
|
||||
|
||||
+2
-2
@@ -19,8 +19,8 @@ public interface IFullDataSourceProvider extends AutoCloseable {
|
||||
void write(DhSectionPos sectionPos, ChunkSizedData chunkData);
|
||||
CompletableFuture<Void> flushAndSave();
|
||||
|
||||
long getCacheVersion(DhSectionPos sectionPos);
|
||||
boolean isCacheVersionValid(DhSectionPos sectionPos, long cacheVersion);
|
||||
//long getCacheVersion(DhSectionPos sectionPos);
|
||||
//boolean isCacheVersionValid(DhSectionPos sectionPos, long cacheVersion);
|
||||
|
||||
CompletableFuture<IFullDataSource> onCreateDataFile(FullDataMetaFile file);
|
||||
IFullDataSource onDataFileLoaded(IFullDataSource source, MetaData metaData, Consumer<IFullDataSource> onUpdated, Function<IFullDataSource, Boolean> updater);
|
||||
|
||||
@@ -104,31 +104,31 @@ public abstract class AbstractMetaDataFile
|
||||
{
|
||||
try (FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ))
|
||||
{
|
||||
ByteBuffer buffer = ByteBuffer.allocate(METADATA_SIZE);
|
||||
channel.read(buffer, 0);
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocate(METADATA_SIZE);
|
||||
channel.read(byteBuffer, 0);
|
||||
channel.close();
|
||||
buffer.flip();
|
||||
byteBuffer.flip();
|
||||
|
||||
int idBytes = buffer.getInt();
|
||||
int idBytes = byteBuffer.getInt();
|
||||
if (idBytes != METADATA_IDENTITY_BYTES)
|
||||
{
|
||||
throw new IOException("Invalid file format: Metadata Identity byte check failed. Expected: [" + METADATA_IDENTITY_BYTES + "], Actual: [" + idBytes + "].");
|
||||
}
|
||||
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt(); // Unused
|
||||
int z = buffer.getInt();
|
||||
int checksum = buffer.getInt();
|
||||
byte detailLevel = buffer.get();
|
||||
byte dataLevel = buffer.get();
|
||||
byte loaderVersion = buffer.get();
|
||||
byte unused = buffer.get();
|
||||
long dataTypeId = buffer.getLong();
|
||||
long timestamp = buffer.getLong();
|
||||
LodUtil.assertTrue(buffer.remaining() == METADATA_RESERVED_SIZE);
|
||||
int x = byteBuffer.getInt();
|
||||
int y = byteBuffer.getInt(); // Unused
|
||||
int z = byteBuffer.getInt();
|
||||
int checksum = byteBuffer.getInt();
|
||||
byte detailLevel = byteBuffer.get();
|
||||
byte dataLevel = byteBuffer.get();
|
||||
byte loaderVersion = byteBuffer.get();
|
||||
byte unused = byteBuffer.get();
|
||||
long dataTypeId = byteBuffer.getLong();
|
||||
long unusedTimestamp = byteBuffer.getLong(); // not currently implemented
|
||||
LodUtil.assertTrue(byteBuffer.remaining() == METADATA_RESERVED_SIZE);
|
||||
DhSectionPos dataPos = new DhSectionPos(detailLevel, x, z);
|
||||
|
||||
return new MetaData(dataPos, checksum, timestamp, dataLevel, dataTypeId, loaderVersion);
|
||||
return new MetaData(dataPos, checksum, dataLevel, dataTypeId, loaderVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ public abstract class AbstractMetaDataFile
|
||||
buff.put(this.metaData.loaderVersion);
|
||||
buff.put(Byte.MIN_VALUE); // Unused
|
||||
buff.putLong(this.metaData.dataTypeId);
|
||||
buff.putLong(this.metaData.dataVersion.get());
|
||||
buff.putLong(Long.MAX_VALUE); //buff.putLong(this.metaData.dataVersion.get()); // not currently implemented
|
||||
LodUtil.assertTrue(buff.remaining() == METADATA_RESERVED_SIZE);
|
||||
buff.flip();
|
||||
file.write(buff);
|
||||
|
||||
@@ -13,17 +13,17 @@ public class MetaData
|
||||
{
|
||||
public DhSectionPos pos;
|
||||
public int checksum;
|
||||
public AtomicLong dataVersion;
|
||||
// public AtomicLong dataVersion; // currently broken
|
||||
public byte dataLevel;
|
||||
// Loader stuff
|
||||
public long dataTypeId;
|
||||
public byte loaderVersion;
|
||||
|
||||
public MetaData(DhSectionPos pos, int checksum, long dataVersion, byte dataLevel, long dataTypeId, byte loaderVersion)
|
||||
public MetaData(DhSectionPos pos, int checksum, byte dataLevel, long dataTypeId, byte loaderVersion)
|
||||
{
|
||||
this.pos = pos;
|
||||
this.checksum = checksum;
|
||||
this.dataVersion = new AtomicLong(dataVersion);
|
||||
// this.dataVersion = new AtomicLong(dataVersion);
|
||||
this.dataLevel = dataLevel;
|
||||
this.dataTypeId = dataTypeId;
|
||||
this.loaderVersion = loaderVersion;
|
||||
|
||||
@@ -67,7 +67,7 @@ public class RenderFileHandler implements ILodRenderSourceProvider
|
||||
{
|
||||
try
|
||||
{
|
||||
RenderMetaDataFile metaFile = new RenderMetaDataFile(this, file);
|
||||
RenderMetaDataFile metaFile = RenderMetaDataFile.createFromExistingFile(this, file);
|
||||
filesByPos.put(metaFile.pos, metaFile);
|
||||
}
|
||||
catch (IOException e)
|
||||
@@ -107,8 +107,14 @@ public class RenderFileHandler implements ILodRenderSourceProvider
|
||||
RenderMetaDataFile fileToUse;
|
||||
if (metaFiles.size() > 1)
|
||||
{
|
||||
//fileToUse = metaFiles.stream().findFirst().orElse(null); // use the first file in the list
|
||||
|
||||
// use the file's last modified date
|
||||
fileToUse = Collections.max(metaFiles, Comparator.comparingLong(renderMetaDataFile ->
|
||||
renderMetaDataFile.metaData.dataVersion.get()));
|
||||
renderMetaDataFile.path.lastModified()));
|
||||
|
||||
// fileToUse = Collections.max(metaFiles, Comparator.comparingLong(renderMetaDataFile ->
|
||||
// renderMetaDataFile.metaData.dataVersion.get()));
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Multiple files with the same pos: ");
|
||||
@@ -301,7 +307,7 @@ public class RenderFileHandler implements ILodRenderSourceProvider
|
||||
|
||||
//LOGGER.info("Recreating cache for {}", data.getSectionPos());
|
||||
DataRenderTransformer.asyncTransformDataSource(fullDataSourceFuture, this.level)
|
||||
.thenAccept((newRenderSource) -> this.write(renderSourceReference.get(), file, newRenderSource, this.fullDataSourceProvider.getCacheVersion(renderSource.getSectionPos())))
|
||||
.thenAccept((newRenderSource) -> this.write(renderSourceReference.get(), file, newRenderSource))
|
||||
.exceptionally((ex) ->
|
||||
{
|
||||
if (!UncheckedInterruptedException.isThrowableInterruption(ex))
|
||||
@@ -315,16 +321,18 @@ public class RenderFileHandler implements ILodRenderSourceProvider
|
||||
|
||||
public IRenderSource onRenderFileLoaded(IRenderSource renderSource, RenderMetaDataFile file)
|
||||
{
|
||||
if (!this.fullDataSourceProvider.isCacheVersionValid(file.pos, file.metaData.dataVersion.get()))
|
||||
{
|
||||
// TODO
|
||||
|
||||
// if (!this.fullDataSourceProvider.isCacheVersionValid(file.pos, file.metaData.dataVersion.get()))
|
||||
// {
|
||||
this.updateCache(renderSource, file);
|
||||
}
|
||||
// }
|
||||
|
||||
return renderSource;
|
||||
}
|
||||
|
||||
private void write(IRenderSource currentRenderSource, RenderMetaDataFile file,
|
||||
IRenderSource newRenderSource, long newDataVersion)
|
||||
IRenderSource newRenderSource)
|
||||
{
|
||||
if (currentRenderSource == null || newRenderSource == null)
|
||||
{
|
||||
@@ -333,7 +341,7 @@ public class RenderFileHandler implements ILodRenderSourceProvider
|
||||
|
||||
currentRenderSource.updateFromRenderSource(newRenderSource);
|
||||
|
||||
file.metaData.dataVersion.set(newDataVersion);
|
||||
//file.metaData.dataVersion.set(newDataVersion);
|
||||
file.metaData.dataLevel = currentRenderSource.getDataDetail();
|
||||
file.loader = AbstractRenderSourceLoader.getLoader(currentRenderSource.getClass(), currentRenderSource.getRenderVersion());
|
||||
file.dataType = currentRenderSource.getClass();
|
||||
@@ -344,10 +352,10 @@ public class RenderFileHandler implements ILodRenderSourceProvider
|
||||
|
||||
public void onReadRenderSourceFromCache(RenderMetaDataFile file, IRenderSource data)
|
||||
{
|
||||
if (!this.fullDataSourceProvider.isCacheVersionValid(file.pos, file.metaData.dataVersion.get()))
|
||||
{
|
||||
// if (!this.fullDataSourceProvider.isCacheVersionValid(file.pos, file.metaData.dataVersion.get()))
|
||||
// {
|
||||
this.updateCache(data, file);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
public boolean refreshRenderSource(IRenderSource source)
|
||||
@@ -363,13 +371,13 @@ public class RenderFileHandler implements ILodRenderSourceProvider
|
||||
|
||||
LodUtil.assertTrue(file != null);
|
||||
LodUtil.assertTrue(file.metaData != null);
|
||||
if (!this.fullDataSourceProvider.isCacheVersionValid(file.pos, file.metaData.dataVersion.get()))
|
||||
{
|
||||
// if (!this.fullDataSourceProvider.isCacheVersionValid(file.pos, file.metaData.dataVersion.get()))
|
||||
// {
|
||||
this.updateCache(source, file);
|
||||
return true;
|
||||
}
|
||||
// }
|
||||
|
||||
return false;
|
||||
// return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,18 +33,6 @@ public class RenderMetaDataFile extends AbstractMetaDataFile
|
||||
// null - Nothing is loaded or being loaded
|
||||
AtomicReference<Object> data = new AtomicReference<>(null);
|
||||
|
||||
// @FunctionalInterface
|
||||
// public interface CacheValidator
|
||||
// {
|
||||
// boolean isCacheValid(DhSectionPos sectionPos, long timestamp);
|
||||
// }
|
||||
// @FunctionalInterface
|
||||
// public interface CacheSourceProducer
|
||||
// {
|
||||
// CompletableFuture<IFullDataSource> getSourceFuture(DhSectionPos sectionPos);
|
||||
// }
|
||||
// CacheValidator validator;
|
||||
// CacheSourceProducer source;
|
||||
private final RenderFileHandler fileHandler;
|
||||
private boolean doesFileExist;
|
||||
|
||||
@@ -250,7 +238,7 @@ public class RenderMetaDataFile extends AbstractMetaDataFile
|
||||
private static MetaData makeMetaData(IRenderSource data)
|
||||
{
|
||||
AbstractRenderSourceLoader loader = AbstractRenderSourceLoader.getLoader(data.getClass(), data.getRenderVersion());
|
||||
return new MetaData(data.getSectionPos(), -1, -1,
|
||||
return new MetaData(data.getSectionPos(), -1,
|
||||
data.getDataDetail(), loader == null ? 0 : loader.renderTypeId, data.getRenderVersion());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user