public long[] getApproximateSizes(NativeRange... ranges) { if (ranges == null) { return null; } long rc[] = new long[ranges.length]; NativeRange.RangeJNI structs[] = new NativeRange.RangeJNI[ranges.length]; if (rc.length > 0) { NativeBuffer range_array = NativeRange.RangeJNI.arrayCreate(ranges.length); try { for (int i = 0; i < ranges.length; i++) { structs[i] = new NativeRange.RangeJNI(ranges[i]); structs[i].arrayWrite(range_array.pointer(), i); } DBJNI.GetApproximateSizes(self, range_array.pointer(), ranges.length, rc); } finally { for (int i = 0; i < ranges.length; i++) { if (structs[i] != null) { structs[i].delete(); } } range_array.delete(); } } return rc; }
public byte[] get(NativeReadOptions options, byte[] key) throws DBException { checkArgNotNull(options, "options"); checkArgNotNull(key, "key"); NativeBuffer keyBuffer = new NativeBuffer(key); try { return get(options, keyBuffer); } finally { keyBuffer.delete(); } }
public void delete(NativeWriteOptions options, byte[] key) throws DBException { checkArgNotNull(options, "options"); checkArgNotNull(key, "key"); NativeBuffer keyBuffer = new NativeBuffer(key); try { delete(options, keyBuffer); } finally { keyBuffer.delete(); } }
public String getProperty(String name) { checkArgNotNull(name, "name"); NativeBuffer keyBuffer = new NativeBuffer(name.getBytes()); try { byte[] property = getProperty(keyBuffer); if (property == null) { return null; } else { return new String(property); } } finally { keyBuffer.delete(); } }
public void put(NativeWriteOptions options, byte[] key, byte[] value) throws DBException { checkArgNotNull(options, "options"); checkArgNotNull(key, "key"); checkArgNotNull(value, "value"); NativeBuffer keyBuffer = new NativeBuffer(key); try { NativeBuffer valueBuffer = new NativeBuffer(value); try { put(options, keyBuffer, valueBuffer); } finally { valueBuffer.delete(); } } finally { keyBuffer.delete(); } }
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; } }
static NativeBuffer arrayCreate(int dimension) { return NativeBuffer.create(dimension * SliceJNI.SIZEOF); }
public NativeSlice set(NativeBuffer buffer) { this.size_ = buffer.capacity(); this.data_ = buffer.pointer(); return this; }
public NativeSlice(NativeBuffer buffer) { this(buffer.pointer(), buffer.capacity()); }