KeyRef.getAbsoluteOffset(refWord) - KeyRef.AbsoluteOffset.byteLength; if (KeyRef.getIsSingleFlag(refWord)) {
/** * Get partial hash code from the reference word. * @param hashCode * @return */ public static long getPartialHashCodeFromRefWord(long refWord) { return KeyRef.getPartialHashCode(refWord); } }
/** * Setup for reading the key of an entry with the equalKey method. * @param hashMapStore * @param refWord */ public void setKey(VectorMapJoinFastBytesHashMapStore hashMapStore, long refWord) { // Preconditions.checkState(!KeyRef.getIsInvalidFlag(refWord)); this.hashMapStore = hashMapStore; this.refWord = refWord; absoluteOffset = KeyRef.getAbsoluteOffset(refWord); // Position after next relative offset (fixed length) to the key. hashMapStore.writeBuffers.setReadPoint(absoluteOffset, readPos); keyLength = KeyRef.getSmallKeyLength(refWord); boolean isKeyLengthSmall = (keyLength != KeyRef.SmallKeyLength.allBitsOn); if (isKeyLengthSmall) { keyAbsoluteOffset = absoluteOffset; } else { // And, if current value is big we must read it. keyLength = hashMapStore.writeBuffers.readVInt(readPos); keyAbsoluteOffset = hashMapStore.writeBuffers.getReadPoint(readPos); } // NOTE: Reading is now positioned before the key bytes. }
/** * @param refWord */ public long bumpCount(long refWord, WriteBuffers.Position unsafeReadPos) { // Preconditions.checkState(!KeyRef.getIsInvalidFlag(refWord)); /* * Extract information from the reference word. */ final long countAbsoluteOffset = KeyRef.getAbsoluteOffset(refWord) - MultiSetCount.byteLength; final int currentCount = writeBuffers.readInt( countAbsoluteOffset, unsafeReadPos); // Mark reference as having more than 1 as the count. refWord &= KeyRef.IsSingleFlag.flagOffMask; // Save current write position. final long saveAbsoluteOffset = writeBuffers.getWritePoint(); writeBuffers.setWritePoint(countAbsoluteOffset); writeBuffers.writeInt( countAbsoluteOffset, currentCount + 1); // Restore current write position. writeBuffers.setWritePoint(saveAbsoluteOffset); return refWord; }
public static boolean equalKey(long refWord, byte[] keyBytes, int keyStart, int keyLength, WriteBuffers writeBuffers, WriteBuffers.Position readPos) { // Preconditions.checkState((refWord & KeyRef.IsInvalidFlag.flagOnMask) == 0); final long absoluteOffset = KeyRef.getAbsoluteOffset(refWord); writeBuffers.setReadPoint(absoluteOffset, readPos); int actualKeyLength = KeyRef.getSmallKeyLength(refWord); boolean isKeyLengthSmall = (actualKeyLength != KeyRef.SmallKeyLength.allBitsOn); if (!isKeyLengthSmall) { // And, if current value is big we must read it. actualKeyLength = writeBuffers.readVInt(readPos); } if (actualKeyLength != keyLength) { return false; } // Our reading was positioned to the key. if (!writeBuffers.isEqual(keyBytes, keyStart, readPos, keyLength)) { return false; } return true; }
/** * Setup for reading the key of an entry with the equalKey method. * @param multiSetStore * @param refWord */ public void setKey(VectorMapJoinFastBytesHashMultiSetStore multiSetStore, long refWord) { // Preconditions.checkState(!KeyRef.getIsInvalidFlag(refWord)); this.multiSetStore = multiSetStore; this.refWord = refWord; absoluteOffset = KeyRef.getAbsoluteOffset(refWord); // Position after next relative offset (fixed length) to the key. multiSetStore.writeBuffers.setReadPoint(absoluteOffset, readPos); keyLength = KeyRef.getSmallKeyLength(refWord); boolean isKeyLengthSmall = (keyLength != KeyRef.SmallKeyLength.allBitsOn); if (!isKeyLengthSmall) { // And, if current value is big we must read it. keyLength = multiSetStore.writeBuffers.readVInt(readPos); } // NOTE: Reading is now positioned before the key bytes. }
public static int calculateHashCode(long refWord, WriteBuffers writeBuffers, WriteBuffers.Position readPos) { // Preconditions.checkState((refWord & KeyRef.IsInvalidFlag.flagOnMask) == 0); final long absoluteOffset = KeyRef.getAbsoluteOffset(refWord); int actualKeyLength = KeyRef.getSmallKeyLength(refWord); boolean isKeyLengthSmall = (actualKeyLength != KeyRef.SmallKeyLength.allBitsOn); final long keyAbsoluteOffset; if (!isKeyLengthSmall) { // Position after next relative offset (fixed length) to the key. writeBuffers.setReadPoint(absoluteOffset, readPos); // And, if current value is big we must read it. actualKeyLength = writeBuffers.readVInt(readPos); keyAbsoluteOffset = absoluteOffset + actualKeyLength; } else { keyAbsoluteOffset = absoluteOffset; } return writeBuffers.unsafeHashCode(keyAbsoluteOffset, actualKeyLength); }
/** * Setup for reading the key of an entry with the equalKey method. * @param setStore * @param refWord */ public void setKey(VectorMapJoinFastBytesHashSetStore setStore, long refWord) { // Preconditions.checkState(!KeyRef.getIsInvalidFlag(refWord)); this.setStore = setStore; absoluteOffset = KeyRef.getAbsoluteOffset(refWord); // Position after next relative offset (fixed length) to the key. setStore.writeBuffers.setReadPoint(absoluteOffset, readPos); keyLength = KeyRef.getSmallKeyLength(refWord); boolean isKeyLengthSmall = (keyLength != KeyRef.SmallKeyLength.allBitsOn); if (!isKeyLengthSmall) { // And, if current value is big we must read it. keyLength = setStore.writeBuffers.readVInt(readPos); } // NOTE: Reading is now positioned before the key bytes. }
/** * Mark the key matched with equalKey as a match and set up for reading the values. * Afterward, methods isSingleRow, cappedCount, first, next, etc may be called. */ public void setMatch() { hasRows = true; isSingleRow = KeyRef.getIsSingleFlag(refWord); // We must set the position since equalKey does not leave us positioned correctly. hashMapStore.writeBuffers.setReadPoint( keyAbsoluteOffset + keyLength, readPos); // Save first value absolute offset... firstValueAbsoluteOffset = hashMapStore.writeBuffers.getReadPoint(readPos); // Position to beginning. readIndex = 0; isNextEof = false; setJoinResult(JoinResult.MATCH); }
/** * Mark the key matched with equalKey as a match and read the set membership count, * if necessary. */ public void setContains() { isSingleCount = KeyRef.getIsSingleFlag(refWord); if (isSingleCount) { count = 1; } else { count = multiSetStore.writeBuffers.readInt( absoluteOffset - MultiSetCount.byteLength, readPos); } setJoinResult(JoinResult.MATCH); }
public void getKey(long refWord, ByteSegmentRef keyByteSegmentRef, WriteBuffers.Position readPos) { final long absoluteOffset = KeyRef.getAbsoluteOffset(refWord); writeBuffers.setReadPoint(absoluteOffset, readPos); int keyLength = KeyRef.getSmallKeyLength(refWord); boolean isKeyLengthSmall = (keyLength != KeyRef.SmallKeyLength.allBitsOn); if (!isKeyLengthSmall) { // Read big key length we wrote with the key. keyLength = writeBuffers.readVInt(readPos); } writeBuffers.getByteSegmentRefToCurrent(keyByteSegmentRef, keyLength, readPos); }