use of java.io.Serializable in project hibernate-orm by hibernate.
the class BaseEnversCollectionEventListener method generateFakeBidirecationalRelationWorkUnits.
private void generateFakeBidirecationalRelationWorkUnits(AuditProcess auditProcess, PersistentCollection newColl, Serializable oldColl, String collectionEntityName, String referencingPropertyName, AbstractCollectionEvent event, RelationDescription rd) {
// First computing the relation changes
final List<PersistentCollectionChangeData> collectionChanges = getEnversService().getEntitiesConfigurations().get(collectionEntityName).getPropertyMapper().mapCollectionChanges(event.getSession(), referencingPropertyName, newColl, oldColl, event.getAffectedOwnerIdOrNull());
// Getting the id mapper for the related entity, as the work units generated will correspond to the related
// entities.
final String relatedEntityName = rd.getToEntityName();
final IdMapper relatedIdMapper = getEnversService().getEntitiesConfigurations().get(relatedEntityName).getIdMapper();
// For each collection change, generating the bidirectional work unit.
for (PersistentCollectionChangeData changeData : collectionChanges) {
final Object relatedObj = changeData.getChangedElement();
final Serializable relatedId = (Serializable) relatedIdMapper.mapToIdFromEntity(relatedObj);
final RevisionType revType = (RevisionType) changeData.getData().get(getEnversService().getAuditEntitiesConfiguration().getRevisionTypePropName());
// This can be different from relatedEntityName, in case of inheritance (the real entity may be a subclass
// of relatedEntityName).
final String realRelatedEntityName = event.getSession().bestGuessEntityName(relatedObj);
// By default, the nested work unit is a collection change work unit.
final AuditWorkUnit nestedWorkUnit = new CollectionChangeWorkUnit(event.getSession(), realRelatedEntityName, rd.getMappedByPropertyName(), getEnversService(), relatedId, relatedObj);
auditProcess.addWorkUnit(new FakeBidirectionalRelationWorkUnit(event.getSession(), realRelatedEntityName, getEnversService(), relatedId, referencingPropertyName, event.getAffectedOwnerOrNull(), rd, revType, changeData.getChangedElementIndex(), nestedWorkUnit));
}
// We also have to generate a collection change work unit for the owning entity.
auditProcess.addWorkUnit(new CollectionChangeWorkUnit(event.getSession(), collectionEntityName, referencingPropertyName, getEnversService(), event.getAffectedOwnerIdOrNull(), event.getAffectedOwnerOrNull()));
}
use of java.io.Serializable in project hudson-2.x by hudson.
the class Fingerprinter method record.
private void record(AbstractBuild<?, ?> build, BuildListener listener, Map<String, String> record, final String targets) throws IOException, InterruptedException {
final class Record implements Serializable {
final boolean produced;
final String relativePath;
final String fileName;
final String md5sum;
public Record(boolean produced, String relativePath, String fileName, String md5sum) {
this.produced = produced;
this.relativePath = relativePath;
this.fileName = fileName;
this.md5sum = md5sum;
}
Fingerprint addRecord(AbstractBuild build) throws IOException {
FingerprintMap map = Hudson.getInstance().getFingerprintMap();
return map.getOrCreate(produced ? build : null, fileName, md5sum);
}
private static final long serialVersionUID = 1L;
}
final long buildTimestamp = build.getTimeInMillis();
FilePath ws = build.getWorkspace();
if (ws == null) {
listener.error(Messages.Fingerprinter_NoWorkspace());
build.setResult(Result.FAILURE);
return;
}
List<Record> records = ws.act(new FileCallable<List<Record>>() {
public List<Record> invoke(File baseDir, VirtualChannel channel) throws IOException {
List<Record> results = new ArrayList<Record>();
FileSet src = Util.createFileSet(baseDir, targets);
DirectoryScanner ds = src.getDirectoryScanner();
for (String f : ds.getIncludedFiles()) {
File file = new File(baseDir, f);
// consider the file to be produced by this build only if the timestamp
// is newer than when the build has started.
// 2000ms is an error margin since since VFAT only retains timestamp at 2sec precision
boolean produced = buildTimestamp <= file.lastModified() + 2000;
try {
results.add(new Record(produced, f, file.getName(), new FilePath(file).digest()));
} catch (IOException e) {
throw new IOException2(Messages.Fingerprinter_DigestFailed(file), e);
} catch (InterruptedException e) {
throw new IOException2(Messages.Fingerprinter_Aborted(), e);
}
}
return results;
}
});
for (Record r : records) {
Fingerprint fp = r.addRecord(build);
if (fp == null) {
listener.error(Messages.Fingerprinter_FailedFor(r.relativePath));
continue;
}
fp.add(build);
record.put(r.relativePath, fp.getHashString());
}
}
use of java.io.Serializable in project pinot by linkedin.
the class SelectionOperatorService method reduceWithOrdering.
/**
* Reduce a collection of {@link DataTable}s to selection rows for selection queries with <code>ORDER BY</code>.
* (Broker side)
*
* @param selectionResults {@link Map} from {@link ServerInstance} to {@link DataTable}.
*/
public void reduceWithOrdering(@Nonnull Map<ServerInstance, DataTable> selectionResults) {
for (DataTable dataTable : selectionResults.values()) {
int numRows = dataTable.getNumberOfRows();
for (int rowId = 0; rowId < numRows; rowId++) {
Serializable[] row = SelectionOperatorUtils.extractRowFromDataTable(dataTable, rowId);
SelectionOperatorUtils.addToPriorityQueue(row, _rows, _maxNumRows);
}
}
}
use of java.io.Serializable in project pinot by linkedin.
the class InnerSegmentSelectionMultiValueQueriesTest method testSelectStar.
@Test
public void testSelectStar() {
String query = "SELECT * FROM testTable";
// Test query without filter.
MSelectionOnlyOperator selectionOnlyOperator = getOperatorForQuery(query);
IntermediateResultsBlock resultsBlock = (IntermediateResultsBlock) selectionOnlyOperator.nextBlock();
ExecutionStatistics executionStatistics = selectionOnlyOperator.getExecutionStatistics();
Assert.assertEquals(executionStatistics.getNumDocsScanned(), 10L);
Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 0L);
Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 100L);
Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 100000L);
DataSchema selectionDataSchema = resultsBlock.getSelectionDataSchema();
Assert.assertEquals(selectionDataSchema.size(), 10);
Assert.assertEquals(selectionDataSchema.getColumnName(0), "column1");
Assert.assertEquals(selectionDataSchema.getColumnName(5), "column6");
Assert.assertEquals(selectionDataSchema.getColumnType(0), FieldSpec.DataType.INT);
Assert.assertEquals(selectionDataSchema.getColumnType(5), FieldSpec.DataType.INT_ARRAY);
List<Serializable[]> selectionResult = (List<Serializable[]>) resultsBlock.getSelectionResult();
Assert.assertEquals(selectionResult.size(), 10);
Serializable[] firstRow = selectionResult.get(0);
Assert.assertEquals(firstRow.length, 10);
Assert.assertEquals(((Integer) firstRow[0]).intValue(), 890282370);
Assert.assertEquals(firstRow[5], new int[] { 2147483647 });
// Test query with filter.
selectionOnlyOperator = getOperatorForQueryWithFilter(query);
resultsBlock = (IntermediateResultsBlock) selectionOnlyOperator.nextBlock();
executionStatistics = selectionOnlyOperator.getExecutionStatistics();
Assert.assertEquals(executionStatistics.getNumDocsScanned(), 10L);
Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 230501L);
Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 100L);
Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 100000L);
selectionDataSchema = resultsBlock.getSelectionDataSchema();
Assert.assertEquals(selectionDataSchema.size(), 10);
Assert.assertEquals(selectionDataSchema.getColumnName(0), "column1");
Assert.assertEquals(selectionDataSchema.getColumnName(5), "column6");
Assert.assertEquals(selectionDataSchema.getColumnType(0), FieldSpec.DataType.INT);
Assert.assertEquals(selectionDataSchema.getColumnType(5), FieldSpec.DataType.INT_ARRAY);
selectionResult = (List<Serializable[]>) resultsBlock.getSelectionResult();
Assert.assertEquals(selectionResult.size(), 10);
firstRow = selectionResult.get(0);
Assert.assertEquals(firstRow.length, 10);
Assert.assertEquals(((Integer) firstRow[0]).intValue(), 890282370);
Assert.assertEquals(firstRow[5], new int[] { 2147483647 });
}
use of java.io.Serializable in project pinot by linkedin.
the class InnerSegmentSelectionMultiValueQueriesTest method testSelectionOrderBy.
@Test
public void testSelectionOrderBy() {
String query = "SELECT" + SELECTION + " FROM testTable" + ORDER_BY;
// Test query without filter.
MSelectionOrderByOperator selectionOrderByOperator = getOperatorForQuery(query);
IntermediateResultsBlock resultsBlock = (IntermediateResultsBlock) selectionOrderByOperator.nextBlock();
ExecutionStatistics executionStatistics = selectionOrderByOperator.getExecutionStatistics();
Assert.assertEquals(executionStatistics.getNumDocsScanned(), 100000L);
Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 0L);
Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 400000L);
Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 100000L);
DataSchema selectionDataSchema = resultsBlock.getSelectionDataSchema();
Assert.assertEquals(selectionDataSchema.size(), 4);
Assert.assertEquals(selectionDataSchema.getColumnName(0), "column5");
Assert.assertEquals(selectionDataSchema.getColumnName(3), "column6");
Assert.assertEquals(selectionDataSchema.getColumnType(0), FieldSpec.DataType.STRING);
Assert.assertEquals(selectionDataSchema.getColumnType(3), FieldSpec.DataType.INT_ARRAY);
Queue<Serializable[]> selectionResult = (Queue<Serializable[]>) resultsBlock.getSelectionResult();
Assert.assertEquals(selectionResult.size(), 10);
Serializable[] lastRow = selectionResult.peek();
Assert.assertEquals(lastRow.length, 4);
Assert.assertEquals((String) lastRow[0], "AKXcXcIqsqOJFsdwxZ");
Assert.assertEquals(lastRow[3], new int[] { 1252 });
// Test query with filter.
selectionOrderByOperator = getOperatorForQueryWithFilter(query);
resultsBlock = (IntermediateResultsBlock) selectionOrderByOperator.nextBlock();
executionStatistics = selectionOrderByOperator.getExecutionStatistics();
Assert.assertEquals(executionStatistics.getNumDocsScanned(), 15620L);
Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 282430L);
Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 62480L);
Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 100000L);
selectionDataSchema = resultsBlock.getSelectionDataSchema();
Assert.assertEquals(selectionDataSchema.size(), 4);
Assert.assertEquals(selectionDataSchema.getColumnName(0), "column5");
Assert.assertEquals(selectionDataSchema.getColumnName(3), "column6");
Assert.assertEquals(selectionDataSchema.getColumnType(0), FieldSpec.DataType.STRING);
Assert.assertEquals(selectionDataSchema.getColumnType(3), FieldSpec.DataType.INT_ARRAY);
selectionResult = (Queue<Serializable[]>) resultsBlock.getSelectionResult();
Assert.assertEquals(selectionResult.size(), 10);
lastRow = selectionResult.peek();
Assert.assertEquals(lastRow.length, 4);
Assert.assertEquals((String) lastRow[0], "AKXcXcIqsqOJFsdwxZ");
Assert.assertEquals(lastRow[3], new int[] { 2147483647 });
}
Aggregations