| | |
| | | private int indexEntryLimit; |
| | | |
| | | private EntryIDSetCodec codec; |
| | | protected boolean encryptValues; |
| | | protected CryptoSuite cryptoSuite; |
| | | |
| | | /** |
| | |
| | | * The configured limit on the number of entry IDs that may be indexed by one key. |
| | | * @param entryContainer |
| | | * The entryContainer holding this index. |
| | | * @param cryptoSuite |
| | | * @throws StorageRuntimeException |
| | | * If an error occurs in the storage. |
| | | */ |
| | | DefaultIndex(TreeName name, State state, int indexEntryLimit, EntryContainer entryContainer) |
| | | DefaultIndex(TreeName name, State state, int indexEntryLimit, EntryContainer entryContainer, CryptoSuite cryptoSuite) |
| | | throws StorageRuntimeException |
| | | { |
| | | super(name); |
| | | this.indexEntryLimit = indexEntryLimit; |
| | | this.state = state; |
| | | this.entryContainer = entryContainer; |
| | | this.cryptoSuite = cryptoSuite; |
| | | } |
| | | |
| | | @Override |
| | |
| | | { |
| | | final EnumSet<IndexFlag> flags = state.getIndexFlags(txn, getName()); |
| | | codec = flags.contains(COMPACTED) ? CODEC_V2 : CODEC_V1; |
| | | if (encryptValues) |
| | | if (cryptoSuite.isEncrypted()) |
| | | { |
| | | codec = new EntryIDSet.EntryIDSetCodecV3(codec, cryptoSuite); |
| | | } |
| | |
| | | // Keeps temporary values during import encrypted even in on-disk buffers. |
| | | long importDecodeValue(ByteString value) |
| | | { |
| | | return encryptValues ? decodeValue(ByteString.empty(), value).iterator().next().longValue() : value.toLong(); |
| | | return cryptoSuite.isEncrypted() |
| | | ? decodeValue(ByteString.empty(), value).iterator().next().longValue() |
| | | : value.toLong(); |
| | | } |
| | | |
| | | ByteString importToValue(EntryID entryID) |
| | | { |
| | | return encryptValues ? toValue(newDefinedSet(entryID.longValue())) : entryID.toByteString(); |
| | | return cryptoSuite.isEncrypted() ? toValue(newDefinedSet(entryID.longValue())) : entryID.toByteString(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public boolean setConfidential(boolean indexConfidential) |
| | | { |
| | | final boolean rebuildRequired = !this.encryptValues && indexConfidential; |
| | | this.encryptValues = indexConfidential; |
| | | return rebuildRequired; |
| | | return cryptoSuite.isEncrypted() != indexConfidential; |
| | | } |
| | | |
| | | @Override |