Example #1
0
 public static NativeDB open(NativeOptions options, File path) throws IOException, DBException {
   checkArgNotNull(options, "options");
   checkArgNotNull(path, "path");
   long rc[] = new long[1];
   try {
     checkStatus(DBJNI.Open(options, path.getCanonicalPath(), rc));
   } catch (IOException e) {
     if (rc[0] != 0) {
       DBJNI.delete(rc[0]);
     }
     throw e;
   }
   return new NativeDB(rc[0]);
 }
Example #2
0
  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;
  }
Example #3
0
 private byte[] get(NativeReadOptions options, NativeSlice keySlice) throws DBException {
   assertAllocated();
   NativeStdString result = new NativeStdString();
   try {
     checkStatus(DBJNI.Get(self, options, keySlice, result.pointer()));
     return result.toByteArray();
   } finally {
     result.delete();
   }
 }
Example #4
0
 private byte[] getProperty(NativeSlice nameSlice) {
   assertAllocated();
   NativeStdString result = new NativeStdString();
   try {
     if (DBJNI.GetProperty(self, nameSlice, result.pointer())) {
       return result.toByteArray();
     } else {
       return null;
     }
   } finally {
     result.delete();
   }
 }
Example #5
0
 public static void repair(File path, NativeOptions options) throws IOException, DBException {
   checkArgNotNull(options, "options");
   checkArgNotNull(path, "path");
   checkStatus(DBJNI.RepairDB(path.getCanonicalPath(), options));
 }
Example #6
0
 public NativeIterator iterator(NativeReadOptions options) {
   checkArgNotNull(options, "options");
   return new NativeIterator(DBJNI.NewIterator(self, options));
 }
Example #7
0
 public void releaseSnapshot(NativeSnapshot snapshot) {
   checkArgNotNull(snapshot, "snapshot");
   DBJNI.ReleaseSnapshot(self, snapshot.pointer());
 }
Example #8
0
 public NativeSnapshot getSnapshot() {
   return new NativeSnapshot(DBJNI.GetSnapshot(self));
 }
Example #9
0
 public void write(NativeWriteOptions options, NativeWriteBatch updates) throws DBException {
   checkArgNotNull(options, "options");
   checkArgNotNull(updates, "updates");
   checkStatus(DBJNI.Write(self, options, updates.pointer()));
 }
Example #10
0
 private void delete(NativeWriteOptions options, NativeSlice keySlice) throws DBException {
   assertAllocated();
   checkStatus(DBJNI.Delete(self, options, keySlice));
 }
Example #11
0
 private void put(NativeWriteOptions options, NativeSlice keySlice, NativeSlice valueSlice)
     throws DBException {
   assertAllocated();
   checkStatus(DBJNI.Put(self, options, keySlice, valueSlice));
 }
Example #12
0
 public void delete() {
   assertAllocated();
   DBJNI.delete(self);
   self = 0;
 }