use of it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap in project geode by apache.
the class RangeIndex method saveMapping.
void saveMapping(Object key, Object indxResultSet, RegionEntry entry) {
if (key == null) {
List nullSet = nullEntries.get();
if (nullSet == null) {
nullSet = new ArrayList(1);
nullEntries.set(nullSet);
}
nullSet.add(indxResultSet);
} else if (key == QueryService.UNDEFINED) {
List undefinedSet = undefinedEntries.get();
if (undefinedSet == null) {
undefinedSet = new ArrayList(1);
undefinedEntries.set(undefinedSet);
}
if (indxResultSet != null) {
if (indxResultSet.getClass().getName().startsWith("org.apache.geode.internal.cache.Token$") || indxResultSet == QueryService.UNDEFINED) {
// do nothing, Entries are either removed or invalidated or destroyed
// by other thread.
} else {
undefinedSet.add(indxResultSet);
}
}
} else {
Map keysToSetMap = keysToHashSetMap.get();
if (keysToSetMap == null) {
keysToSetMap = new Object2ObjectOpenHashMap(1);
keysToHashSetMap.set(keysToSetMap);
}
Object value = keysToSetMap.get(key);
if (value == null) {
keysToSetMap.put(key, indxResultSet);
} else if (value instanceof Collection) {
((Collection) value).add(indxResultSet);
} else {
List values = new ArrayList(2);
values.add(indxResultSet);
values.add(value);
keysToSetMap.put(key, values);
}
}
this.internalIndexStats.incNumUpdates();
}
use of it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap in project geode by apache.
the class HashIndex method removeMapping.
/**
* @param opCode one of OTHER_OP, BEFORE_UPDATE_OP, AFTER_UPDATE_OP.
*/
void removeMapping(RegionEntry entry, int opCode) throws IMQException {
// + entry );
if (opCode == BEFORE_UPDATE_OP) {
// Either take key from reverse map OR evaluate it using IMQEvaluator.
if (!IndexManager.isObjectModificationInplace()) {
// It will always contain 1 element only, for this thread.
entryToOldKeysMap.set(new Object2ObjectOpenHashMap(1));
this.evaluator.evaluate(entry, false);
}
} else {
// happen in same thread.
if (entryToOldKeysMap != null) {
entryToOldKeysMap.remove();
}
this.evaluator.evaluate(entry, false);
this.internalIndexStats.incNumUpdates();
}
}
use of it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap in project geode by apache.
the class PdxStringJUnitTest method testHashCodeEquals.
@Test
public void testHashCodeEquals() throws Exception {
PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
pf.writeString("secId", "abc");
PdxInstanceImpl pi = (PdxInstanceImpl) pf.create();
PdxString pdx1 = (PdxString) pi.getRawField("secId");
Map<PdxString, String> map = new HashMap<PdxString, String>();
map.put(pdx1, "abc");
PdxString pdx2 = new PdxString("abc");
assertEquals(map.get(pdx2), "abc");
map = new Object2ObjectOpenHashMap();
map.put(pdx1, "abc");
assertEquals(map.get(pdx2), "abc");
}
use of it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap in project geode by apache.
the class MsgStreamer method create.
/**
* Create message streamers splitting into versioned streamers, if required, for given list of
* connections to remote nodes. This method can either return a single MsgStreamer object or a
* List of MsgStreamer objects.
*/
public static BaseMsgStreamer create(List<?> cons, final DistributionMessage msg, final boolean directReply, final DMStats stats) {
final Connection firstCon = (Connection) cons.get(0);
// split into different versions if required
Version version;
final int numCons = cons.size();
if (numCons > 1) {
Connection con;
Object2ObjectOpenHashMap versionToConnMap = null;
int numVersioned = 0;
for (Object c : cons) {
con = (Connection) c;
if ((version = con.getRemoteVersion()) != null) {
if (versionToConnMap == null) {
versionToConnMap = new Object2ObjectOpenHashMap();
}
@SuppressWarnings("unchecked") ArrayList<Object> vcons = (ArrayList<Object>) versionToConnMap.get(version);
if (vcons == null) {
vcons = new ArrayList<Object>(numCons);
versionToConnMap.put(version, vcons);
}
vcons.add(con);
numVersioned++;
}
}
if (versionToConnMap == null) {
return new MsgStreamer(cons, msg, directReply, stats, firstCon.getSendBufferSize());
} else {
// if there is a versioned stream created, then split remaining
// connections to unversioned stream
final ArrayList<MsgStreamer> streamers = new ArrayList<MsgStreamer>(versionToConnMap.size() + 1);
final int sendBufferSize = firstCon.getSendBufferSize();
if (numCons > numVersioned) {
// allocating list of numCons size so that as the result of
// getSentConnections it may not need to be reallocted later
final ArrayList<Object> unversionedCons = new ArrayList<Object>(numCons);
for (Object c : cons) {
con = (Connection) c;
if ((version = con.getRemoteVersion()) == null) {
unversionedCons.add(con);
}
}
streamers.add(new MsgStreamer(unversionedCons, msg, directReply, stats, sendBufferSize));
}
for (ObjectIterator<Object2ObjectMap.Entry> itr = versionToConnMap.object2ObjectEntrySet().fastIterator(); itr.hasNext(); ) {
Object2ObjectMap.Entry entry = itr.next();
Object ver = entry.getKey();
Object l = entry.getValue();
streamers.add(new VersionedMsgStreamer((List<?>) l, msg, directReply, stats, sendBufferSize, (Version) ver));
}
return new MsgStreamerList(streamers);
}
} else if ((version = firstCon.getRemoteVersion()) == null) {
return new MsgStreamer(cons, msg, directReply, stats, firstCon.getSendBufferSize());
} else {
// create a single VersionedMsgStreamer
return new VersionedMsgStreamer(cons, msg, directReply, stats, firstCon.getSendBufferSize(), version);
}
}
Aggregations