/** * @param diffPairIdx a number from 0-n, where n is the value returned from numDiffs * @return the from ordinal for the (diffPairIdx)th record pair in which there were differences for this field. */ public int getFromOrdinal(int diffPairIdx) { return diffFromOrdinals.get(diffPairIdx); }
public int next() { int nextVal = pivotedToOrdinalClusters.get(currentMatchListPosition++); exhausted = (nextVal & Integer.MIN_VALUE) != 0; return nextVal & Integer.MAX_VALUE; }
/** * @param diffPairIdx a number from 0-n, where n is the value returned from numDiffs * @return the score of the diff for this field in the (diffPairIdx)th record pair in which there were differences for this field. */ public int getPairScore(int diffPairIdx) { return diffPairScores.get(diffPairIdx); }
/** * @param diffPairIdx a number from 0-n, where n is the value returned from numDiffs * @return the to ordinal for the (diffPairIdx)th record pair in which there were differences for this field. */ public int getToOrdinal(int diffPairIdx) { return diffToOrdinals.get(diffPairIdx); }
char specialCharacter() { switch(specialCharacterOffsets.get(specialCharacterIteratorPos) >>> 30) { case 0: return '{'; case 1: return '}'; case 2: return '\"'; case 3: return '\\'; } throw new IllegalStateException(); }
public boolean isMatchEqual(int matchIdx, HollowIndexerValueTraverser otherTraverser, int otherMatchIdx, BitSet fields) { for(int i=0;i<getNumFieldPaths();i++) { if(fields.get(i)) { if(!HollowReadFieldUtils.fieldsAreEqual((HollowObjectTypeDataAccess)fieldTypeDataAccess[i], fieldMatchLists[i].get(matchIdx), fieldSchemaPosition[i], (HollowObjectTypeDataAccess)otherTraverser.fieldTypeDataAccess[i], otherTraverser.fieldMatchLists[i].get(otherMatchIdx), otherTraverser.fieldSchemaPosition[i])) return false; } } return true; }
public int getIdentityFromOrdinal(int fromOrdinal) { int hashCode = HashCodes.hashInt(fromOrdinal); int bucket = hashCode & (fromOrdinalsMap.length - 1); while(fromOrdinalsMap[bucket] != -1L) { if((int)fromOrdinalsMap[bucket] == fromOrdinal) { if((fromOrdinalsMap[bucket] & Long.MIN_VALUE) != 0L) return pivotedToOrdinalClusters.get((int)((fromOrdinalsMap[bucket] & Long.MAX_VALUE) >> 32)); return (int)(fromOrdinalsMap[bucket] >> 32); } bucket = (bucket + 1) & (fromOrdinalsMap.length - 1); } return -1; }
public void addAll(IntList list) { for(int i=0;i<list.size;i++) add(list.get(i)); }
public Object getMatchedValue(int matchIdx, int fieldIdx) { int matchedOrdinal = fieldMatchLists[fieldIdx].get(matchIdx); return HollowReadFieldUtils.fieldValueObject((HollowObjectTypeDataAccess)fieldTypeDataAccess[fieldIdx], matchedOrdinal, fieldSchemaPosition[fieldIdx]); }
public boolean isMatchedValueEqual(int matchIdx, int fieldIdx, Object value) { int matchedOrdinal = fieldMatchLists[fieldIdx].get(matchIdx); return HollowReadFieldUtils.fieldValueEquals((HollowObjectTypeDataAccess)fieldTypeDataAccess[fieldIdx], matchedOrdinal, fieldSchemaPosition[fieldIdx], value); }
public int getMatchHash(int matchIdx, BitSet fields) { int hashCode = 0; for(int i=0;i<getNumFieldPaths();i++) { if(fields.get(i)) { hashCode ^= HashCodes.hashInt(HollowReadFieldUtils.fieldHashCode((HollowObjectTypeDataAccess)fieldTypeDataAccess[i], fieldMatchLists[i].get(matchIdx), fieldSchemaPosition[i])); hashCode ^= HashCodes.hashInt(hashCode); } } return hashCode; }
public int getMatchHash(int matchIdx) { int hashCode = 0; for(int i=0;i<getNumFieldPaths();i++) { hashCode ^= HashCodes.hashInt(HollowReadFieldUtils.fieldHashCode((HollowObjectTypeDataAccess)fieldTypeDataAccess[i], fieldMatchLists[i].get(matchIdx), fieldSchemaPosition[i])); hashCode ^= HashCodes.hashInt(hashCode); } return hashCode; }
@Override public void writeDataTo(ByteDataBuffer buf) { VarInt.writeVInt(buf, elementOrdinals.size()); for(int i=0;i<elementOrdinals.size();i++) { VarInt.writeVInt(buf, elementOrdinals.get(i)); } }
private int locatePrimaryKeyField(int locationOfCurrentRecord, int[] fieldPathIndex, int idx) { int schemaIdOfRecord = VarInt.readVInt(buf.getUnderlyingArray(), locationOfCurrentRecord); HollowObjectSchema recordSchema = (HollowObjectSchema) schemaIdMapper.getSchema(schemaIdOfRecord); locationOfCurrentRecord += VarInt.sizeOfVInt(schemaIdOfRecord); int fieldOffset = navigateToField(recordSchema, fieldPathIndex[idx], locationOfCurrentRecord); if (idx == fieldPathIndex.length - 1) return fieldOffset; int ordinalOfNextRecord = VarInt.readVInt(buf.getUnderlyingArray(), fieldOffset); int offsetOfNextRecord = recordLocationsByOrdinal.get(ordinalOfNextRecord); return locatePrimaryKeyField(offsetOfNextRecord, fieldPathIndex, idx + 1); }
private void assertList(IntList list, int... expectedEntries) { Assert.assertEquals(expectedEntries.length, list.size()); for(int i=0;i<list.size();i++) { Assert.assertEquals(expectedEntries[i], list.get(i)); } } }
private void assertResults(HollowHistoryKeyIndex keyIdx, String type, String query, int... expectedResults) { IntList actualResults = keyIdx.getTypeKeyIndexes().get(type).queryIndexedFields(query); Assert.assertEquals(expectedResults.length, actualResults.size()); actualResults.sort(); for(int i=0;i<expectedResults.length;i++) { Assert.assertEquals(expectedResults[i], actualResults.get(i)); } }
private HollowObject retrieveRemovedRecord(HollowHistory history, long version, String type, int key) { HollowHistoricalState historicalState = history.getHistoricalState(version); IntList queryResult = history.getKeyIndex().getTypeKeyIndexes().get(type).queryIndexedFields(String.valueOf(key)); int keyOrdinal = queryResult.get(0); int removedOrdinal = historicalState.getKeyOrdinalMapping().getTypeMapping(type).findRemovedOrdinal(keyOrdinal); return (HollowObject) GenericHollowRecordHelper.instantiate(historicalState.getDataAccess(), type, removedOrdinal); }
private HollowObject retrieveAddedRecord(HollowHistory history, long version, String type, int key) { HollowHistoricalState historicalState = history.getHistoricalState(version); Map<String, HollowHistoryTypeKeyIndex> typeKeyIndexes = history.getKeyIndex().getTypeKeyIndexes(); IntList queryResult = typeKeyIndexes.get(type).queryIndexedFields(String.valueOf(key)); int keyOrdinal = queryResult.get(0); int addedOrdinal = historicalState.getKeyOrdinalMapping().getTypeMapping(type).findAddedOrdinal(keyOrdinal); return (HollowObject) GenericHollowRecordHelper.instantiate(historicalState.getDataAccess(), type, addedOrdinal); }