How to use the @xviz/parser.XVIZStreamBuffer function in @xviz/parser

To help you get started, we’ve selected a few @xviz/parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uber / xviz / test / modules / parser / synchronizers / stream-synchronizer.spec.js View on Github external
tape('StreamSynchronizer#correct lookup with empty entries (explicit no-data)', t => {
  resetXVIZConfigAndSettings();
  setXVIZConfig({TIME_WINDOW: 3});

  const STREAMS_WITH_NO_DATA_ENTRIES = new XVIZStreamBuffer();
  STREAMS_WITH_NO_DATA_ENTRIES.timeslices = [
    {
      // start both with no-data entry
      timestamp: 90,
      streams: {
        stream1: null,
        stream2: null
      }
    },
    {
      // stream1 has entry
      timestamp: 100,
      streams: {
        stream1: {value: 1}
      }
    },
github uber / xviz / test / modules / parser / synchronizers / stream-synchronizer.spec.js View on Github external
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import {StreamSynchronizer, XVIZStreamBuffer, setXVIZConfig} from '@xviz/parser';
import tape from 'tape-catch';
import {equals} from 'math.gl';

import {resetXVIZConfigAndSettings} from '../config/config-utils';

// xviz data uses snake_case
/* eslint-disable camelcase */

/* NOTE: keep in sync with tests in log-synchronizer.spec.js */
const TEST_BUFFER = new XVIZStreamBuffer();
TEST_BUFFER.timeslices = [
  {
    timestamp: 50,
    streams: {
      log1: {value: 1},
      log2: {value: 10}
    }
  },
  {
    timestamp: 100,
    streams: {
      log1: {value: 1},
      log2: {value: 20}
    }
  },
  {
github uber / streetscape.gl / modules / core / src / loaders / xviz-live-loader.js View on Github external
// Construct websocket connection details from parameters
    this.requestParams = getSocketRequestParams(options);
    assert(this.requestParams.bufferLength, 'bufferLength must be provided');

    this.retrySettings = {
      retries: this.requestParams.retryAttempts,
      minTimeout: 500,
      randomize: true
    };

    // Setup relative stream buffer storage by splitting bufferLength 1/3 : 2/3
    const bufferChunk = this.requestParams.bufferLength / 3;

    // Replace base class object
    this.streamBuffer = new XVIZStreamBuffer({
      startOffset: -2 * bufferChunk,
      endOffset: bufferChunk
    });
  }
github uber / xviz / test / modules / parser / synchronizers / xviz-stream-buffer.spec.js View on Github external
test('XVIZStreamBuffer#size, getTimeslices', t => {
  const xvizStreamBuffer = new XVIZStreamBuffer();
  t.is(xvizStreamBuffer.size, 0, 'returns correct size');

  xvizStreamBuffer.timeslices = TEST_TIMESLICES_SORTED.slice();
  t.is(xvizStreamBuffer.size, 5, 'returns correct size');

  let timeslices = xvizStreamBuffer.getTimeslices({start: 800, end: 900});
  t.is(timeslices.length, 0, 'returns correct timeslices');

  timeslices = xvizStreamBuffer.getTimeslices({start: 1000, end: 2000});
  t.is(timeslices.length, 5, 'returns correct timeslices');

  timeslices = xvizStreamBuffer.getTimeslices({start: 1000, end: 1004});
  t.is(timeslices.length, 4, 'returns correct timeslices');

  timeslices = xvizStreamBuffer.getTimeslices({start: 1006, end: 2000});
  t.is(timeslices.length, 0, 'returns correct timeslices');
github uber / xviz / test / modules / parser / synchronizers / xviz-stream-buffer.spec.js View on Github external
test('XVIZStreamBuffer#updateFixedBuffer uncapped expansion', t => {
  const xvizStreamBuffer = new XVIZStreamBuffer();
  xvizStreamBuffer.updateFixedBuffer(1002, 1004);
  const {start, end, oldStart, oldEnd} = xvizStreamBuffer.updateFixedBuffer(1000, 1010);

  t.is(start, 1000, 'expands buffer start');
  t.is(end, 1010, 'expands buffer end');
  t.is(oldStart, 1002, 'returns old buffer start');
  t.is(oldEnd, 1004, 'returns old buffer end');
  t.is(xvizStreamBuffer.bufferType, 2, 'buffer is limited');
  t.end();
});
github uber / xviz / test / modules / parser / synchronizers / xviz-stream-buffer.spec.js View on Github external
test('XVIZStreamBuffer#updateFixedBuffer small forward slides', t => {
  const xvizStreamBuffer = new XVIZStreamBuffer({maxLength: 30});
  xvizStreamBuffer.updateFixedBuffer(990, 1004);
  const {start, end} = xvizStreamBuffer.updateFixedBuffer(1008, 1030);

  t.is(start, 1000, 'buffer start slides forward based on max length');
  t.is(end, 1030, 'buffer end uses provided');
  t.end();
});
github uber / xviz / test / modules / parser / synchronizers / xviz-stream-buffer.spec.js View on Github external
test('XVIZStreamBuffer#insert, getStreams', t => {
  const xvizStreamBuffer = new XVIZStreamBuffer();
  let timeslices;
  let {lastUpdate} = xvizStreamBuffer;

  TEST_CASES.forEach(sample => {
    xvizStreamBuffer.insert(sample.message);

    timeslices = xvizStreamBuffer.getTimeslices();

    const inserted = timeslices.find(timeslice => timeslice.timestamp === sample.message.timestamp);
    t.deepEquals(inserted.streams, sample.snapshot, 'timeslice is inserted');

    t.not(lastUpdate, xvizStreamBuffer.lastUpdate, 'lastUpdate timestamp has changed');

    lastUpdate = xvizStreamBuffer.lastUpdate;

    let prevTimeslice = null;
github uber / xviz / test / modules / parser / synchronizers / xviz-stream-buffer.spec.js View on Github external
test('XVIZStreamBuffer#constructor', t => {
  const xvizStreamBuffer = new XVIZStreamBuffer();
  t.ok(xvizStreamBuffer instanceof XVIZStreamBuffer, 'constructor does not throw error');
  t.not(xvizStreamBuffer.isLimited, 'buffer is unlimited');

  const xvizStreamBufferLimited = new XVIZStreamBuffer({
    startOffset: -1,
    endOffset: 5
  });
  t.ok(xvizStreamBufferLimited instanceof XVIZStreamBuffer, 'constructor does not throw error');
  t.is(xvizStreamBufferLimited.bufferType, 1, 'buffer is limited');

  t.throws(() => new XVIZStreamBuffer({startOffset: 1, endOffset: 5}), 'validates parameters');

  t.end();
});
github uber / xviz / test / modules / parser / synchronizers / xviz-stream-buffer.spec.js View on Github external
streams: {X: 20, Y: 30, Z: -1}
      },
      expect: {A: 5, X: 20, Y: 30, Z: -1}
    },
    {
      title: 'merge',
      message: {
        updateType: 'PERSISTENT',
        timestamp: 900,
        streams: {Y: null}
      },
      expect: {A: 5, X: 20, Y: 20, Z: -1}
    }
  ];

  const xvizStreamBuffer = new XVIZStreamBuffer();
  xvizStreamBuffer.insert({
    timestamp: 1000,
    streams: {A: 5}
  });

  for (const testCase of testCases) {
    const {lastUpdate} = xvizStreamBuffer;
    t.ok(xvizStreamBuffer.insert(testCase.message), 'persistent timeslice inserted');
    t.ok(xvizStreamBuffer.lastUpdate > lastUpdate, 'update counter updated');

    const timeslices = xvizStreamBuffer.getTimeslices({start: 1000, end: 1001});
    const streams = {};
    timeslices.forEach(timeslice => {
      for (const streamName in timeslice.streams) {
        streams[streamName] = timeslice.streams[streamName] || streams[streamName];
      }
github uber / xviz / test / modules / parser / synchronizers / stream-synchronizer.spec.js View on Github external
tape('StreamSynchronizer#getCurrentFrame links', t => {
  resetXVIZConfigAndSettings();
  setXVIZConfig({TIME_WINDOW: 3});

  const testBuffer = new XVIZStreamBuffer();
  testBuffer.timeslices = [
    {
      timestamp: 50,
      streams: {
        log1: {value: 1},
        log2: {value: 10}
      },
      links: {
        log2: {
          target_pose: 'log1'
        }
      }
    }
  ];

  const streamSynchronizer = new StreamSynchronizer(testBuffer);