Skip to content

Commit 4f7c130

Browse files
committed
update definition of native pixels cache reader
1 parent 81b6bf3 commit 4f7c130

File tree

4 files changed

+100
-5
lines changed

4 files changed

+100
-5
lines changed

cpp/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
all: JNITest
1+
all: NativePixelsCacheReader
22

3-
JNITest:
4-
$(CXX) -shared -fPIC JNITest.cc -o JNITest.so -I/usr/lib/jvm/java-1.8.0-openjdk-amd64/include/ -I/usr/lib/jvm/java-8-openjdk-amd64/include/linux/
3+
NativePixelsCacheReader:
4+
$(CXX) -shared -fPIC $@.cc -o lib_pixels.so -I/usr/lib/jvm/java-1.8.0-openjdk-amd64/include/ -I/usr/lib/jvm/java-8-openjdk-amd64/include/linux/
55

66
clean:
7-
rm -rf ./JNITest.so
7+
rm -rf ./lib_pixels.so

cpp/NativePixelsCacheReader.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <iostream>
2+
#include "NativePixelsCacheReader.h"
3+
using namespace std;
4+
5+
JNIEXPORT jbyteArray JNICALL Java_cn_edu_ruc_iir_pixels_cache_NativePixelsCacheReader_get
6+
(JNIEnv *env, jclass cls, jlong blockId, jshort rowGroupId, jshort columnId)
7+
{
8+
jbyteArray res;
9+
return res;
10+
}
11+
12+
13+
JNIEXPORT jbyteArray JNICALL Java_cn_edu_ruc_iir_pixels_cache_NativePixelsCacheReader_sch
14+
(JNIEnv *env, jclass cls, jlong blockId, jshort rowGroupId, jshort columnId)
15+
{
16+
jbyteArray res;
17+
return res;
18+
}

cpp/NativePixelsCacheReader.h

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixels-cache/src/main/java/cn/edu/ruc/iir/pixels/cache/NativePixelsCacheReader.java

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package cn.edu.ruc.iir.pixels.cache;
22

3+
import java.nio.ByteBuffer;
4+
import java.nio.ByteOrder;
5+
36
/**
47
* Created at: 19-5-11
58
* Author: hank
@@ -10,6 +13,7 @@ public class NativePixelsCacheReader
1013
private long indexFileSize;
1114
private String cacheFileLocation;
1215
private long cacheFileSize;
16+
private ByteBuffer keyBuffer = ByteBuffer.allocate(PixelsCacheKey.SIZE).order(ByteOrder.BIG_ENDIAN);
1317

1418
public NativePixelsCacheReader(String indexFileLocation, long indexFileSize,
1519
String cacheFileLocation, long cacheFileSize)
@@ -25,5 +29,49 @@ public NativePixelsCacheReader(String indexFileLocation, long indexFileSize,
2529
System.loadLibrary("lib_pixels.so");
2630
}
2731

28-
private native byte[] getFromCache();
32+
public static class Builder
33+
{
34+
private String builderIndexFileLocation;
35+
private long builderIndexFileSize;
36+
private String builderCacheFileLocation;
37+
private long builderCacheFileSize;
38+
39+
private Builder()
40+
{
41+
}
42+
43+
public NativePixelsCacheReader.Builder setCacheFile(String location, long size)
44+
{
45+
this.builderCacheFileLocation = location;
46+
this.builderCacheFileSize = size;
47+
return this;
48+
}
49+
50+
public NativePixelsCacheReader.Builder setIndexFile(String location, long size)
51+
{
52+
this.builderIndexFileLocation = location;
53+
this.builderIndexFileSize = size;
54+
return this;
55+
}
56+
57+
public NativePixelsCacheReader build()
58+
{
59+
return new NativePixelsCacheReader(builderIndexFileLocation, builderIndexFileSize,
60+
builderCacheFileLocation, builderCacheFileSize);
61+
}
62+
}
63+
64+
public static NativePixelsCacheReader.Builder newBuilder()
65+
{
66+
return new NativePixelsCacheReader.Builder();
67+
}
68+
69+
public static native byte[] get(long blockId, short rowGroupId, short columnId);
70+
71+
public PixelsCacheIdx search(long blockId, short rowGroupId, short columnId)
72+
{
73+
return new PixelsCacheIdx(sch(blockId, rowGroupId, columnId));
74+
}
75+
76+
private static native byte[] sch(long blockId, short rowGroupId, short columnId);
2977
}

0 commit comments

Comments
 (0)