protected boolean isIndexedBin(Statement stmt, Qualifier qualifier) { if(null == qualifier.getField()) return false; Index index = this.indexCache.get(String.join(":", Arrays.asList(stmt.getNamespace(), stmt.getSetName(), qualifier.getField()))); if (index == null) return false; switch (qualifier.getOperation()){ case EQ: case BETWEEN: case GT: case GTEQ: case LT: case LTEQ: return true; default: return false; } }
/** * inserts a record, with a time to live, using a Statement and KeyQualifier. If the record exists, and exception will be thrown. * * @param stmt A Statement object containing Namespace and Set * @param keyQualifier KeyQualifier containin the primary key * @param bins A list of Bins to insert * @param ttl The record time to live in seconds */ public void insert(Statement stmt, KeyQualifier keyQualifier, List<Bin> bins, int ttl) { Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName()); // Key key = new Key(stmt.getNamespace(), stmt.getSetName(), keyQualifier.getValue1()); this.client.put(this.insertPolicy, key, bins.toArray(new Bin[0])); }
/** * The list of Bins will update each record that match the Qualifiers supplied. * * @param stmt A Statement object containing Namespace and Set * @param bins A list of Bin objects with the values to updated * @param qualifiers Zero or more Qualifiers for the update query * @return returns a Map containing a number of successful updates. The Map will contain 2 keys "read" and "write", the values will be the count of successful operations */ public Map<String, Long> update(Statement stmt, List<Bin> bins, Qualifier... qualifiers) { if (qualifiers != null && qualifiers.length == 1 && qualifiers[0] instanceof KeyQualifier) { KeyQualifier keyQualifier = (KeyQualifier) qualifiers[0]; Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName()); this.client.put(this.updatePolicy, key, bins.toArray(new Bin[0])); Map<String, Long> result = new HashMap<String, Long>(); result.put("read", 1L); result.put("write", 1L); return result; } else { KeyRecordIterator results = select(stmt, true, null, qualifiers); return update(results, bins); } }
/** * Deletes the records specified by the Statement and Qualifiers * * @param stmt A Statement object containing Namespace and Set * @param qualifiers Zero or more Qualifiers for the update query * @return returns a Map containing a number of successful updates. The Map will contain 2 keys "read" and "write", the values will be the count of successful operations */ public Map<String, Long> delete(Statement stmt, Qualifier... qualifiers) { if (qualifiers == null || qualifiers.length == 0) { /* * There are no qualifiers, so delete every record in the set * using Scan UDF delete */ ExecuteTask task = client.execute(null, stmt, QUERY_MODULE, "delete_record"); task.waitTillComplete(); return null; } if (qualifiers.length == 1 && qualifiers[0] instanceof KeyQualifier) { KeyQualifier keyQualifier = (KeyQualifier) qualifiers[0]; Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName()); this.client.delete(null, key); Map<String, Long> map = new HashMap<String, Long>(); map.put("read", 1L); map.put("write", 1L); return map; } KeyRecordIterator results = select(stmt, true, null, qualifiers); return delete(results); }
if (statement.getSetName() != null) { dataOffset += Buffer.estimateSizeUtf8(statement.getSetName()) + FIELD_HEADER_SIZE; fieldCount++; if (statement.getSetName() != null) { writeField(statement.getSetName(), FieldType.TABLE);
if (statement.getSetName() != null) { dataOffset += Buffer.estimateSizeUtf8(statement.getSetName()) + FIELD_HEADER_SIZE; fieldCount++; if (statement.getSetName() != null) { writeField(statement.getSetName(), FieldType.TABLE);
Key key = kq.makeKey(stmt.getNamespace(), stmt.getSetName()); Record record = null; if (metaOnly)