11package 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