Read the record that matches this record's current key.
For a GridTable, this method calls the inherited seek.
@return true if successful, false if not found.
@exception FILE_NOT_OPEN.
@exception KEY_NOT_FOUND - The key was not found on read.
163546
public boolean seek(String strSeekSign) throws DBException
    {
        // NOTE: This extra logic deals with a very specific and obscure case:
        // If this GRID table is NOT currently being used for indexed access (ie., get(x))
        // You can do a seek and I will cache the record. On a subsequent seek, I will return the cached
        // record. This is typically used for thin client accessing cached virtual fields in a table session.
        boolean bAutonomousSeek = false;
        if (m_iEndOfFileIndex == UNKNOWN_POSITION)
            if ((m_iPhysicalFilePosition == UNKNOWN_POSITION) || (m_iPhysicalFilePosition == ADD_NEW_POSITION))
                if ((m_iLogicalFilePosition == UNKNOWN_POSITION) || (m_iLogicalFilePosition == ADD_NEW_POSITION))
                    bAutonomousSeek = true;
        if (bAutonomousSeek)
        {
            Object bookmark = this.getRecord().getHandle(DBConstants.BOOKMARK_HANDLE);
            int iPosition = this.findElement(bookmark, DBConstants.BOOKMARK_HANDLE);
            if (iPosition == 0)
            {
                DataRecord dataRecord = (DataRecord)this.elementAt(iPosition);
                return this.getNextTable().setDataRecord(dataRecord);    // Success always.
            }
        }
    //  Don't set m_iPhysicalFilePosition = UNKNOWN_POSITION, because tables use seek to do queries.
        boolean bSuccess = super.seek(strSeekSign);
        if (bAutonomousSeek)
        {
            if (bSuccess)
                this.addRecordReference(0);
        }
        return bSuccess;
    }
879264
private HashtableEntry findEntry(Object key, int retrieveMode, boolean checkExpired)
                    throws IOException,
                    EOFException,
                    FileManagerException,
                    ClassNotFoundException,
                    HashtableOnDiskException {
        if (key == null) {
            return null;
        }

        int hashcode = key.hashCode();
        int index = header.getHtIndex(hashcode, header.currentTableId());
        long current = 0;
        HashtableEntry answer = null;

        if (header.rehashInProgress == 1) {

            if (debug)
                print("*");

            //
            // First search primary table.
            //
            if (htindex[index] != 0) {
                if (debug)
                    print("A");
                current = htindex[index];

                if (current == 0) {
                    throw new IllegalStateException("findEntry: ht pointer is null");
                }
                answer = findEntry(key, hashcode, retrieveMode, checkExpired, current, header.currentTableId());
                if (answer != null) {
                    return answer;
                }
            }

            //
            // Fell through, now search new table
            //
            index = header.getHtIndex(hashcode, header.alternateTableId());
            if (new_htindex[index] != 0) {
                if (debug)
                    print("B ");
                current = new_htindex[index];
                if (current == 0) {
                    throw new IllegalStateException("findEntry: ht pointer is null");
                }
                return findEntry(key, hashcode, retrieveMode, checkExpired, current, header.alternateTableId());
            }
            //
            // Fell through again, nothing here.
            //
            return null;
        } else {
            if (htindex[index] == 0) {
                return null;
            }
            int tableid = header.currentTableId();
            //current = header.calcOffset(index, tableid);
            current = htindex[index];
            if (current == 0) {
                throw new IllegalStateException("findEntry: ht pointer is null");
            }
            return findEntry(key, hashcode, retrieveMode, checkExpired, current, tableid);
        }
    }
1216905
protected ORecordInternal<?> readCurrentRecord(ORecordInternal<?> iRecord, final int iMovement) {
		if (limit > -1 && browsedRecords >= limit)
			// LIMIT REACHED
			return null;

		current.clusterPosition += iMovement;

		if (iRecord != null) {
			iRecord.setIdentity(current);
			iRecord = lowLevelDatabase.load(iRecord, fetchPlan);
		} else
			iRecord = lowLevelDatabase.load(current, fetchPlan);

		if (iRecord != null)
			browsedRecords++;

		return iRecord;
	}
245509
@Override
  public boolean nextKeyValue() throws IOException, InterruptedException {
    if (!hasMore) {
      key = null;
      value = null;
      return false;
    }
    firstValue = !nextKeyIsSame;
    DataInputBuffer next = input.getKey();
    currentRawKey.set(next.getData(), next.getPosition(), 
                      next.getLength() - next.getPosition());
    buffer.reset(currentRawKey.getBytes(), 0, currentRawKey.getLength());
    key = keyDeserializer.deserialize(key);
    next = input.getValue();
    buffer.reset(next.getData(), next.getPosition(), next.getLength());
    value = valueDeserializer.deserialize(value);
    hasMore = input.next();
    if (hasMore) {
      next = input.getKey();
      nextKeyIsSame = comparator.compare(currentRawKey.getBytes(), 0, 
                                         currentRawKey.getLength(),
                                         next.getData(),
                                         next.getPosition(),
                                         next.getLength() - next.getPosition()
                                         ) == 0;
    } else {
      nextKeyIsSame = false;
    }
    inputValueCounter.increment(1);
    return true;
  }
488445
@SuppressWarnings("unchecked")
    public synchronized ValT get(Object elementKey) {
        KeyT key = (KeyT) elementKey;
        ValT value = cache.get(key);
        if (value != null) {
            // memory hit
            Log.d(name, "MEM cache hit for " + key.toString());
            return value;
        }

        // memory miss, try reading from disk
        File file = getFileForKey(key);
        if (file.exists()) {
        	// if file older than expirationInMinutes, remove it
        	long lastModified = file.lastModified();
        	Date now = new Date();
        	long ageInMinutes = ((now.getTime() - lastModified) / (1000*60));
        	
        	if (ageInMinutes >= expirationInMinutes) {
        		Log.d(name, "DISK cache expiration for file " + file.toString());
        		file.delete();
        		return null;
        	}
        	
        	// disk hit
            Log.d(name, "DISK cache hit for " + key.toString());
            try {
                value = readValueFromDisk(file);
            } catch (IOException e) {
                // treat decoding errors as a cache miss
                e.printStackTrace();
                return null;
            }
            if (value == null) {
                return null;
            }
            cache.put(key, value);
            return value;
        }

        // cache miss
        return null;
    }
347579
boolean hasNext() throws DataSourceReadException {
        if (!hasNextComputed) {
            boolean stayInLoop;
            do {
                stayInLoop = false;
                /*
                 * Prior to reading the first iterator, we loop through all of
                 * the iterators to determine the minimum keyId. The minimum
                 * keyId, stored in currentMin, is used for data retrieval. The
                 * value of currentMin will be null if there is no data to
                 * retrieve.
                 */
                if (i == 0) {
                    this.currentMin = null;
                    for (DataStreamingEvent<E> elt : this.currentElt) {
                        currentMin = min(elt);
                    }
                }
                /*
                 * If there is no data to retrieve, we'll return false. If there
                 * is data to retrieve, we'll loop through the iterators and
                 * pull data for the current keyId, which is the keyId field of
                 * currentMin. If there's no data for the current keyId, this
                 * should loop through all of the iterators until their ends,
                 * and set hasNext to false.
                 */
                if (currentMin == null) {
                    this.hasNext = false;
                } else {
                    int n = this.currentElt.size();
                    for (; i < n; i++) {
                        DataStreamingEvent<E> elt = this.currentElt.get(i);
                        if (elt != null && elt.getKeyId().equals(
                                this.currentMin != null 
                                ? this.currentMin.getKeyId() : null)) {
                            this.result = elt;
                            this.nextKeyId = elt.getKeyId();
                            advance(i);
                            i++;
                            break;
                        }
                    }
                    if (this.i == n && this.result == null) {
                        this.i = 0;
                        stayInLoop = true;
                    }
                }
            } while (this.hasNext && stayInLoop);
            this.hasNextComputed = true;
        }
        return hasNext;
    }
1014644
private boolean next() throws IOException {
    if (valuesRead >= endOfPageValueCount) {
      if (valuesRead >= totalValueCount) {
        // How do we get here? Throw end of stream exception?
        return false;
      }
      readPage();
    }
    ++valuesRead;
    // TODO: Don't read for flat schemas
    //repetitionLevel = repetitionLevelColumn.nextInt();
    return definitionLevelColumn.nextInt() == maxDefLevel;
  }
475838
private @Nullable PooledByteBuffer readFromDiskCache(final CacheKey key) throws IOException {
    try {
      FLog.v(TAG, "Disk cache read for %s", key.getUriString());

      final BinaryResource diskCacheResource = mFileCache.getResource(key);
      if (diskCacheResource == null) {
        FLog.v(TAG, "Disk cache miss for %s", key.getUriString());
        mImageCacheStatsTracker.onDiskCacheMiss();
        return null;
      } else {
        FLog.v(TAG, "Found entry in disk cache for %s", key.getUriString());
        mImageCacheStatsTracker.onDiskCacheHit(key);
      }

      PooledByteBuffer byteBuffer;
      final InputStream is = diskCacheResource.openStream();
      try {
        byteBuffer = mPooledByteBufferFactory.newByteBuffer(is, (int) diskCacheResource.size());
      } finally {
        is.close();
      }

      FLog.v(TAG, "Successful read from disk cache for %s", key.getUriString());
      return byteBuffer;
    } catch (IOException ioe) {
      // TODO: 3697790 log failures
      // TODO: 5258772 - uncomment line below
      // mFileCache.remove(key);
      FLog.w(TAG, ioe, "Exception reading from cache for %s", key.getUriString());
      mImageCacheStatsTracker.onDiskCacheGetFail();
      throw ioe;
    }
  }
104017
public Object getData() 
    {
        try {
            Object objValue = super.getData();    // Get the actual key data.
            if (objValue == null)
                objValue = m_strNullValue;
            if (objValue == null)
                return null;
            if (objValue.getClass() == m_fieldKey.getDataClass())
                m_fieldKey.setData(objValue);
            else
                m_fieldKey.setString(objValue.toString());
            if (m_record.getTable().seek(null) == true)  // I use get, so the index matches the index of JComboBox
                return m_fieldData.getData();
        } catch (Exception ex)  {
            ex.printStackTrace();
        }
        return null;
    }
338281
public Object get(Object key) {
      NonSyncHashtableEntry tab[] = table;
      int hash = key.hashCode();
      int index = (hash & 0x7FFFFFFF) % tab.length;
      for (NonSyncHashtableEntry e = tab[index]; e != null; e = e.next) {
         if ((e.hash == hash) && e.key.equals(key)) {
            return e.value;
         }
      }
      return null;
   }
853886
public E read() throws IOException {
		boolean status = false;
		try {

			// Read header if not already read
			readHeader();

			// Read the records
			E element;
			try {
				do {
					element = readRecord(this.nextExpectedRecordIndex);
					if (!postRecordReadingStage(element)) {
						element = null;
					}
					++this.nextExpectedRecordIndex;
				}
				while (element == null);
			} catch (EOFException e) {
				element = null;
				close();
				postReadingStage(true);
			}
			status = true;

			return element;
		} finally {
			if (this.taskProgression != null) {
				this.taskProgression.setValue(this.buffer.position() + HEADER_BYTES);
			}
			if (!status) {
				close();
				postReadingStage(status);
			}
		}
	}
182015
private boolean containsKeyAndValue(Object key) {
        ReplicatedRecord replicatedRecord = getStorage().get(marshall(key));
        return replicatedRecord != null && replicatedRecord.getValue() != null;
    }
113040
BlockCrcInfoWritable getNextRecord() throws IOException {
    // By calling getBucketIdForNextRecord(), we make sure the next field
    // to read is the next record (if there is any record left in the file)
    // Also, by checking the return value, we know whether we've finished
    // the file.
    if (moveToNextRecordAndGetItsBucketId() == -1) {
      return null;
    }

    BlockCrcInfoWritable crcInfo = new BlockCrcInfoWritable();
    crcInfo.readFields(in);
    numRecordsReadInBucket++;
    return crcInfo;
  }
220527
public Object doSetHandle(Object bookmark, int iOpenMode, String strFields, int iHandleType) throws DBException, RemoteException
    {
        m_objCurrentCacheRecord = NONE;
        m_objCurrentLockedRecord = NONE;
        try {   // This caching logic is exactly the same as seek caching.
            Object objData = null;
            if ((m_mapCache == null) && (m_htCache == null))
                m_htCache = new Hashtable<Object,Object>();    // Okay, start caching keys and records
            if (m_htCache != null)
            {
                if (bookmark instanceof Integer)
                    objData = m_htCache.get(bookmark);    // Try to find this in the cache
            }
            m_mapCache = null;  // If seek is used, the grid cache is no good anymore.
            if (objData != null)
                m_objCurrentCacheRecord = bookmark;   // Current data is Cached
            if (objData == null)
            {
                m_objCurrentPhysicalRecord = NONE;
                objData = m_tableRemote.doSetHandle(bookmark, iOpenMode, strFields, iHandleType);
                if (objData instanceof Vector)
                    if (m_htCache != null)
                {
                    m_objCurrentPhysicalRecord = bookmark;    // Current data is current
                    m_objCurrentCacheRecord = bookmark;
                    m_htCache.put(bookmark, objData);
                }
            }
            return objData;
        } catch (RemoteException ex) {
            throw ex;
        }
    }
662639
public boolean containsKey(Object key) {
        if (key == null) {
            return false;
        }

        Entry tab[] = mTable;
        int hash = System.identityHashCode(key);
        int index = (hash & 0x7FFFFFFF) % tab.length;

        for (Entry e = tab[index], prev = null; e != null; e = e.mNext) {
            Object entryKey = e.getKey();

            if (entryKey == null) {
                // Clean up after a cleared Reference.
                mModCount++;
                if (prev != null) {
                    prev.mNext = e.mNext;
                }
                else {
                    tab[index] = e.mNext;
                }
                mCount--;
            }
            else if (e.mHash == hash && key == entryKey) {
                return true;
            }
            else {
                prev = e;
            }
        }

        return false;
    }
125715
@Override
    public void seek(Slice targetKey)
    {
        if (restartCount == 0) {
            return;
        }

        int left = 0;
        int right = restartCount - 1;

        // binary search restart positions to find the restart position immediately before the targetKey
        while (left < right) {
            int mid = (left + right + 1) / 2;

            seekToRestartPosition(mid);

            if (comparator.compare(nextEntry.getKey(), targetKey) < 0) {
                // key at mid is smaller than targetKey.  Therefore all restart
                // blocks before mid are uninteresting.
                left = mid;
            }
            else {
                // key at mid is greater than or equal to targetKey.  Therefore
                // all restart blocks at or after mid are uninteresting.
                right = mid - 1;
            }
        }

        // linear search (within restart block) for first key greater than or equal to targetKey
        for (seekToRestartPosition(left); nextEntry != null; next()) {
            if (comparator.compare(peek().getKey(), targetKey) >= 0) {
                break;
            }
        }

    }
227131
public synchronized Object get(Object key) {
        ConcurrentHashMap<Object, Object> tableRef = primaryTable;
        Entry curEntry = (Entry) primaryTable.get(key);

        // Not found in primary
        if (curEntry == null) {
            tableRef = secondaryTable;
            curEntry = (Entry) secondaryTable.get(key);

            // Not found in primary or secondary
            if (curEntry == null) {
                tableRef = tertiaryTable;
                curEntry = (Entry) tertiaryTable.get(key);
            }

            // Not found in primary, secondary, or tertiary
            if (curEntry == null) {
                tableRef = null;
            }
        }

        // If found in secondary or tertiary, move entry to primary
        if ((tableRef != null) && (tableRef != primaryTable)) {
            primaryTable.put(key, curEntry);
            tableRef.remove(key);
        }

        // If not present even in any table, add an empty entry
        // that can be found faster for update
        if (tableRef == null) {
            curEntry = (Entry) primaryTable.get(key);
            if (curEntry == null) {
                curEntry = new Entry();
                Entry prevEntry = (Entry) primaryTable.putIfAbsent(key, curEntry);
                if (prevEntry != null)
                    curEntry = prevEntry; // We lost the race, so use the entry from the other thread
            }
        }
        return curEntry.value;
    }