Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
s4gh committed Oct 7, 2024
1 parent 219c2e0 commit 27b908a
Show file tree
Hide file tree
Showing 56 changed files with 5,169 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/class-name-casing": "warn",
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
out
node_modules
.vscode-test/
*.vsix
36 changes: 36 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
20 changes: 20 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
11 changes: 11 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.vscode/**
.vscode-test/**
out/test/**
src/**
java/jshell/**
.gitignore
vsc-extension-quickstart.md
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# JShell Notebook

This plugin provides support for notebools which can have markdown documentation cells and code cells. It uses JShell to evaluate code snippets

# Preparation

- Install the extension
- Install Plugin which renders JSON output as table https://github.com/RandomFractals/vscode-data-table
- Optionally install
Plugin to render dfferent visualtaions of data in jupyper format https://github.com/Microsoft/vscode-notebook-renderers (not currently used. There are plans to use it in future)

## Use

- create file with .jshnb file, "Open With..."
- Select "JShell Notebook"
- Add markdown or code cells. Use build in ```show(Object o)``` method do display cell output. There is also ```showTable(org.apache.flink.table.api.Table table)``` method to execute Flink table and render it as JSON
- Create cell with the command to set flink class path:

```
/env --class-path /home/serhiy/.m2/repository/org/apache/flink/flink-clients/1.20.0/flink-clients-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-core/1.20.0/flink-core-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-core-api/1.20.0/flink-core-api-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-metrics-core/1.20.0/flink-metrics-core-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-annotations/1.20.0/flink-annotations-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-shaded-asm-9/9.5-17.0/flink-shaded-asm-9-9.5-17.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-shaded-jackson/2.14.2-17.0/flink-shaded-jackson-2.14.2-17.0.jar:/home/serhiy/.m2/repository/org/snakeyaml/snakeyaml-engine/2.6/snakeyaml-engine-2.6.jar:/home/serhiy/.m2/repository/org/apache/commons/commons-text/1.10.0/commons-text-1.10.0.jar:/home/serhiy/.m2/repository/com/esotericsoftware/kryo/kryo/2.24.0/kryo-2.24.0.jar:/home/serhiy/.m2/repository/com/esotericsoftware/minlog/minlog/1.2/minlog-1.2.jar:/home/serhiy/.m2/repository/org/objenesis/objenesis/2.1/objenesis-2.1.jar:/home/serhiy/.m2/repository/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar:/home/serhiy/.m2/repository/org/apache/commons/commons-compress/1.26.0/commons-compress-1.26.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-runtime/1.20.0/flink-runtime-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-rpc-core/1.20.0/flink-rpc-core-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-rpc-akka-loader/1.20.0/flink-rpc-akka-loader-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-queryable-state-client-java/1.20.0/flink-queryable-state-client-java-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-hadoop-fs/1.20.0/flink-hadoop-fs-1.20.0.jar:/home/serhiy/.m2/repository/commons-io/commons-io/2.15.1/commons-io-2.15.1.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-shaded-netty/4.1.91.Final-17.0/flink-shaded-netty-4.1.91.Final-17.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-shaded-zookeeper-3/3.7.1-17.0/flink-shaded-zookeeper-3-3.7.1-17.0.jar:/home/serhiy/.m2/repository/org/javassist/javassist/3.24.0-GA/javassist-3.24.0-GA.jar:/home/serhiy/.m2/repository/org/xerial/snappy/snappy-java/1.1.10.4/snappy-java-1.1.10.4.jar:/home/serhiy/.m2/repository/tools/profiler/async-profiler/2.9/async-profiler-2.9.jar:/home/serhiy/.m2/repository/org/lz4/lz4-java/1.8.0/lz4-java-1.8.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-optimizer/1.20.0/flink-optimizer-1.20.0.jar:/home/serhiy/.m2/repository/commons-cli/commons-cli/1.5.0/commons-cli-1.5.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-datastream/1.20.0/flink-datastream-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-datastream-api/1.20.0/flink-datastream-api-1.20.0.jar:/home/serhiy/.m2/repository/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar:/home/serhiy/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-table-api-java-bridge/1.20.0/flink-table-api-java-bridge-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-table-api-java/1.20.0/flink-table-api-java-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-table-api-bridge-base/1.20.0/flink-table-api-bridge-base-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-java/1.20.0/flink-java-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar:/home/serhiy/.m2/repository/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar:/home/serhiy/.m2/repository/com/twitter/chill-java/0.7.6/chill-java-0.7.6.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-streaming-java/1.20.0/flink-streaming-java-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-file-sink-common/1.20.0/flink-file-sink-common-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-shaded-guava/31.1-jre-17.0/flink-shaded-guava-31.1-jre-17.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-connector-datagen/1.20.0/flink-connector-datagen-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-table-runtime/1.20.0/flink-table-runtime-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-table-common/1.20.0/flink-table-common-1.20.0.jar:/home/serhiy/.m2/repository/com/ibm/icu/icu4j/67.1/icu4j-67.1.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-cep/1.20.0/flink-cep-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-connector-files/1.20.0/flink-connector-files-1.20.0.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-table-planner_2.12/1.20.0/flink-table-planner_2.12-1.20.0.jar:/home/serhiy/.m2/repository/org/immutables/value/2.8.8/value-2.8.8.jar:/home/serhiy/.m2/repository/org/immutables/value-annotations/2.8.8/value-annotations-2.8.8.jar:/home/serhiy/.m2/repository/org/codehaus/janino/commons-compiler/3.1.10/commons-compiler-3.1.10.jar:/home/serhiy/.m2/repository/org/codehaus/janino/janino/3.1.10/janino-3.1.10.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-scala_2.12/1.20.0/flink-scala_2.12-1.20.0.jar:/home/serhiy/.m2/repository/org/scala-lang/scala-reflect/2.12.7/scala-reflect-2.12.7.jar:/home/serhiy/.m2/repository/org/scala-lang/scala-library/2.12.7/scala-library-2.12.7.jar:/home/serhiy/.m2/repository/org/scala-lang/scala-compiler/2.12.7/scala-compiler-2.12.7.jar:/home/serhiy/.m2/repository/org/scala-lang/modules/scala-xml_2.12/1.0.6/scala-xml_2.12-1.0.6.jar:/home/serhiy/.m2/repository/com/twitter/chill_2.12/0.7.6/chill_2.12-0.7.6.jar:/home/serhiy/.m2/repository/org/apache/flink/flink-csv/1.20.0/flink-csv-1.20.0.jar
```
- Add cell with sample Flink code. Example below used remote axecution environment and expects that Flink is started as a separate process

```java
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.*;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl;
import org.apache.flink.table.types.DataType;
import org.apache.flink.types.Row;

import java.util.HashMap;
import java.util.List;

Configuration conf = new Configuration();
StreamExecutionEnvironment senv = StreamExecutionEnvironment.createRemoteEnvironment(
"127.0.0.1",
8081,
null);
StreamTableEnvironment tableEnv = StreamTableEnvironmentImpl.create(senv, EnvironmentSettings.newInstance().withConfiguration(conf).build());


DataType rowType = DataTypes.ROW(
DataTypes.FIELD("NAME", DataTypes.STRING()),
DataTypes.FIELD("ADDRESS", DataTypes.STRING())
);

Table sampleTable = tableEnv.fromValues(
rowType,
Row.of("Alice Johnson", "123 Main St, Anytown"),
Row.of("Bob Smith", "456 Oak Ave, Somewhere"),
Row.of("Charlie Brown", "789 Pine Rd, Elsewhere")
);

tableEnv.createTemporaryView("people", sampleTable);

Table result = tableEnv.from("people");

showTable(result);
```
- Execute cells

## Notes
Java™, Java™ SE, Java™ EE, and OpenJDK™ are trademarks of Oracle and/or its affiliates.
Binary file added images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions java/jshell/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions java/jshell/.idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions java/jshell/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions java/jshell/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions java/jshell/.idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions java/jshell/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions java/jshell/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 27b908a

Please sign in to comment.