@Override public String toString() { return "delete_timestamp_ranges_batch_mutate(" + host + ", " + tableRef.getQualifiedName() + ", " + maxTimestampExclusiveByCell.size() + " column timestamp ranges)"; } });
private boolean matchingIgnoreCase(TableReference t1, TableReference t2) { if (t1 != null) { return t1.getQualifiedName().toLowerCase().equals(t2.getQualifiedName().toLowerCase()); } else { if (t2 == null) { return true; } return false; } }
@SuppressWarnings("ValidateConstantMessage") // https://github.com/palantir/gradle-baseline/pull/175 static void sanityCheckTableName(TableReference tableRef) { String tableName = tableRef.getQualifiedName(); Validate.isTrue(!(tableName.startsWith("_") && tableName.contains(".")) || AtlasDbConstants.HIDDEN_TABLES.contains(tableRef) || tableName.startsWith(AtlasDbConstants.NAMESPACE_PREFIX), "invalid tableName: %s", tableName); }
private boolean shouldTraceQuery(Set<TableReference> tableRefs) { for (TableReference tableRef : tableRefs) { if (tracingPrefs.shouldTraceQuery(tableRef.getQualifiedName())) { return true; } } return false; }
private Table getTableMap(TableReference tableRef) { if (createTablesAutomatically && !tables.containsKey(tableRef)) { createTable(tableRef, AtlasDbConstants.EMPTY_TABLE_METADATA); } Table table = tables.get(tableRef); if (table == null) { throw new IllegalArgumentException("table " + tableRef.getQualifiedName() + " does not exist"); } return table; }
@SuppressWarnings("checkstyle:RegexpSinglelineJava") static Cell getOldMetadataCell(TableReference tableRef) { return Cell.create( tableRef.getQualifiedName().getBytes(Charset.defaultCharset()), METADATA_COL); }
public static TransactionSerializableConflictException create( TableReference tableRef, long timestamp, long elapsedMillis) { String msg = String.format("There was a read-write conflict on table %s. This means that this table was " + "marked as Serializable and another transaction wrote a different value than this transaction read. " + "startTs: %d elapsedMillis: %d", tableRef.getQualifiedName(), timestamp, elapsedMillis); return new TransactionSerializableConflictException(msg); }
public static <T> Iterable<List<T>> partitionByCountAndBytes(final Iterable<T> iterable, final int maximumCountPerPartition, final long maximumBytesPerPartition, final String tableNameForLoggingPurposesOnly, final Function<T, Long> sizingFunction) { return partitionByCountAndBytes(iterable, maximumCountPerPartition, maximumBytesPerPartition, tableNameForLoggingPurposesOnly, sizingFunction, defaultLogger); }
Optional<SweepTableIdentifier> currentMapping(TableReference table) { SweepNameToIdRow row = SweepNameToIdRow.of(table.getQualifiedName()); Cell cell = Cell.create(row.persistToBytes(), SweepNameToIdNamedColumn.ID.getShortName()); return Optional.ofNullable(kvs.get(NAME_TO_ID, Collections.singletonMap(cell, Long.MAX_VALUE)).get(cell)) .map(Value::getContents) .map(SweepTableIdentifier.BYTES_HYDRATOR::hydrateFromBytes); } }
@Override public void drop() { executeIgnoringError("DROP TABLE " + prefixedTableName(), "does not exist"); conns.get().executeUnregisteredQuery( String.format("DELETE FROM %s WHERE table_name = ?", config.metadataTable().getQualifiedName()), tableName.getQualifiedName()); }
@Override protected boolean matchesSafely(Map<TableReference, byte[]> item, Description mismatchDescription) { mismatchDescription.appendText("Map does not contain match: ").appendValue(tableRef.getQualifiedName()); return item.containsKey(tableRef) && Arrays.equals(description, item.get(tableRef)); }
public void addIndexDefinition(String idxName, IndexDefinition definition) { validateIndex(idxName, definition); String indexName = Schemas.appendIndexSuffix(idxName, definition).getQualifiedName(); validateTableNameLength(indexName); indexesByTable.put(definition.getSourceTable(), indexName); indexDefinitions.put(indexName, definition); }
private LockResponse acquireRowLock(String rowName) { LockDescriptor rowLockDescriptor = AtlasRowLockDescriptor.of( TEST_TABLE.getQualifiedName(), PtBytes.toBytes(rowName)); return lock(rowLockDescriptor); }
@Test public void sweepTableFromStartRowWithBatchConfigWithExactlyOneNonNullBatchConfigShouldBeSuccessful() { sweeperService.sweepTable(TABLE_REF.getQualifiedName(), Optional.of(encodeStartRow(new byte[] {1, 2, 3})), Optional.empty(), Optional.of(10), Optional.empty(), Optional.empty()); }
@Override public byte[] getMetadataForTable(final TableReference tableRef) { return run(ctx -> { byte[] metadata = ctx .select(METADATA) .from(METADATA_TABLE) .where(TABLE_NAME.eq(tableRef.getQualifiedName())) .fetchOne(METADATA); return MoreObjects.firstNonNull(metadata, new byte[0]); }); }
@Test public void sweepTableFromStartRowShouldAcceptMixedCaseBase16Encodings() { when(kvs.getAllTableNames()).thenReturn(ImmutableSet.of(TABLE_REF)); sweeperService.sweepTableFrom(TABLE_REF.getQualifiedName(), MIXED_CASE_START_ROW); }
boolean storeNewMapping(TableReference table, int id) { SweepIdToNameColumn column = SweepIdToNameColumn.of(id); SweepIdToNameColumnValue value = SweepIdToNameColumnValue.of(column, table.getQualifiedName()); Cell cell = Cell.create(rowAsBytes, value.persistColumnName()); CheckAndSetRequest request = CheckAndSetRequest.newCell(ID_TO_NAME, cell, value.persistValue()); try { kvs.checkAndSet(request); return true; } catch (CheckAndSetException e) { return get(id).get().equals(table); } }
@Override @Test public void smokeTest() throws Exception { createTable(TABLE_1, SweepStrategy.CONSERVATIVE); putManyCells(TABLE_1, 100, 110); putManyCells(TABLE_1, 103, 113); putManyCells(TABLE_1, 105, 115); sweeperService.sweepTableFully(TABLE_1.getQualifiedName()); verifyTableSwept(TABLE_1, 75, true); }
public static CqlQuery constructSelectFromTimestampTableQuery() { // Timestamps are safe. return ImmutableCqlQuery.builder() .safeQueryFormat("SELECT %s, %s FROM %s WHERE key=%s;") .addArgs( SafeArg.of("columnName", COLUMN_NAME_COLUMN), SafeArg.of("valueColumnName", VALUE_COLUMN), SafeArg.of("tableRef", wrapInQuotes(AtlasDbConstants.TIMESTAMP_TABLE.getQualifiedName())), SafeArg.of("rowAndColumnValue", ROW_AND_COLUMN_NAME_HEX_STRING)) .build(); }
@Test public void testCanUnpersistBinary_tableNameAsString() { byte[] data = EncodingUtils.add( new byte[1], EncodingUtils.encodeVarString(TABLE.getQualifiedName()), EncodingUtils.encodeSizedBytes(row), EncodingUtils.encodeSizedBytes(column), EncodingUtils.encodeVarLong(1)); StoredWriteReference stored = StoredWriteReference.BYTES_HYDRATOR.hydrateFromBytes(data); assertThat(persister.unpersist(stored)).isEqualTo(WRITE_REFERENCE); }