Changeset 766:8820bcce0c46
Legend:
- Unmodified
- Added
- Removed
-
kraken-logstorage/src/main/java/org/krakenapps/logstorage/engine/v2/LogFileReaderV2.java
r255 r766 67 67 pos += 4 + header.logCount * INDEX_ITEM_SIZE; 68 68 } 69 logger.trace("kraken logstorage: {} has {} blocks, {} logs.", new Object[] { indexPath.getName(), 70 indexBlockHeaders.size(),logCount });69 logger.trace("kraken logstorage: {} has {} blocks, {} logs.", new Object[] { indexPath.getName(), indexBlockHeaders.size(), 70 logCount }); 71 71 72 72 this.dataFile = new RandomAccessFile(dataPath, "r"); … … 126 126 127 127 @Override 128 public void traverse(Date from, Date to, int limit, LogRecordCallback callback) throws IOException, 129 InterruptedException { 128 public void traverse(Date from, Date to, int limit, LogRecordCallback callback) throws IOException, InterruptedException { 130 129 int matched = 0; 131 130 131 Long fromTime = (from == null) ? null : from.getTime(); 132 Long toTime = (to == null) ? null : to.getTime(); 132 133 for (int i = dataBlockHeaders.size() - 1; i >= 0; i--) { 133 134 DataBlockHeader header = dataBlockHeaders.get(i); 134 if ((from == null || header.endDate >= from.getTime()) && (to == null || header.startDate <= to.getTime())) { 135 Long f = (from != null) ? from.getTime() : null; 136 Long t = (to != null) ? to.getTime() : null; 137 matched += readBlock(i, f, t, limit - matched, callback); 135 if ((fromTime == null || header.endDate >= fromTime) && (toTime == null || header.startDate <= toTime)) { 136 matched += readBlock(i, fromTime, toTime, limit - matched, callback); 138 137 if (matched == limit) 139 138 return; … … 142 141 } 143 142 144 private int readBlock(int blockId, Long from, Long to, int limit, LogRecordCallback callback) throws IOException, 145 InterruptedException { 143 private int readBlock(int blockId, Long from, Long to, int limit, LogRecordCallback callback) throws IOException, InterruptedException { 146 144 IndexBlockHeader header = indexBlockHeaders.get(blockId); 147 145 List<Integer> offsets = new ArrayList<Integer>(); … … 149 147 150 148 indexFile.seek(header.fp + 4); 149 ByteBuffer indexBuffer = ByteBuffer.allocate(header.logCount * 4); 150 indexFile.read(indexBuffer.array()); 151 151 for (int i = 0; i < header.logCount; i++) 152 offsets.add(index File.readInt());152 offsets.add(indexBuffer.getInt()); 153 153 154 154 // reverse order
Note: See TracChangeset
for help on using the changeset viewer.
