private bool NextFileIndex() { _CurrentFileIndex++; if (_CurrentFileIndex >= _WordStepDocIndex.IndexFileInfoList.Count) { _End = true; return(false); } IndexFile.FilePosition fp = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].IndexFilePostion; if (_WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex == null) { _CurrentIndexBuf = _IndexFileProxy.GetIndexBufferMemory(fp.Serial, fp.Position, fp.Length); _CurrentDocId = -1; _LastDocIdInCurrentStep = -1; } else { _CurrentStepDocIndex = -1; _CurrentDocId = -1; _LastDocIdInCurrentStep = -1; int length = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[0].Position; _CurrentIndexBuf = _IndexFileProxy.GetIndexBufferMemory(fp.Serial, fp.Position, length); } return(true); }
private bool NextFileIndexBuf() { if (_WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex == null) { return(NextFileIndex()); } _CurrentStepDocIndex++; if (_CurrentStepDocIndex >= _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex.Count) { return(NextFileIndex()); } IndexFile.FilePosition fp = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].IndexFilePostion; _CurrentDocId = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[_CurrentStepDocIndex].DocId; int positionInIndex = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[_CurrentStepDocIndex].Position; int length; if (_CurrentStepDocIndex < _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex.Count - 1) { length = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[_CurrentStepDocIndex + 1].Position - positionInIndex; } else { length = fp.Length - positionInIndex; } _CurrentIndexBuf = _IndexFileProxy.GetIndexBufferMemory(fp.Serial, fp.Position + positionInIndex, length); return(true); }
public void Reset() { _CurrentFileIndex = -1; _CurrentIndexBuf = null; _CurrentDocId = -1; _LastDocIdInCurrentStep = -1; _CurrentStepDocIndex = -1; _End = false; _NextDocPositionList = new DocumentPositionList(-1); _NextODPL.DocumentId = -1; }
private bool TryGetAggregateAllocationTasks(EntityManager entityManager, [NotNullWhen(true)] out NonAllocatingList <Task>?tasks) { nint allocatedMeshDataCount = entityManager.GetComponentCount <AllocatedMeshData <TIndex, TVertex> >(); if (allocatedMeshDataCount is 0) { tasks = null; return(false); } tasks = new NonAllocatingList <Task>((int)allocatedMeshDataCount); bool recreateCommandBuffer = false; foreach ((Entity entity, AllocatedMeshData <TIndex, TVertex> mesh) in entityManager.GetEntitiesWithComponents <AllocatedMeshData <TIndex, TVertex> >()) { unsafe Task CreateDrawIndirectAllocationAllocationImpl(DrawElementsIndirectAllocation <TIndex, TVertex> pendingAllocation) { pendingAllocation.Allocation?.Dispose(); BufferMemory <TIndex> indexArrayMemory = _MultiDrawIndirectMesh.RentBufferMemory <TIndex>((nuint)sizeof(TIndex), MemoryMarshal.Cast <QuadIndexes <TIndex>, TIndex>(mesh.Data.Indexes.Segment)); BufferMemory <TVertex> vertexArrayMemory = _MultiDrawIndirectMesh.RentBufferMemory <TVertex>((nuint)sizeof(TVertex), MemoryMarshal.Cast <QuadVertexes <TVertex>, TVertex>(mesh.Data.Vertexes.Segment)); pendingAllocation.Allocation = new MeshMemory <TIndex, TVertex>(indexArrayMemory, vertexArrayMemory); return(Task.CompletedTask); } if (!mesh.Data.IsEmpty) { if (!entity.TryComponent(out DrawElementsIndirectAllocation <TIndex, TVertex>?allocation)) { allocation = entityManager.RegisterComponent <DrawElementsIndirectAllocation <TIndex, TVertex> >(entity); } tasks.Add(CreateDrawIndirectAllocationAllocationImpl(allocation)); ConfigureMaterial(entityManager, entity); recreateCommandBuffer = true; } entityManager.RemoveComponent <AllocatedMeshData <TIndex, TVertex> >(entity); } return(recreateCommandBuffer); }
static public DocumentPositionList GetNextDocumentPositionList(ref int docId, BufferMemory bufferMemory, bool simple) { if (docId < 0) { docId = VInt.sReadFromBuffer(bufferMemory.Buf, ref bufferMemory.Position); int count = VInt.sReadFromBuffer(bufferMemory.Buf, ref bufferMemory.Position); if (!simple) { int firstPosition = VInt.sReadFromBuffer(bufferMemory.Buf, ref bufferMemory.Position); return(new DocumentPositionList(docId, count / 8, (Int16)(count % 8), firstPosition)); } else { return(new DocumentPositionList(docId, count / 8, (Int16)(count % 8))); } } else { byte b = bufferMemory.Buf[bufferMemory.Position]; if (b < 128) { docId += b; bufferMemory.Position++; } else { docId = VInt.sReadFromBuffer(bufferMemory.Buf, ref bufferMemory.Position) + docId; } b = bufferMemory.Buf[bufferMemory.Position]; int count; if (b < 128) { count = b; bufferMemory.Position++; } else { count = VInt.sReadFromBuffer(bufferMemory.Buf, ref bufferMemory.Position); } int docCount = count / 8; if (!simple) { b = bufferMemory.Buf[bufferMemory.Position]; int firstPosition; if (b < 128) { firstPosition = b; bufferMemory.Position++; } else { firstPosition = VInt.sReadFromBuffer(bufferMemory.Buf, ref bufferMemory.Position); } return(new DocumentPositionList(docId, docCount, (Int16)(count % 8), firstPosition)); } else { return(new DocumentPositionList(docId, docCount, (Int16)(count % 8))); } } }
static public void GetNextOriginalDocumentPositionList(ref OriginalDocumentPositionList odpl, ref int docId, BufferMemory bufferMemory, bool simple) { if (docId < 0) { docId = VInt.sReadFromBuffer(bufferMemory.Buf, ref bufferMemory.Position); odpl.DocumentId = docId; odpl.CountAndWordCount = VInt.sReadFromBuffer(bufferMemory.Buf, ref bufferMemory.Position); if (!simple) { odpl.FirstPosition = VInt.sReadFromBuffer(bufferMemory.Buf, ref bufferMemory.Position); } //return odpl; } else { byte b = bufferMemory.Buf[bufferMemory.Position]; if (b < 128) { docId += b; bufferMemory.Position++; } else { docId = VInt.sReadFromBuffer(bufferMemory.Buf, ref bufferMemory.Position) + docId; } odpl.DocumentId = docId; b = bufferMemory.Buf[bufferMemory.Position]; if (b < 128) { odpl.CountAndWordCount = b; bufferMemory.Position++; } else { odpl.CountAndWordCount = VInt.sReadFromBuffer(bufferMemory.Buf, ref bufferMemory.Position); } if (!simple) { b = bufferMemory.Buf[bufferMemory.Position]; if (b < 128) { odpl.FirstPosition = b; bufferMemory.Position++; } else { odpl.FirstPosition = VInt.sReadFromBuffer(bufferMemory.Buf, ref bufferMemory.Position); } } //return odpl; } }
/// <summary> /// Match step doc index for this docid /// </summary> /// <param name="docId"></param> private bool Match(int docid) { if (_WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex == null) { //Current file index hasn't skip doc index return(false); } else { int nextStepDocIndex = _CurrentStepDocIndex + 1; bool lessThenNextStepDocIndex = false; int lastDocIdInCurrentStep = -1; //last docid in current segment of step; for (; nextStepDocIndex < _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex.Count; nextStepDocIndex++) { //StepDocIndex[nextStepDocIndex].DocId is the last docid of the segment of nextStepDocIndex. lastDocIdInCurrentStep = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[nextStepDocIndex].DocId; if (docid <= lastDocIdInCurrentStep) { lessThenNextStepDocIndex = true; break; } } if (!lessThenNextStepDocIndex) { return(false); } else { if (_CurrentStepDocIndex + 1 == nextStepDocIndex) { _LastDocIdInCurrentStep = lastDocIdInCurrentStep; return(false); } else { _CurrentStepDocIndex = nextStepDocIndex - 1; _CurrentDocId = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[_CurrentStepDocIndex].DocId; IndexFile.FilePosition fp = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].IndexFilePostion; int positionInIndex = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[_CurrentStepDocIndex].Position; int length; if (_CurrentStepDocIndex < _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex.Count - 1) { length = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[_CurrentStepDocIndex + 1].Position - positionInIndex; } else { length = fp.Length - positionInIndex; } _CurrentIndexBuf = _IndexFileProxy.GetIndexBufferMemory(fp.Serial, fp.Position + positionInIndex, length); return(true); } } } }