Skip to content

Commit

Permalink
Merge pull request #1252 from hbs/leveldb.fdb.functions
Browse files Browse the repository at this point in the history
Moved FDB/LevelDB function registrations in actual backend code
  • Loading branch information
hbs authored May 26, 2023
2 parents 26d8298 + ff02e1c commit e2f64d7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 41 deletions.
15 changes: 14 additions & 1 deletion warp10/src/main/java/io/warp10/fdb/FDBContext.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 SenX S.A.S.
// Copyright 2022-2023 SenX S.A.S.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -21,12 +21,25 @@

import com.apple.foundationdb.Database;

import io.warp10.script.WarpScriptLib;

public class FDBContext {

private final String clusterFile;
private final byte[] tenantPrefix;
private final byte[] tenantName;

static {
//
// FDB related functions
//

WarpScriptLib.addNamedWarpScriptFunction(new FDBTENANT(WarpScriptLib.FDBTENANT));
WarpScriptLib.addNamedWarpScriptFunction(new FDBSTATUS(WarpScriptLib.FDBSTATUS));
WarpScriptLib.addNamedWarpScriptFunction(new FDBSIZE(WarpScriptLib.FDBSIZE));
WarpScriptLib.addNamedWarpScriptFunction(new FDBGET(WarpScriptLib.FDBGET));
}

/**
* Field to keep track of the last seen read version. Used by FDBKVScanner to retry
* getRange operations which encountered an error 1037 (process_behind) which may occur
Expand Down
22 changes: 21 additions & 1 deletion warp10/src/main/java/io/warp10/leveldb/WarpDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

import io.warp10.continuum.store.Constants;
import io.warp10.script.WarpScriptException;
import io.warp10.script.WarpScriptLib;

public class WarpDB extends Thread implements DB {

Expand Down Expand Up @@ -79,6 +80,25 @@ public static enum WarpDBCommand {

private final LinkedBlockingQueue<WarpDBCommand> commandQ = new LinkedBlockingQueue<WarpDBCommand>(16);

static {
//
// LevelDB related functions
//

WarpScriptLib.addNamedWarpScriptFunction(new LEVELDBOPEN(WarpScriptLib.LEVELDBOPEN));
WarpScriptLib.addNamedWarpScriptFunction(new LEVELDBCLOSE(WarpScriptLib.LEVELDBCLOSE));
WarpScriptLib.addNamedWarpScriptFunction(new LEVELDBREPAIR(WarpScriptLib.LEVELDBREPAIR));
WarpScriptLib.addNamedWarpScriptFunction(new LEVELDBCOMPACT(WarpScriptLib.LEVELDBCOMPACT));
WarpScriptLib.addNamedWarpScriptFunction(new LEVELDBSNAPSHOT(WarpScriptLib.LEVELDBSNAPSHOT, false));
WarpScriptLib.addNamedWarpScriptFunction(new LEVELDBSNAPSHOT(WarpScriptLib.LEVELDBSNAPSHOTINC, true));
WarpScriptLib.addNamedWarpScriptFunction(new SSTFIND(WarpScriptLib.SSTFIND));
WarpScriptLib.addNamedWarpScriptFunction(new SSTINFO(WarpScriptLib.SSTINFO));
WarpScriptLib.addNamedWarpScriptFunction(new SSTPURGE(WarpScriptLib.SSTPURGE));
WarpScriptLib.addNamedWarpScriptFunction(new SSTREPORT(WarpScriptLib.SSTREPORT));
WarpScriptLib.addNamedWarpScriptFunction(new SSTTIMESTAMP(WarpScriptLib.SSTTIMESTAMP));

}

private static final class WarpIterator implements DBIterator {

private final DBIterator iter;
Expand Down Expand Up @@ -154,7 +174,7 @@ public WarpDB(boolean nativedisabled, boolean javadisabled, String home, Options
this.setDaemon(true);
this.start();

this.open(nativedisabled, javadisabled, home, options);
this.open(nativedisabled, javadisabled, home, options);
}

private synchronized void open(boolean nativedisabled, boolean javadisabled, String home, Options options) throws IOException {
Expand Down
39 changes: 0 additions & 39 deletions warp10/src/main/java/io/warp10/script/WarpScriptLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,10 @@
import io.warp10.continuum.gts.DISCORDS;
import io.warp10.continuum.gts.FFT;
import io.warp10.continuum.gts.GeoTimeSerie.TYPE;
import io.warp10.fdb.FDBGET;
import io.warp10.fdb.FDBSIZE;
import io.warp10.fdb.FDBSTATUS;
import io.warp10.fdb.FDBTENANT;
import io.warp10.continuum.gts.IFFT;
import io.warp10.continuum.gts.INTERPOLATE;
import io.warp10.continuum.gts.LOCATIONOFFSET;
import io.warp10.continuum.gts.ZIP;
import io.warp10.leveldb.LEVELDBOPEN;
import io.warp10.leveldb.LEVELDBCLOSE;
import io.warp10.leveldb.LEVELDBCOMPACT;
import io.warp10.leveldb.LEVELDBREPAIR;
import io.warp10.leveldb.LEVELDBSNAPSHOT;
import io.warp10.leveldb.SSTFIND;
import io.warp10.leveldb.SSTINFO;
import io.warp10.leveldb.SSTPURGE;
import io.warp10.leveldb.SSTREPORT;
import io.warp10.leveldb.SSTTIMESTAMP;
import io.warp10.script.aggregator.And;
import io.warp10.script.aggregator.Argminmax;
import io.warp10.script.aggregator.CircularMean;
Expand Down Expand Up @@ -3179,31 +3165,6 @@ public class WarpScriptLib {
addNamedWarpScriptFunction(new WSAUDIT(WSAUDIT));
addNamedWarpScriptFunction(new WSAUDITMODE(WSAUDITMODE));

//
// LevelDB
//

addNamedWarpScriptFunction(new LEVELDBOPEN(LEVELDBOPEN));
addNamedWarpScriptFunction(new LEVELDBCLOSE(LEVELDBCLOSE));
addNamedWarpScriptFunction(new LEVELDBREPAIR(LEVELDBREPAIR));
addNamedWarpScriptFunction(new LEVELDBCOMPACT(LEVELDBCOMPACT));
addNamedWarpScriptFunction(new LEVELDBSNAPSHOT(LEVELDBSNAPSHOT, false));
addNamedWarpScriptFunction(new LEVELDBSNAPSHOT(LEVELDBSNAPSHOTINC, true));
addNamedWarpScriptFunction(new SSTFIND(SSTFIND));
addNamedWarpScriptFunction(new SSTINFO(SSTINFO));
addNamedWarpScriptFunction(new SSTPURGE(SSTPURGE));
addNamedWarpScriptFunction(new SSTREPORT(SSTREPORT));
addNamedWarpScriptFunction(new SSTTIMESTAMP(SSTTIMESTAMP));

//
// FDB
//

addNamedWarpScriptFunction(new FDBTENANT(FDBTENANT));
addNamedWarpScriptFunction(new FDBSTATUS(FDBSTATUS));
addNamedWarpScriptFunction(new FDBSIZE(FDBSIZE));
addNamedWarpScriptFunction(new FDBGET(FDBGET));

/////////////////////////

int nregs = Integer.parseInt(WarpConfig.getProperty(Configuration.CONFIG_WARPSCRIPT_REGISTERS, String.valueOf(WarpScriptStack.DEFAULT_REGISTERS)));
Expand Down

0 comments on commit e2f64d7

Please sign in to comment.