Last updated

Big Data

This tutorial shows how to handle a relatively large number of samples. It has two curves with more than one million samples each and 2d visual. This tutorial creates dataset geotoolkit/data/DataSet to control data requests and memory usage. The data set contains 2 tables: a table with three columns: index column (time), GR, RHOB for simple curves and a table for 2d visual.

# Widget with Big Data

import { Plot } from "@int/geotoolkit/plot/Plot.ts";
import { HeaderType } from "@int/geotoolkit/welllog/header/LogAxisVisualHeader.ts";
import { TrackType } from "@int/geotoolkit/welllog/TrackType.ts";
import { LogCurve } from "@int/geotoolkit/welllog/LogCurve.ts";
import { LogData } from "@int/geotoolkit/welllog/data/LogData.ts";
import { MemoryDataSource } from "/src/code/WellLog/DataAndTemplates/BigData/memorydatasource.ts";
import { create2DVisual } from "/src/code/WellLog/DataAndTemplates/BigData/create2DVisual.ts";
import { log2DData } from "/src/code/WellLog/DataAndTemplates/BigData/log2DData.ts";
import { defaults } from "/src/helpers/defaults.js";
import { createWellLogWidget } from "/src/code/WellLog/utils/common.ts";
class BigData {
  constructor(options) {
    this.data = new MemoryDataSource();
    this.widget = this.createWidget();
    this.plot = new Plot({
      "canvaselement": options.canvas,
      "root": this.widget
    });
    this.setDataDecimation(options.decimation);
    this.setRealTime(options.realtime);
  }
  dispose() {
    if (this.plot) {
      this.plot.dispose();
    }
    if (this.data) {
      this.data.dispose();
    }
  }
  createWidget() {
    const widget = createWellLogWidget({
      "indextype": "time",
      "indexunit": "ms"
    });
    widget.setAxisHeaderType(HeaderType.Simple);
    widget.addTrack(TrackType.IndexTrack);
    widget.addTrack(TrackType.LinearTrack).addChild([
      new LogCurve(new LogData("GR")).setLineStyle("green")
    ]);
    widget.addTrack(TrackType.LogTrack).addChild([
      new LogCurve(new LogData("RHOB")).setLineStyle("red")
    ]);
    widget.addTrack(TrackType.LinearTrack).addChild([
      create2DVisual("Log 2D", log2DData.min, log2DData.max)
    ]);
    widget.setDepthScale(1e7);
    this.data.connect(widget);
    widget.setData(this.data);
    return widget;
  }
  setDataDecimation(enabled) {
    this.data.enableDecimation(enabled);
  }
  setRealTime(enabled) {
    this.data.enableRealTime(enabled);
  }
  zoomIn() {
    this.widget.scale(defaults.zoomInScale);
  }
  zoomOut() {
    this.widget.scale(defaults.zoomOutScale);
  }
  fitToHeight() {
    this.widget.fitToHeight();
  }
}
export { BigData };

createScene();

# Visible limits changed

The WellLog widget listens if visible limits are changed because of scrolling, panning or zooming. On each change, method fetch is called to specify a time range and the current scale to update data.
The dataset can emit two events:

  • geotoolkit/data/Events.DataFetching to request data.
  • geotoolkit/data/Events.Updated to notify if dataset is invalid.

If geotoolkit/data/Events.DataFetching is received, provide the requested data by sending a query to the server to retrieve data. When data is received, call a callback method to provide data or if it failed, then send an error message. In the current display, fill the necessary range from the prepared datasource. The code below shows three events handlers.