protected void incrementBinaryReferenceCount ( BinaryKey binaryKey , Set < BinaryKey > unusedBinaryKeys , Set < BinaryKey > usedBinaryKeys ) { // Find the document metadata and increment the usage count ... String sha1 = binaryKey . toString ( ) ; String key = keyForBinaryReferenceDocument ( sha1 ) ; // don't acquire a lock since we've already done this at the beginning of the #save EditableDocument entry = documentStore . edit ( key , false ) ; if ( entry == null ) { // The document doesn't yet exist, so create it ... Document content = Schematic . newDocument ( SHA1 , sha1 , REFERENCE_COUNT , 1L ) ; documentStore . localStore ( ) . put ( key , content ) ; } else { Long countValue = entry . getLong ( REFERENCE_COUNT ) ; entry . setNumber ( REFERENCE_COUNT , countValue != null ? countValue + 1 : 1L ) ; } // We're using the sha1, so remove it if its in the set of unused binary keys ... if ( unusedBinaryKeys != null ) { unusedBinaryKeys . remove ( binaryKey ) ; } if ( usedBinaryKeys != null ) { usedBinaryKeys . add ( binaryKey ) ; } }
Increment the reference count for the stored binary value with the supplied SHA - 1 hash .