package com.ldbc.driver.workloads.ldbc.snb.bi; import com.ldbc.driver.Operation; import com.ldbc.driver.SerializingMarshallingException; import java.util.ArrayList; import java.util.List; public class LdbcSnbBiQuery7AuthoritativeUsers extends Operation<List<LdbcSnbBiQuery7AuthoritativeUsersResult>> { public static final int TYPE = 7; public static final int DEFAULT_LIMIT = 100; private final String tag; private final int limit; public LdbcSnbBiQuery7AuthoritativeUsers( String tag, int limit ) { this.tag = tag; this.limit = limit; } public String tag() { return tag; } public int limit() { return limit; } @Override public String toString() { return "LdbcSnbBiQuery7{" + "tag='" + tag + '\'' + ", limit=" + limit + '}'; } @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } LdbcSnbBiQuery7AuthoritativeUsers that = (LdbcSnbBiQuery7AuthoritativeUsers) o; if ( limit != that.limit ) { return false; } return !(tag != null ? !tag.equals( that.tag ) : that.tag != null); } @Override public int hashCode() { int result = tag != null ? tag.hashCode() : 0; result = 31 * result + limit; return result; } @Override public List<LdbcSnbBiQuery7AuthoritativeUsersResult> marshalResult( String serializedResults ) throws SerializingMarshallingException { List<List<Object>> resultsAsList = SerializationUtil.marshalListOfLists( serializedResults ); List<LdbcSnbBiQuery7AuthoritativeUsersResult> result = new ArrayList<>(); for ( int i = 0; i < resultsAsList.size(); i++ ) { List<Object> row = resultsAsList.get( i ); long personId = ((Number) row.get( 0 )).longValue(); int score = ((Number) row.get( 1 )).intValue(); result.add( new LdbcSnbBiQuery7AuthoritativeUsersResult( personId, score ) ); } return result; } @Override public String serializeResult( Object resultsObject ) throws SerializingMarshallingException { List<LdbcSnbBiQuery7AuthoritativeUsersResult> result = (List<LdbcSnbBiQuery7AuthoritativeUsersResult>) resultsObject; List<List<Object>> resultsFields = new ArrayList<>(); for ( int i = 0; i < result.size(); i++ ) { LdbcSnbBiQuery7AuthoritativeUsersResult row = result.get( i ); List<Object> resultFields = new ArrayList<>(); resultFields.add( row.personId() ); resultFields.add( row.score() ); resultsFields.add( resultFields ); } return SerializationUtil.toJson( resultsFields ); } @Override public int type() { return TYPE; } }