From dcfb657e5de65c656cfa29db8498a4bef854bea9 Mon Sep 17 00:00:00 2001 From: Wout Schellaert Date: Wed, 29 Nov 2017 17:37:37 +0100 Subject: [PATCH] Merge pull request #12 from wschella/type-tree Type tree --- packages/sparqlee/benchmarks/Examples.ts | 1 - packages/sparqlee/benchmarks/Testing.ts | 21 ++ packages/sparqlee/package.json | 1 + .../operators/DateTimeOperands.test.ts | 3 +- packages/sparqlee/src/evaluator/EvalSync.ts | 26 ++- .../expressions/BinOpImplementation.ts | 196 ++++++++++++++++++ .../src/evaluator/expressions/Operators.ts | 153 ++++++++++---- .../src/evaluator/expressions/Terms.ts | 151 +------------- packages/sparqlee/src/util/Consts.ts | 2 +- 9 files changed, 365 insertions(+), 189 deletions(-) create mode 100644 packages/sparqlee/benchmarks/Testing.ts create mode 100644 packages/sparqlee/src/evaluator/expressions/BinOpImplementation.ts diff --git a/packages/sparqlee/benchmarks/Examples.ts b/packages/sparqlee/benchmarks/Examples.ts index cc4341d195..426c06dc67 100644 --- a/packages/sparqlee/benchmarks/Examples.ts +++ b/packages/sparqlee/benchmarks/Examples.ts @@ -5,7 +5,6 @@ import { Mapping } from '../src/core/Mapping'; import { DataType as DT } from '../src/util/Consts'; - const parser = new Parser({'xsd': 'http://www.w3.org/2001/XMLSchema#'}) export class Example { diff --git a/packages/sparqlee/benchmarks/Testing.ts b/packages/sparqlee/benchmarks/Testing.ts new file mode 100644 index 0000000000..dd2a556276 --- /dev/null +++ b/packages/sparqlee/benchmarks/Testing.ts @@ -0,0 +1,21 @@ +import * as RDF from 'rdf-data-model'; + +import { Example } from './Examples'; +import { DataType as DT } from '../src/util/Consts'; +import { SyncEvaluator } from '../src/evaluator/EvalSync'; + +const example1 = (() => { + const str = '?a = ?b'; + // const str = '10000 > ?age'; + const mapping = new Map([ + ['a', RDF.literal('20', RDF.namedNode(DT.XSD_INTEGER))], + ['b', RDF.literal('30', RDF.namedNode(DT.XSD_INTEGER))], + ['c', RDF.literal('50', RDF.namedNode(DT.XSD_INTEGER))] + ]); + return new Example(str, mapping); +})(); + +console.log(JSON.stringify(example1.expression, null, 4)); + +const evaluator = new SyncEvaluator(example1.expression); +console.log(evaluator.evaluate(example1.mapping)); \ No newline at end of file diff --git a/packages/sparqlee/package.json b/packages/sparqlee/package.json index 1441789372..ee6281923e 100644 --- a/packages/sparqlee/package.json +++ b/packages/sparqlee/package.json @@ -9,6 +9,7 @@ "test-debug-win": "node --debug-brk=5858 ./node_modules/jest/bin/jest.js", "prepare": "npm run build", "bench": "node dist/benchmarks/Compare.js", + "testm": "node dist/benchmarks/Testing.js", "build": "tsc" }, "repository": { diff --git a/packages/sparqlee/src/__tests__/operators/DateTimeOperands.test.ts b/packages/sparqlee/src/__tests__/operators/DateTimeOperands.test.ts index 42239e1255..fc40f7f5c9 100644 --- a/packages/sparqlee/src/__tests__/operators/DateTimeOperands.test.ts +++ b/packages/sparqlee/src/__tests__/operators/DateTimeOperands.test.ts @@ -152,7 +152,7 @@ describe('the evaluation of simple datetime expressions', () => { edge1 edge2 = true ` - test('<=', table) + test('<=', table); }); describe('like >= receiving', () => { @@ -173,6 +173,7 @@ describe('the evaluation of simple datetime expressions', () => { edge1 edge2 = true ` + test('>=', table); }); }) }); \ No newline at end of file diff --git a/packages/sparqlee/src/evaluator/EvalSync.ts b/packages/sparqlee/src/evaluator/EvalSync.ts index 4e85fad1d8..c9053c210d 100644 --- a/packages/sparqlee/src/evaluator/EvalSync.ts +++ b/packages/sparqlee/src/evaluator/EvalSync.ts @@ -80,15 +80,15 @@ export class SyncEvaluator implements ExpressionEvaluator { case '||': return new Ops.Or(args); case '!': return new Ops.Not(args); case '=': return new Ops.Equal(args); - case '!=': throw new UnimplementedError(); - case '<': throw new UnimplementedError(); + case '!=': return new Ops.NotEqual(args); + case '<': return new Ops.LesserThan(args); case '>': return new Ops.GreaterThan(args); - case '<=': throw new UnimplementedError(); - case '>=': throw new UnimplementedError(); - case '*': throw new UnimplementedError(); - case '/': throw new UnimplementedError(); + case '<=': return new Ops.LesserThan(args); + case '>=': throw new Ops.GreaterThenEqual(args); + case '*': throw new Ops.Multiplication(args); + case '/': throw new Ops.Division(args); case '+': return new Ops.Addition(args); - case '-': throw new UnimplementedError(); + case '-': throw new Ops.Subtraction(args); } }; case ET.FunctionCall: throw new UnimplementedError(); @@ -148,7 +148,19 @@ export class SyncEvaluator implements ExpressionEvaluator { case DT.XSD_DECIMAL: case DT.XSD_FLOAT: case DT.XSD_DOUBLE: + + case DT.XSD_NEGATIVE_INTEGER: + case DT.XSD_NON_NEGATIVE_INTEGER: + case DT.XSD_NON_POSITIVE_INTEGER: + case DT.XSD_POSITIVE_INTEGER: case DT.XSD_LONG: + case DT.XSD_INT: + case DT.XSD_SHORT: + case DT.XSD_BYTE: + case DT.XSD_UNSIGNED_LONG: + case DT.XSD_UNSIGNED_INT: + case DT.XSD_UNSIGNED_SHORT: + case DT.XSD_UNSIGNED_BYTE: case DT.XSD_INT: { let val: number = JSON.parse(lit.value); if (typeof val != 'number') { diff --git a/packages/sparqlee/src/evaluator/expressions/BinOpImplementation.ts b/packages/sparqlee/src/evaluator/expressions/BinOpImplementation.ts new file mode 100644 index 0000000000..72aa9915ef --- /dev/null +++ b/packages/sparqlee/src/evaluator/expressions/BinOpImplementation.ts @@ -0,0 +1,196 @@ +import { InvalidOperationError, UnimplementedError } from '../../util/Errors'; +import { BooleanLiteral, DateTimeLiteral, NumericLiteral, SimpleLiteral, + StringLiteral, Term } from './Terms'; + +export enum ImplType { + Term ='Term', + String = 'String', + Numeric = 'Numeric', + Boolean = 'Boolean', + DateTime = 'DateTime', + Simple = 'Simple', +} + +export interface Impl { + rdfEqual(left: Term, right: Term): boolean, + + rdfNotEqual(left: Term, right: Term): boolean, + + lt(left: Term, right: Term): boolean, + gt(left: Term, right: Term): boolean, + lte(left: Term, right: Term): boolean, + gte(left: Term, right: Term): boolean, + + multiply(left: Term, right: Term): number, + divide(left: Term, right: Term): number, + add(left: Term, right: Term): number, + subtract(left: Term, right: Term): number, +} + +export class TermImpl implements Impl { + + rdfEqual(left: Term, right: Term): boolean { + throw new UnimplementedError(); + } + + rdfNotEqual(left: Term, right: Term): boolean { + return !this.rdfEqual(left, right); + } + + lt(left: Term, right: Term): boolean { throw new InvalidOperationError(); } + gt(left: Term, right: Term): boolean { throw new InvalidOperationError(); } + lte(left: Term, right: Term): boolean { throw new InvalidOperationError(); } + gte(left: Term, right: Term): boolean { throw new InvalidOperationError(); } + multiply(left: Term, right: Term): number { throw new InvalidOperationError(); } + divide(left: Term, right: Term): number { throw new InvalidOperationError(); } + add(left: Term, right: Term): number { throw new InvalidOperationError(); } + subtract(left: Term, right: Term): number { throw new InvalidOperationError(); } +} + +export class NumericImpl extends TermImpl { + + rdfEqual(left: NumericLiteral, right: NumericLiteral): boolean { + return left.value === right.value; + } + + rdfNotEqual(left: NumericLiteral, right: NumericLiteral): boolean { + return left.value !== right.value; + } + + lt(left: NumericLiteral, right: NumericLiteral): boolean { + return left.value < right.value; + } + + gt(left: NumericLiteral, right: NumericLiteral): boolean { + return left.value > right.value; + } + + lte(left: NumericLiteral, right: NumericLiteral): boolean { + return left.value <= right.value; + } + + gte(left: NumericLiteral, right: NumericLiteral): boolean { + return left.value >= right.value; + } + + multiply(left: NumericLiteral, right: NumericLiteral): number { + return left.value * right.value; + } + + divide(left: NumericLiteral, right: NumericLiteral): number { + return left.value / right.value; + } + + add(left: NumericLiteral, right: NumericLiteral): number { + return left.value + right.value; + } + + subtract(left: NumericLiteral, right: NumericLiteral): number { + return left.value - right.value; + } +} + +export class StringImpl extends TermImpl { + rdfEqual(left: StringLiteral, right: StringLiteral): boolean { + return left.value === right.value; + } + + rdfNotEqual(left: StringLiteral, right: StringLiteral): boolean { + return left.value !== right.value; + } + + lt(left: StringLiteral, right: StringLiteral): boolean { + return left.value < right.value; + } + + gt(left: StringLiteral, right: StringLiteral): boolean { + return left.value > right.value; + } + + lte(left: StringLiteral, right: StringLiteral): boolean { + return left.value <= right.value; + } + + gte(left: StringLiteral, right: StringLiteral): boolean { + return left.value >= right.value; + } +} + +export class DateTimeImpl extends TermImpl { + + rdfEqual(left: DateTimeLiteral, right: DateTimeLiteral): boolean { + return left.value.getTime() === right.value.getTime(); + } + + rdfNotEqual(left: DateTimeLiteral, right: DateTimeLiteral): boolean { + return left.value.getTime() !== right.value.getTime(); + } + + lt(left: DateTimeLiteral, right: DateTimeLiteral): boolean { + return left.value < right.value; + } + + gt(left: DateTimeLiteral, right: DateTimeLiteral): boolean { + return left.value > right.value; + } + + lte(left: DateTimeLiteral, right: DateTimeLiteral): boolean { + return left.value.getTime() <= right.value.getTime(); + } + + gte(left: DateTimeLiteral, right: DateTimeLiteral): boolean { + return left.value.getTime() >= right.value.getTime(); + } +} + +export class BooleanImpl extends TermImpl { + rdfEqual(left: BooleanLiteral, right: BooleanLiteral): boolean { + return left.value === right.value; + } + + rdfNotEqual(left: BooleanLiteral, right: BooleanLiteral): boolean { + return left.value !== right.value; + } + + lt(left: BooleanLiteral, right: BooleanLiteral): boolean { + return left.value < right.value; + } + + gt(left: BooleanLiteral, right: BooleanLiteral): boolean { + return left.value > right.value; + } + + lte(left: BooleanLiteral, right: BooleanLiteral): boolean { + return left.value <= right.value; + } + + gte(left: BooleanLiteral, right: BooleanLiteral): boolean { + return left.value >= right.value; + } +} + +export class SimpleImpl extends TermImpl { + rdfEqual(left: SimpleLiteral, right: SimpleLiteral): boolean { + return left.value === right.value; + } + + rdfNotEqual(left: SimpleLiteral, right: SimpleLiteral): boolean { + return left.value !== right.value; + } + + lt(left: SimpleLiteral, right: SimpleLiteral): boolean { + return left.value < right.value; + } + + gt(left: SimpleLiteral, right: SimpleLiteral): boolean { + return left.value > right.value; + } + + lte(left: SimpleLiteral, right: SimpleLiteral): boolean { + return left.value <= right.value; + } + + gte(left: SimpleLiteral, right: SimpleLiteral): boolean { + return left.value >= right.value; + } +} \ No newline at end of file diff --git a/packages/sparqlee/src/evaluator/expressions/Operators.ts b/packages/sparqlee/src/evaluator/expressions/Operators.ts index ddc69ef509..b52d43dbcb 100644 --- a/packages/sparqlee/src/evaluator/expressions/Operators.ts +++ b/packages/sparqlee/src/evaluator/expressions/Operators.ts @@ -1,5 +1,8 @@ import { Expression, ExpressionType } from './Types'; -import { Term, Literal, BooleanLiteral, NumericLiteral } from './Terms'; +import { BooleanLiteral, Literal, NumericLiteral, Term } from './Terms'; +import { InvalidOperationError, UnimplementedError } from '../../util/Errors'; +import { BooleanImpl, DateTimeImpl, Impl, NumericImpl, SimpleImpl, StringImpl, + TermImpl, ImplType } from './BinOpImplementation'; export interface Operation extends Expression { operator: Operator, @@ -19,16 +22,16 @@ export enum Operator { GT, LTE, GTE, - PRODUCT, + MULTIPLICATION, DIVISION, ADDITION, - SUBTACTION + SUBTRACTION } export abstract class BaseOperation implements Operation { abstract operator: Operator; - exprType:ExpressionType.Operation = ExpressionType.Operation; + exprType: ExpressionType.Operation = ExpressionType.Operation; args: Expression[]; constructor(args: Expression[]) { @@ -52,10 +55,26 @@ export abstract class BinaryOperation extends BaseOperation { } apply(args: Term[]): Term { - return this.applyBin(args[0], args[1]); + let type = `${args[0].implType} ${args[1].implType}`; + let impl = typeMap.get(type); + return this.applyBin(impl, args[0], args[1]); } - abstract applyBin(left: Term, right: Term): Term; + abstract applyBin(impl: Impl, left: Term, right: Term): Term; +} + +export abstract class BinaryBoolOperation extends BinaryOperation { + abstract func(impl: Impl): ((left: Term, right: Term) => boolean); + applyBin(impl: Impl, left: Term, right: Term): Term { + return new BooleanLiteral(this.func(impl)(left, right)) + } +} + +export abstract class BinaryArithmeticOperation extends BinaryOperation { + abstract func(impl: Impl): ((left: Term, right: Term) => number); + applyBin(impl: Impl, left: Term, right: Term): Term { + return new NumericLiteral(this.func(impl)(left, right)) + } } export abstract class UnaryOperation extends BaseOperation { @@ -76,54 +95,114 @@ export abstract class UnaryOperation extends BaseOperation { abstract applyUn(arg: Term): Term; } +export class Not extends UnaryOperation { + operator = Operator.NOT; + applyUn(arg: Term): BooleanLiteral { + return new BooleanLiteral(arg.not()); + } +} + +// TODO: Maybe just extend BinaryOperation for performance // TODO: Correctly handle error + false -export class And extends BinaryOperation { +export class And extends BinaryBoolOperation { operator = Operator.AND; - - applyBin(left: Term, right: Term): BooleanLiteral { - let result = left.toEBV() && right.toEBV(); - return new BooleanLiteral(result); - } + func(impl: Impl) { + return (left: Term, right: Term) => { + return left.toEBV() && right.toEBV(); + } + }; } // TODO: Correctly handle error + true -export class Or extends BinaryOperation { +export class Or extends BinaryBoolOperation { operator = Operator.OR; + func(impl: Impl) { + return (left: Term, right: Term) => { + return left.toEBV() || right.toEBV(); + } + }; +} - applyBin(left: Term, right: Term): BooleanLiteral { - let result = left.toEBV() || right.toEBV(); - return new BooleanLiteral(result); - } +export class Equal extends BinaryBoolOperation { + operator = Operator.EQUAL; + func(impl: Impl) { return impl.rdfEqual; } } -export class Not extends UnaryOperation { - operator = Operator.NOT; +export class NotEqual extends BinaryBoolOperation { + operator = Operator.NOTEQUAL; + func(impl: Impl) { return impl.rdfNotEqual; } +} - applyUn(arg: Term): BooleanLiteral { - return new BooleanLiteral(arg.not()); - } +export class LesserThan extends BinaryBoolOperation { + operator = Operator.LT; + func(impl: Impl) { return impl.lt; } } -export class Addition extends BinaryOperation { - operator = Operator.ADDITION +export class GreaterThan extends BinaryBoolOperation { + operator = Operator.GT; + func(impl: Impl) { return impl.gt; } +} - public applyBin(left: Term, right: Term): Term { - return new NumericLiteral(left.add(right)); - } +export class LesserThenEqual extends BinaryBoolOperation { + operator = Operator.LTE; + func(impl: Impl) { return impl.lte; } } -export class GreaterThan extends BinaryOperation { - operator = Operator.LT; +export class GreaterThenEqual extends BinaryBoolOperation { + operator = Operator.GTE; + func(impl: Impl) { return impl.gte; } +} - applyBin(left: Term, right: Term): Term { - return new BooleanLiteral(left.gt(right)); - } +export class Multiplication extends BinaryArithmeticOperation { + operator = Operator.MULTIPLICATION; + func(impl: Impl) { return impl.multiply; } } -export class Equal extends BinaryOperation { - operator = Operator.EQUAL; +export class Division extends BinaryArithmeticOperation { + operator = Operator.DIVISION; + func(impl: Impl) { return impl.divide; } +} - applyBin(left: Term, right: Term): Term { - return new BooleanLiteral(left.rdfEqual(right)); +export class Addition extends BinaryArithmeticOperation { + operator = Operator.ADDITION; + func(impl: Impl) { return impl.add; } +} + +export class Subtraction extends BinaryArithmeticOperation { + operator = Operator.SUBTRACTION; + func(impl: Impl) { return impl.subtract; } +} + +// Generate typeMap so no branching is needed; +// interface TypeKey { left: ImplType, right: ImplType } +type TypeKey = string; +const typeMap: Map = (() => { + let keyValues: [TypeKey, Impl][] = []; + let term = new TermImpl(); + let num = new NumericImpl(); + let sim = new SimpleImpl(); + let str = new StringImpl(); + let bool = new BooleanImpl(); + let date = new DateTimeImpl(); + for (let t in ImplType) { + for (let tt in ImplType) { + let left: ImplType = (ImplType)[t]; + let right: ImplType = (ImplType)[tt]; + let impl: Impl = term; + if (left === right) { + switch (left) { + case ImplType.Term: impl = term; break; + case ImplType.Numeric: impl = num; break; + case ImplType.Simple: impl = sim; break; + case ImplType.String: impl = str; break; + case ImplType.Boolean: impl = bool; break; + case ImplType.DateTime: impl = date; break; + default: throw Error("ImplType was somehow not defined"); + } + } + console.log(left, right); + keyValues.push([`${left} ${right}`, impl]) + } } -} \ No newline at end of file + return new Map(keyValues); +})(); \ No newline at end of file diff --git a/packages/sparqlee/src/evaluator/expressions/Terms.ts b/packages/sparqlee/src/evaluator/expressions/Terms.ts index aaf99fc5a7..07304775c2 100644 --- a/packages/sparqlee/src/evaluator/expressions/Terms.ts +++ b/packages/sparqlee/src/evaluator/expressions/Terms.ts @@ -2,32 +2,21 @@ import * as console from 'console'; import * as RDFJS from 'rdf-js'; import * as RDFDM from 'rdf-data-model'; +import { Impl, ImplType } from './BinOpImplementation'; import { Expression, ExpressionType } from './Types'; import { DataType as DT, NumericType } from '../../util/Consts'; import { UnimplementedError, InvalidOperationError } from '../../util/Errors'; export interface Term extends Expression { termType: TermType + implType: ImplType toEBV(): boolean - rdfEqual(other: Term): boolean - rdfNotEqual(other: Term): boolean - // TODO: Maybe just return the native types (eg: boolean, number) not(): boolean unPlus(): number unMin(): number - lt(other: Term): boolean - gt(other: Term): boolean - lte(other: Term): boolean - gte(other: Term): boolean - - multiply(other: Term): number - divide(other: Term): number - add(other: Term): number - subtract(other: Term): number - toRDFJS(): RDFJS.Term } @@ -44,35 +33,19 @@ export enum TermType { export abstract class BaseTerm implements Term { abstract termType: TermType; exprType = ExpressionType.Term; + implType = ImplType.Term; // https://www.w3.org/TR/sparql11-query/#ebv toEBV(): boolean { throw new InvalidOperationError(); } - rdfEqual(other: Term): boolean { - throw new UnimplementedError(); - } - - rdfNotEqual(other: Term): boolean { - return !this.rdfEqual(other); - } - not(): boolean { throw new InvalidOperationError(); } unPlus(): number { throw new InvalidOperationError(); } unMin(): number { throw new InvalidOperationError(); } - lt(other: Term): boolean { throw new InvalidOperationError(); } - gt(other: Term): boolean { throw new InvalidOperationError(); } - lte(other: Term): boolean { throw new InvalidOperationError(); } - gte(other: Term): boolean { throw new InvalidOperationError(); } - - multiply(other: Term): number { throw new InvalidOperationError(); } - divide(other: Term): number { throw new InvalidOperationError(); } - add(other: Term): number { throw new InvalidOperationError(); } - subtract(other: Term): number { throw new InvalidOperationError(); } - abstract toRDFJS(): RDFJS.Term; + } // ============================================================================ @@ -157,29 +130,7 @@ export abstract class PlainLiteral extends BaseLiteral { } export class SimpleLiteral extends PlainLiteral { - rdfEqual(other: SimpleLiteral): boolean { - return this.value === other.value; - } - - rdfNotEqual(other: SimpleLiteral): boolean { - return this.value !== other.value; - } - - lt(other: SimpleLiteral): boolean { - return this.value < other.value; - } - - gt(other: SimpleLiteral): boolean { - return this.value > other.value; - } - - lte(other: SimpleLiteral): boolean { - return this.value <= other.value; - } - - gte(other: SimpleLiteral): boolean { - return this.value >= other.value; - } + implType = ImplType.Simple; } export class LangLiteral extends PlainLiteral implements Literal { @@ -206,6 +157,7 @@ export class TypedLiteral extends BaseLiteral { export class BooleanLiteral extends TypedLiteral { dataType: DT.XSD_BOOLEAN = DT.XSD_BOOLEAN; + implType = ImplType.Boolean; constructor(value: boolean) { super(value); @@ -222,6 +174,7 @@ export class BooleanLiteral extends TypedLiteral { export class StringLiteral extends TypedLiteral { dataType: DT.XSD_STRING = DT.XSD_STRING; + implType = ImplType.String; constructor(value: string) { super(value); @@ -230,34 +183,11 @@ export class StringLiteral extends TypedLiteral { toEBV(): boolean { return this.value.length != 0; } - - rdfEqual(other: StringLiteral): boolean { - return this.value === other.value; - } - - rdfNotEqual(other: StringLiteral): boolean { - return this.value !== other.value; - } - - lt(other: StringLiteral): boolean { - return this.value < other.value; - } - - gt(other: StringLiteral): boolean { - return this.value > other.value; - } - - lte(other: StringLiteral): boolean { - return this.value <= other.value; - } - - gte(other: StringLiteral): boolean { - return this.value >= other.value; - } } export class NumericLiteral extends TypedLiteral { dataType: NumericType; + implType = ImplType.Numeric; // TODO: Check need for keeping datatype in literal // Possibly not needed at all @@ -279,76 +209,13 @@ export class NumericLiteral extends TypedLiteral { unMin(): number { return -this.value; } - - rdfEqual(other: NumericLiteral): boolean { - return this.value === other.value; - } - - rdfNotEqual(other: NumericLiteral): boolean { - return this.value !== other.value; - } - - lt(other: NumericLiteral): boolean { - return this.value < other.value; - } - - gt(other: NumericLiteral): boolean { - return this.value > other.value; - } - - lte(other: NumericLiteral): boolean { - return this.value <= other.value; - } - - gte(other: NumericLiteral): boolean { - return this.value >= other.value; - } - - multiply(other: NumericLiteral): number { - return this.value * other.value; - } - - divide(other: NumericLiteral): number { - return this.value / other.value; - } - - add(other: NumericLiteral): number { - return this.value + other.value; - } - - subtract(other: NumericLiteral): number { - return this.value - other.value; - } } export class DateTimeLiteral extends TypedLiteral { dataType: DT.XSD_DATE_TIME = DT.XSD_DATE_TIME; + implType = ImplType.DateTime; constructor(value: Date) { super(value); } - - rdfEqual(other: DateTimeLiteral): boolean { - return this.value.getTime() === other.value.getTime(); - } - - rdfNotEqual(other: DateTimeLiteral): boolean { - return this.value.getTime() !== other.value.getTime(); - } - - lt(other: DateTimeLiteral): boolean { - return this.value < other.value; - } - - gt(other: DateTimeLiteral): boolean { - return this.value > other.value; - } - - lte(other: DateTimeLiteral): boolean { - return this.value <= other.value; - } - - gte(other: DateTimeLiteral): boolean { - return this.value >= other.value; - } } \ No newline at end of file diff --git a/packages/sparqlee/src/util/Consts.ts b/packages/sparqlee/src/util/Consts.ts index 5b1aa59a0f..d8ce2339ec 100644 --- a/packages/sparqlee/src/util/Consts.ts +++ b/packages/sparqlee/src/util/Consts.ts @@ -70,7 +70,7 @@ export type NumericType = | DataType.XSD_UNSIGNED_INT | DataType.XSD_UNSIGNED_SHORT | DataType.XSD_UNSIGNED_BYTE - | DataType.XSD_NON_POSITIVE_INTEGER + | DataType.XSD_POSITIVE_INTEGER // TODO: Operator enum // TODO: Function enum \ No newline at end of file