Skip to content

Commit 6bef2b3

Browse files
authored
Merge pull request #135 from TileDB-Inc/sethshelnutt/ch1245/add-context-set-tag-support
Add support for context set_tags
2 parents 6fca9bb + 19890dd commit 6bef2b3

File tree

5 files changed

+56
-11
lines changed

5 files changed

+56
-11
lines changed

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ jar {
121121
from file("$buildDir/install/lib64/${System.mapLibraryName("tiledb")}")
122122
from file("$buildDir/install/lib64/${System.mapLibraryName("tiledbjni")}")
123123
}
124+
125+
manifest {
126+
attributes("Implementation-Title": "Gradle",
127+
"Implementation-Version": version)
128+
}
124129
}
125130

126131
task sourceJar(type: Jar) {

gradle/wrapper/gradle-wrapper.jar

1.45 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
34
zipStoreBase=GRADLE_USER_HOME
45
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip

gradlew

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22

33
##############################################################################
44
##
@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
3333
# Use the maximum available, or set MAX_FD != -1 to use that value.
3434
MAX_FD="maximum"
3535

36-
warn ( ) {
36+
warn () {
3737
echo "$*"
3838
}
3939

40-
die ( ) {
40+
die () {
4141
echo
4242
echo "$*"
4343
echo
@@ -154,16 +154,19 @@ if $cygwin ; then
154154
esac
155155
fi
156156

157-
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158-
function splitJvmOpts() {
159-
JVM_OPTS=("$@")
157+
# Escape application args
158+
save () {
159+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160+
echo " "
160161
}
161-
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162-
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
162+
APP_ARGS=$(save "$@")
163+
164+
# Collect all arguments for the java command, following the shell quoting and substitution rules
165+
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
163166

164167
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
165-
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
168+
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
166169
cd "$(dirname "$0")"
167170
fi
168171

169-
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
172+
exec "$JAVACMD" "$@"

src/main/java/io/tiledb/java/api/Context.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ private void createContext(Config config) throws TileDBError {
170170
this.ctxpp = _ctxpp;
171171
this.ctxp = tiledb.tiledb_ctx_tpp_value(_ctxpp);
172172
this.errorHandler = new ContextCallback();
173+
174+
// Set default tags
175+
setDefaultTags();
173176
}
174177

175178
protected SWIGTYPE_p_tiledb_ctx_t getCtxp() {
@@ -187,6 +190,40 @@ public Config getConfig() throws TileDBError {
187190
return new Config(_configpp);
188191
}
189192

193+
/**
194+
* Set context tasks
195+
*
196+
* @param key to set
197+
* @param value value to set
198+
* @throws TileDBError
199+
*/
200+
public void setTag(String key, String value) throws TileDBError {
201+
handleError(tiledb.tiledb_ctx_set_tag(ctxp, key, value));
202+
}
203+
204+
/**
205+
* Set default context tags
206+
*
207+
* @throws TileDBError
208+
*/
209+
private void setDefaultTags() throws TileDBError {
210+
setTag("x-tiledb-api-language", "java");
211+
Package pkg = Context.class.getPackage();
212+
if (pkg != null) {
213+
String version = pkg.getImplementationVersion();
214+
if (version != null) {
215+
setTag("x-tiledb-api-language-version", version);
216+
}
217+
}
218+
String platform =
219+
System.getProperty("os.name")
220+
+ "-"
221+
+ System.getProperty("os.verions")
222+
+ "-"
223+
+ System.getProperty("os.arch");
224+
setTag("x-tiledb-api-sys-platform", platform);
225+
}
226+
190227
/**
191228
* Close the context and delete all native objects. Should be called always to cleanup the context
192229
*/

0 commit comments

Comments
 (0)