public void delete() {
   if (name_buffer != null) {
     name_buffer.delete();
     name_buffer = null;
   }
   if (globalRef != 0) {
     NativeDB.DBJNI.DeleteGlobalRef(globalRef);
     globalRef = 0;
   }
 }
  public NativeComparator() {
    super(ComparatorJNI.create());
    try {
      name_buffer = NativeBuffer.create(name());
      globalRef = NativeDB.DBJNI.NewGlobalRef(this);
      if (globalRef == 0) {
        throw new RuntimeException("jni call failed: NewGlobalRef");
      }
      ComparatorJNI struct = new ComparatorJNI();
      struct.compare_method = NativeDB.DBJNI.GetMethodID(this.getClass(), "compare", "(JJ)I");
      if (struct.compare_method == 0) {
        throw new RuntimeException("jni call failed: GetMethodID");
      }
      struct.target = globalRef;
      struct.name = name_buffer.pointer();
      ComparatorJNI.memmove(self, struct, ComparatorJNI.SIZEOF);

    } catch (RuntimeException e) {
      delete();
      throw e;
    }
  }
Beispiel #3
0
 public NativeSlice set(NativeBuffer buffer) {
   this.size_ = buffer.capacity();
   this.data_ = buffer.pointer();
   return this;
 }
Beispiel #4
0
 static NativeBuffer arrayCreate(int dimension) {
   return NativeBuffer.create(dimension * SliceJNI.SIZEOF);
 }
Beispiel #5
0
 public NativeSlice(NativeBuffer buffer) {
   this(buffer.pointer(), buffer.capacity());
 }