/** * Copies all of the mappings from the specified map to this one. * These mappings replace any mappings that this map had for any of the * keys currently in the specified map. * * @param m mappings to be stored in this map */ @Override public void putAll(Map<? extends K, ? extends V> m) { for ( Map.Entry<? extends K, ? extends V> e : m.entrySet() ) { put( e.getKey(), e.getValue() ); } }
/** * Reconstitute the <tt>ConcurrentHashMap</tt> instance from a * stream (i.e., deserialize it). * * @param s the stream */ @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); // Initialize each segment to be minimally sized, and let grow. for ( int i = 0; i < segments.length; ++i ) { segments[i].setTable( new HashEntry[1] ); } // Read the keys and values, and put the mappings in the table for (; ; ) { K key = (K) s.readObject(); V value = (V) s.readObject(); if ( key == null ) { break; } put( key, value ); } } }
/** * Map a commit LSN to a point in time when the commit happened. * * @param lsn - LSN of the commit * @return time when the commit was recorded into the database log * @throws SQLException */ public Instant timestampOfLsn(Lsn lsn) throws SQLException { final String query = LSN_TO_TIMESTAMP; if (lsn.getBinary() == null) { return null; } Instant cachedInstant = lsnToInstantCache.get(lsn); if (cachedInstant != null) { return cachedInstant; } return prepareQueryAndMap(query, statement -> { statement.setBytes(1, lsn.getBinary()); }, singleResultMapper(rs -> { final Timestamp ts = rs.getTimestamp(1); final Instant ret = (ts == null) ? null : ts.toInstant(); LOGGER.trace("Timestamp of lsn {} is {}", lsn, ret); if (ret != null) { lsnToInstantCache.put(lsn, ret); } return ret; }, "LSN to timestamp query must return exactly one value")); }
/** * Copies all of the mappings from the specified map to this one. * These mappings replace any mappings that this map had for any of the * keys currently in the specified map. * * @param m mappings to be stored in this map */ @Override public void putAll(Map<? extends K, ? extends V> m) { for ( Map.Entry<? extends K, ? extends V> e : m.entrySet() ) { put( e.getKey(), e.getValue() ); } }
/** * Reconstitute the <tt>ConcurrentHashMap</tt> instance from a * stream (i.e., deserialize it). * * @param s the stream */ @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); // Initialize each segment to be minimally sized, and let grow. for ( int i = 0; i < segments.length; ++i ) { segments[i].setTable( new HashEntry[1] ); } // Read the keys and values, and put the mappings in the table for (; ; ) { K key = (K) s.readObject(); V value = (V) s.readObject(); if ( key == null ) { break; } put( key, value ); } } }