From 65f7cb4595930f6b30d52008e6ad68bc3d2043a8 Mon Sep 17 00:00:00 2001 From: Petr Pchelko Date: Tue, 18 Jul 2017 10:33:50 -0700 Subject: [PATCH 1/2] TEMP --- lib/db.js | 14 ++------------ lib/dbutils.js | 16 ---------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/lib/db.js b/lib/db.js index e1fe7ca..80b89e3 100644 --- a/lib/db.js +++ b/lib/db.js @@ -68,11 +68,9 @@ class DB { attributes: { key: 'string', value: 'json', - tid: 'timeuuid' }, index: [ - { attribute: 'key', type: 'hash' }, - { attribute: 'tid', type: 'range', order: 'desc' } + { attribute: 'key', type: 'hash' } ] }); this.infoSchemaInfo = dbu.makeSchemaInfo(this.infoSchema, true); @@ -306,14 +304,6 @@ class DB { } const schema = req.schema; const query = req.query; - - const tid = query.attributes[schema.tid]; - if (!tid) { - query.attributes[schema.tid] = TimeUuid.now(); - } else if (tid.constructor === String) { - query.attributes[schema.tid] = TimeUuid.fromString(query.attributes[schema.tid]); - } - const queryOptions = { consistency: req.consistency, prepare: true }; const queryInfo = dbu.buildPutQuery(req); @@ -645,7 +635,7 @@ class DB { }); } const item = response.items[0]; - return { tid: item.tid, schema: JSON.parse(item.value) }; + return { schema: JSON.parse(item.value) }; }); } diff --git a/lib/dbutils.js b/lib/dbutils.js index 35aefec..d88413f 100644 --- a/lib/dbutils.js +++ b/lib/dbutils.js @@ -56,11 +56,6 @@ dbu.cassTTL = function cassTTL(name) { return `_ttl_${name}`; }; -dbu.tidNanoTime = (tid) => { - const datePrecision = tid.getDatePrecision(); - return datePrecision.date.getTime() + datePrecision.ticks / 1000; -}; - // Hash a key into a valid Cassandra key name dbu.hashKey = function hashKey(key) { return new crypto.Hash('sha1') @@ -364,17 +359,6 @@ dbu.makeSchemaInfo = function makeSchemaInfo(schema, isMetaCF) { psi.index.unshift({ attribute: '_domain', type: 'hash' }); } - if (lastKey && lastElem.type === 'range' - && lastElem.order === 'desc' - && schema.attributes[lastKey] === 'timeuuid') { - psi.tid = lastKey; - } else { - // Add a hidden _tid timeuuid attribute - psi.attributes._tid = 'timeuuid'; - psi.index.push({ attribute: '_tid', type: 'range', order: 'desc' }); - psi.tid = '_tid'; - } - // Create summary data on the primary data index psi.iKeys = dbu.indexKeys(psi.index); psi.iKeyMap = {}; From c65650c336304847c2a1ebc3334a25feb2e1e4a3 Mon Sep 17 00:00:00 2001 From: Petr Pchelko Date: Tue, 18 Jul 2017 10:43:48 -0700 Subject: [PATCH 2/2] Remove implicit TID handling --- index.js | 2 -- lib/db.js | 3 --- lib/dbutils.js | 5 ----- 3 files changed, 10 deletions(-) diff --git a/index.js b/index.js index e238414..f1ed024 100644 --- a/index.js +++ b/index.js @@ -181,12 +181,10 @@ class RBCassandra { return this.store.getTableSchema(domain, req.params.table) .then((res) => ({ status: 200, - headers: { etag: res.tid.toString() }, body: res.schema })) .catch((e) => ({ status: 500, - body: { type: 'schema_query_error', title: 'Internal error querying table schema in Cassandra storage backend', diff --git a/lib/db.js b/lib/db.js index 80b89e3..dcb62ae 100644 --- a/lib/db.js +++ b/lib/db.js @@ -2,7 +2,6 @@ const P = require('bluebird'); const cass = require('cassandra-driver'); -const TimeUuid = cass.types.TimeUuid; const extend = require('extend'); const dbu = require('./dbutils'); const cassID = dbu.cassID; @@ -302,8 +301,6 @@ class DB { if (!req.schema) { throw new Error('Table not found!'); } - const schema = req.schema; - const query = req.query; const queryOptions = { consistency: req.consistency, prepare: true }; const queryInfo = dbu.buildPutQuery(req); diff --git a/lib/dbutils.js b/lib/dbutils.js index d88413f..6bf97c0 100644 --- a/lib/dbutils.js +++ b/lib/dbutils.js @@ -331,11 +331,6 @@ dbu.makeSchemaInfo = function makeSchemaInfo(schema, isMetaCF) { // Then add some private properties psi.versioned = false; - // Check if the last index entry is a timeuuid, which we take to mean that - // this table is versioned - const lastElem = schema.index[schema.index.length - 1]; - const lastKey = lastElem.attribute; - // Extract attributes that need conversion in the read or write path psi.conversions = {}; Object.keys(psi.attributes).forEach((att) => {