/// <summary> /// Get URL's UUID by its short form. /// </summary> /// <param name="signature">URL's short form</param> /// <param name="uuid">URL's TimeUUID to be returned</param> /// <returns>Returns true if operation was successful.</returns> public bool GetUUIDBySignature(string signature, out TimeUuid uuid) { var col = CassandraSchema.TABLE_SIGNATURES.UUID; var cql = string.Format("SELECT {0} FROM {1} WHERE {2} = ? ;", col, CassandraSchema.TABLE_SIGNATURES.TBL_SIGNATURES, CassandraSchema.TABLE_SIGNATURES.SIGNATURE); var prep = this.session.Prepare(cql); var stmt = prep.Bind(signature); var rows = this.session.Execute(stmt); var row = CassandraHelper.GetFirstRow(rows); if (row == null) { return(false); } uuid = row.GetValue <TimeUuid>(col); return(true); }
/// <summary> /// Get URL popularity. /// </summary> /// <param name="uuid">URL's TimeUUID</param> /// <param name="hits">URL popularity to be returned</param> /// <returns>Returns true if operation was successful.</returns> public bool GetURLHitCount(TimeUuid uuid, out long hits) { var col = CassandraSchema.TABLE_HITS.HIT; var cql = string.Format("SELECT {0} FROM {1} WHERE {2} = ? ;", col, CassandraSchema.TABLE_HITS.TBL_HITS, CassandraSchema.TABLE_HITS.UUID); var prep = this.session.Prepare(cql); var stmt = prep.Bind(uuid); var rows = this.session.Execute(stmt); var row = CassandraHelper.GetFirstRow(rows); if (row == null) { hits = NOT_FOUND; return(false); } hits = row.GetValue <long>(col); return(true); }
/// <summary> /// Get URL's UUID by its short form. /// </summary> /// <param name="uuid">URL's TimeUUID</param> /// <param name="signature">URL's short form to be returned</param> /// <returns>Returns true if operation was successful.</returns> public bool GetSignatureByUUID(TimeUuid uuid, out string signature) { var col = CassandraSchema.TABLE_URLS.SIGNATURE; var cql = string.Format("SELECT {0} FROM {1} WHERE {2} = ? ;", col, CassandraSchema.TABLE_URLS.TBL_URLS, CassandraSchema.TABLE_URLS.UUID); var prep = this.session.Prepare(cql); var stmt = prep.Bind(uuid); var rows = this.session.Execute(stmt); var row = CassandraHelper.GetFirstRow(rows); if (row == null) { signature = string.Empty; return(false); } signature = row.GetValue <string>(col); return(true); }
/// <summary> /// Get URL's UUID by its SHA hash. /// </summary> /// <param name="sha512">URL's SHA512</param> /// <param name="sha256">URL's SHA256</param> /// <param name="uuid">URL's UUID to be returned</param> /// <returns>Returns true if operation was successful.</returns> public bool GetUUIDBySHA(string sha512, string sha256, out TimeUuid uuid) { var col = CassandraSchema.TABLE_HASHES.UUID; var cql = string.Format("SELECT {0} FROM {1} WHERE {2} = ? AND {3} = ? ;", col, CassandraSchema.TABLE_HASHES.TBL_HASHES, CassandraSchema.TABLE_HASHES.SHA512, CassandraSchema.TABLE_HASHES.SHA256); var prep = this.session.Prepare(cql); var stmt = prep.Bind(sha512, sha256); var rows = this.session.Execute(stmt); var row = CassandraHelper.GetFirstRow(rows); if (row == null) { return(false); } uuid = row.GetValue <TimeUuid>(col); return(true); }