diff options
author | Mark Spruiell <mes@zeroc.com> | 2014-08-07 16:08:30 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2014-08-07 16:08:30 -0700 |
commit | 9c4b185a6c83418caa5296f07ec1f08e4964867e (patch) | |
tree | dee966c65c144f20e02583110fac6569fe7680bc /java/src/Freeze/MapInternal/IndexedSubMap.java | |
parent | fix hello demo configuration unintended change (diff) | |
download | ice-9c4b185a6c83418caa5296f07ec1f08e4964867e.tar.bz2 ice-9c4b185a6c83418caa5296f07ec1f08e4964867e.tar.xz ice-9c4b185a6c83418caa5296f07ec1f08e4964867e.zip |
ICE-5311 - use ByteBuffer in Freeze maps
Diffstat (limited to 'java/src/Freeze/MapInternal/IndexedSubMap.java')
-rw-r--r-- | java/src/Freeze/MapInternal/IndexedSubMap.java | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/java/src/Freeze/MapInternal/IndexedSubMap.java b/java/src/Freeze/MapInternal/IndexedSubMap.java index fd775d29927..2a35174003e 100644 --- a/java/src/Freeze/MapInternal/IndexedSubMap.java +++ b/java/src/Freeze/MapInternal/IndexedSubMap.java @@ -13,6 +13,7 @@ import Freeze.ConnectionI; import Freeze.DatabaseException; import Freeze.Map; import Freeze.NavigableMap; +import java.nio.ByteBuffer; // // Indexed submap of a Freeze Map or of another submap @@ -138,8 +139,7 @@ class IndexedSubMap<K, V, I> next() { EntryI<K, V> entry = (EntryI<K, V>)_iterator.next(); - return new Entry(_index.decodeKey(entry.getIndexBytes(), _map.connection().getCommunicator(), - _map.connection().getEncoding())); + return new Entry(_index.decodeKey(entry.getIndexBytes())); } public void @@ -504,7 +504,7 @@ class IndexedSubMap<K, V, I> } private Entry - entrySearch(Search.Type type, byte[] key) + entrySearch(Search.Type type, ByteBuffer key) { if(type != Search.Type.FIRST && type != Search.Type.LAST && key == null) { @@ -523,8 +523,7 @@ class IndexedSubMap<K, V, I> if(Search.search(type, _map.connection(), _index.dbName(), _index.db(), dbKey, null, _index, _view, _index.traceLevels())) { - I k = _index.decodeKey(dbKey.getData(), _map.connection().getCommunicator(), - _map.connection().getEncoding()); + I k = _index.decodeKey(dbKey); return new Entry(k); } @@ -578,7 +577,7 @@ class IndexedSubMap<K, V, I> first() { Search.Type type; - byte[] key = null; + ByteBuffer key = null; if(_fromKey != null) { type = _fromInclusive ? mapSearchType(Search.Type.CEILING) : mapSearchType(Search.Type.HIGHER); @@ -595,7 +594,7 @@ class IndexedSubMap<K, V, I> last() { Search.Type type; - byte[] key = null; + ByteBuffer key = null; if(_toKey != null) { type = _toInclusive ? mapSearchType(Search.Type.FLOOR) : mapSearchType(Search.Type.LOWER); @@ -611,28 +610,28 @@ class IndexedSubMap<K, V, I> final Entry ceiling(I key) { - byte[] k = _index.encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding()); + ByteBuffer k = _index.encodeKey(key); return entrySearch(mapSearchType(Search.Type.CEILING), k); } final Entry floor(I key) { - byte[] k = _index.encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding()); + ByteBuffer k = _index.encodeKey(key); return entrySearch(mapSearchType(Search.Type.FLOOR), k); } final Entry higher(I key) { - byte[] k = _index.encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding()); + ByteBuffer k = _index.encodeKey(key); return entrySearch(mapSearchType(Search.Type.HIGHER), k); } final Entry lower(I key) { - byte[] k = _index.encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding()); + ByteBuffer k = _index.encodeKey(key); return entrySearch(mapSearchType(Search.Type.LOWER), k); } @@ -680,9 +679,9 @@ class IndexedSubMap<K, V, I> // final public boolean - keyInRange(byte[] key) + keyInRange(ByteBuffer key) { - I k = _index.decodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding()); + I k = _index.decodeKey(key); return inRange(k, true); } @@ -699,24 +698,22 @@ class IndexedSubMap<K, V, I> return _comparator; } - final protected byte[] + final protected ByteBuffer fromKeyBytes() { if(_fromKey != null && _fromKeyBytes == null) { - _fromKeyBytes = _index.encodeKey(_fromKey, _map.connection().getCommunicator(), - _map.connection().getEncoding()); + _fromKeyBytes = _index.encodeKey(_fromKey); } return _fromKeyBytes; } - final protected byte[] + final protected ByteBuffer toKeyBytes() { if(_toKey != null && _toKeyBytes == null) { - _toKeyBytes = _index.encodeKey(_toKey, _map.connection().getCommunicator(), - _map.connection().getEncoding()); + _toKeyBytes = _index.encodeKey(_toKey); } return _toKeyBytes; } @@ -754,8 +751,8 @@ class IndexedSubMap<K, V, I> final boolean _fromInclusive; final I _toKey; final boolean _toInclusive; - private byte[] _fromKeyBytes; - private byte[] _toKeyBytes; + private ByteBuffer _fromKeyBytes; + private ByteBuffer _toKeyBytes; } private class AscendingView extends View |