VectorHandlePtr newUnpagedHandle(int64_t index, int64_t valueCount) { ForaValueArray* array = ForaValueArray::Empty(&memoryPool); for (int64_t k = 0; k < valueCount; k++) array->append(ImplValContainer(CSTValue((int64_t)k))); return memoryPool.construct<VectorHandle>( Fora::BigVectorId(), Fora::PageletTreePtr(), array, &memoryPool, hash_type(index) ); }
Fora::ReturnValue<VectorRecord, VectorLoadRequest> VectorRecord::deepcopiedAndContiguous(MemoryPool* inPool, VectorDataManager* inVDM) const { if (!dataPtr()) return Fora::slot0(*this); lassert(!inPool->isBigVectorHandle()); VectorHandle* handle = dataPtr(); if (!allValuesAreLoaded()) return Fora::slot1(VectorLoadRequest(*this)); ForaValueArray* array = ForaValueArray::Empty(inPool); int64_t curIndex = 0; while (curIndex < size()) { TypedFora::Abi::ForaValueArraySlice slice = sliceForOffset(curIndex); lassert(slice.mapping().indexIsValid(curIndex)); lassert_dump( slice.array(), "We should have guaranteed that this value was loaded by calling 'allValuesAreLoaded'" ); Nullable<int64_t> unmappedIndex = slice.firstValueNotLoadedInRange( curIndex, slice.mapping().highIndex() ); lassert_dump( !unmappedIndex, "Index " << *unmappedIndex << " is unmapped in " << prettyPrintString(slice) << " of size " << size() ); if (slice.mapping().stride() == 1) { array->append( *slice.array(), slice.mapping().offsetForIndex(curIndex), slice.mapping().offsetForIndex(slice.mapping().highIndex()) ); } else { while (curIndex < slice.mapping().highIndex()) { int64_t indexInTarget = slice.mapping().offsetForIndex(curIndex); array->append(*slice.array(), indexInTarget, indexInTarget+1); curIndex++; } } curIndex = slice.mapping().highIndex(); } lassert(array->size() == size()); return Fora::slot0( VectorRecord( inPool->construct<VectorHandle>( Fora::BigVectorId(), Fora::PageletTreePtr(), array, inPool, vectorHandleHash() ) ) ); }
VectorRecord VectorRecord::append( MemoryPool* inPool, void* dataToAppend, JOV jovToAppend, VectorDataManager* inVDM, const boost::function0<hash_type>& hashCreatorFun ) { if (!mDataPtr) { ForaValueArray* array = ForaValueArray::Empty(inPool); array->append(jovToAppend, (uint8_t*)dataToAppend, 1, 0); return VectorRecord( inPool->construct<VectorHandle>( Fora::BigVectorId(), Fora::PageletTreePtr(), array, inPool, hashCreatorFun() ) ); } if (stride() == 1 && size() + offset() == mDataPtr->size() && mDataPtr->isWriteable()) { mDataPtr->makeSpaceForNewUnpagedValues(inVDM); lassert(mDataPtr->unpagedValues()); mDataPtr->unpagedValues()->append(jovToAppend, (uint8_t*)dataToAppend, 1, 0); mDataPtr->valueAppendedToUnpagedData(); return VectorRecord(mDataPtr, mSize+1, mOffset, 1); } if (!isCanonicallySliced()) return canonicallySliced(inPool, inVDM, hashCreatorFun()) .append(inPool, dataToAppend, jovToAppend, inVDM, hashCreatorFun); if (mDataPtr->unpagedValues()) { ForaValueArray* array = ForaValueArray::Empty(inPool); array->append(*mDataPtr->unpagedValues()); array->append(jovToAppend, (uint8_t*)dataToAppend, 1, 0); return VectorRecord( inPool->construct<VectorHandle>( mDataPtr->pagedValuesIdentity(), mDataPtr->pageletTree(), array, inPool, hashCreatorFun() ) ); } else { ForaValueArray* array = ForaValueArray::Empty(inPool); array->append(jovToAppend, (uint8_t*)dataToAppend, 1, 0); return VectorRecord( inPool->construct<VectorHandle>( mDataPtr->pagedValuesIdentity(), mDataPtr->pageletTree(), array, inPool, hashCreatorFun() ) ); } }
VectorRecord VectorRecord::append( MemoryPool* inPool, ImplValContainer toAppend, VectorDataManager* inVDM, const boost::function0<hash_type>& hashCreatorFun ) { if (!mDataPtr) { ForaValueArray* array = ForaValueArray::Empty(inPool); array->append(toAppend); return VectorRecord( inPool->construct<VectorHandle>( Fora::BigVectorId(), Fora::PageletTreePtr(), array, inPool, hashCreatorFun() ) ); } if (stride() == 1 && size() + offset() == mDataPtr->size() && mDataPtr->unpagedValues() && mDataPtr->unpagedValues()->isWriteable()) { //we can append directly mDataPtr->unpagedValues()->append(toAppend); mDataPtr->valueAppendedToUnpagedData(); return VectorRecord(mDataPtr, mSize+1, mOffset, 1); } if (!isCanonicallySliced()) return canonicallySliced(inPool, inVDM, hashCreatorFun()) .append(inPool, toAppend, inVDM, hashCreatorFun); if (mDataPtr->unpagedValues()) { ForaValueArray* array = ForaValueArray::Empty(inPool); array->append(*mDataPtr->unpagedValues()); array->append(toAppend); return VectorRecord( inPool->construct<VectorHandle>( mDataPtr->pagedValuesIdentity(), mDataPtr->pageletTree(), array, inPool, hashCreatorFun() ) ); } else { ForaValueArray* array = ForaValueArray::Empty(inPool); array->append(toAppend); return VectorRecord( inPool->construct<VectorHandle>( mDataPtr->pagedValuesIdentity(), mDataPtr->pageletTree(), array, inPool, hashCreatorFun() ) ); } }