Skip to content

Commit a2d332b

Browse files
committed
Index Trace
1 parent 14dbe85 commit a2d332b

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

pixels-daemon/src/main/java/io/pixelsdb/pixels/daemon/retina/RetinaServerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
public class RetinaServerImpl extends RetinaWorkerServiceGrpc.RetinaWorkerServiceImplBase
5151
{
5252
private static final Logger logger = LogManager.getLogger(RetinaServerImpl.class);
53+
5354
private final MetadataService metadataService;
5455
private final IndexService indexService;
5556
private final RetinaResourceManager retinaResourceManager;

pixels-daemon/src/main/resources/log4j2.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,15 @@ appender.rolling.layout.pattern = %-d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n
1919
rootLogger.level = info
2020
rootLogger.appenderRef.stdout.ref = STDOUT
2121
rootLogger.appenderRef.log.ref = log
22+
23+
appender.index.type = File
24+
appender.index.name = INDEX_OUT
25+
appender.index.fileName = ${env:PIXELS_HOME}/logs/index.trace
26+
appender.index.append = true
27+
appender.index.layout.type = PatternLayout
28+
appender.index.layout.pattern = %m%n
29+
30+
logger.index.name = index
31+
logger.index.level = info
32+
logger.index.additivity = false
33+
logger.index.appenderRef.index.ref = INDEX_OUT

pixels-index/pixels-index-rocksdb/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@
6666
<artifactId>grpc-stub</artifactId>
6767
<scope>test</scope>
6868
</dependency>
69+
70+
<dependency>
71+
<!-- this is only for third-party libs that use slf4j -->
72+
<groupId>org.apache.logging.log4j</groupId>
73+
<artifactId>log4j-slf4j-impl</artifactId>
74+
<optional>true</optional>
75+
</dependency>
76+
<dependency>
77+
<!-- this is only for third-party libs that use log4j-1 -->
78+
<groupId>org.slf4j</groupId>
79+
<artifactId>log4j-over-slf4j</artifactId>
80+
<optional>true</optional>
81+
</dependency>
6982
</dependencies>
7083

7184
<build>

pixels-index/pixels-index-rocksdb/src/main/java/io/pixelsdb/pixels/index/rocksdb/RocksDBIndex.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import io.pixelsdb.pixels.index.IndexProto;
2727
import org.apache.commons.io.FileUtils;
2828
import org.rocksdb.*;
29+
import org.slf4j.Logger;
30+
import org.slf4j.LoggerFactory;
2931

3032
import java.io.File;
3133
import java.io.IOException;
@@ -40,6 +42,8 @@
4042
*/
4143
public class RocksDBIndex implements SinglePointIndex
4244
{
45+
private static final Logger indexLogger = LoggerFactory.getLogger("index");
46+
4347
private final RocksDB rocksDB;
4448
private final String rocksDBPath;
4549
private final WriteOptions writeOptions;
@@ -166,6 +170,12 @@ public boolean putEntry(IndexProto.IndexKey key, long rowId) throws SinglePointI
166170
ByteBuffer nonUniqueKeyBuffer = toNonUniqueKeyBuffer(key, rowId);
167171
rocksDB.put(writeOptions, nonUniqueKeyBuffer, EMPTY_VALUE_BUFFER);
168172
}
173+
indexLogger.info("P\t{}\t{}\t{}\t{}\t{}",
174+
tableId,
175+
indexId,
176+
key.getKey().asReadOnlyByteBuffer().getInt(),
177+
key.getTimestamp(),
178+
rowId);
169179
return true;
170180
}
171181
catch (RocksDBException e)
@@ -187,6 +197,13 @@ public boolean putPrimaryEntries(List<IndexProto.PrimaryIndexEntry> entries) thr
187197
ByteBuffer valueBuffer = RocksDBThreadResources.getValueBuffer();
188198
valueBuffer.putLong(rowId).position(0);
189199
writeBatch.put(keyBuffer, valueBuffer);
200+
indexLogger.info("P\t{}\t{}\t{}\t{}\t{}",
201+
tableId,
202+
indexId,
203+
entry.getIndexKey().getKey().asReadOnlyByteBuffer().getInt(),
204+
entry.getIndexKey().getTimestamp(),
205+
entry.getRowId()
206+
);
190207
}
191208
rocksDB.write(writeOptions, writeBatch);
192209
return true;
@@ -238,6 +255,13 @@ public long updatePrimaryEntry(IndexProto.IndexKey key, long rowId) throws Singl
238255
ByteBuffer valueBuffer = RocksDBThreadResources.getValueBuffer();
239256
valueBuffer.putLong(rowId).position(0);
240257
rocksDB.put(writeOptions, keyBuffer, valueBuffer);
258+
indexLogger.info("U\t{}\t{}\t{}\t{}\t{}",
259+
tableId,
260+
indexId,
261+
key.getKey().asReadOnlyByteBuffer().getInt(),
262+
key.getTimestamp(),
263+
rowId
264+
);
241265
return prevRowId;
242266
}
243267
catch (RocksDBException e)
@@ -289,6 +313,13 @@ public List<Long> updatePrimaryEntries(List<IndexProto.PrimaryIndexEntry> entrie
289313
ByteBuffer valueBuffer = RocksDBThreadResources.getValueBuffer();
290314
valueBuffer.putLong(rowId).position(0);
291315
writeBatch.put(keyBuffer, valueBuffer);
316+
indexLogger.info("U\t{}\t{}\t{}\t{}\t{}",
317+
tableId,
318+
indexId,
319+
key.getKey().asReadOnlyByteBuffer().getInt(),
320+
key.getTimestamp(),
321+
rowId
322+
);
292323
}
293324
rocksDB.write(writeOptions, writeBatch);
294325
return builder.build();
@@ -399,6 +430,11 @@ public List<Long> deleteEntries(List<IndexProto.IndexKey> keys) throws SinglePoi
399430
// Delete single point index
400431
for(IndexProto.IndexKey key : keys)
401432
{
433+
indexLogger.info("D\t{}\t{}\t{}\t{}",
434+
tableId,
435+
indexId,
436+
key.getKey().asReadOnlyByteBuffer().getInt(),
437+
key.getTimestamp());
402438
if(unique)
403439
{
404440
long rowId = getUniqueRowId(key);

0 commit comments

Comments
 (0)