18 package com.mysql.clusterj.tie;
20 import java.util.Arrays;
22 import com.mysql.ndbjtie.ndbapi.NdbDictionary.IndexConst;
23 import com.mysql.ndbjtie.ndbapi.NdbDictionary.TableConst;
24 import com.mysql.clusterj.core.store.Index;
25 import com.mysql.clusterj.core.util.I18NHelper;
26 import com.mysql.clusterj.core.util.Logger;
27 import com.mysql.clusterj.core.util.LoggerFactoryService;
32 class IndexImpl
implements Index {
35 static final I18NHelper local = I18NHelper
36 .getInstance(IndexImpl.class);
39 static final Logger logger = LoggerFactoryService.getFactory()
40 .getInstance(IndexImpl.class);
48 private int noOfColumns;
51 private String[] columnNames;
54 private boolean unique;
57 private String internalName;
64 public IndexImpl(IndexConst ndbIndex,
String indexAlias) {
65 this.internalName = ndbIndex.getName();
66 this.tableName = ndbIndex.getTable();
67 this.
name = indexAlias;
68 this.unique = ndbIndex.getType() == IndexConst.Type.UniqueHashIndex;
69 this.noOfColumns = ndbIndex.getNoOfColumns();
70 this.columnNames =
new String[noOfColumns];
71 for (
int i = 0;
i < noOfColumns; ++
i) {
72 String columnName = ndbIndex.getColumn(
i).getName();
73 this.columnNames[
i] = columnName;
75 if (logger.isDetailEnabled()) logger.detail(toString());
84 public IndexImpl(TableConst ndbTable) {
85 this.internalName =
"PRIMARY";
86 this.
name =
"PRIMARY";
87 this.tableName = ndbTable.getName();
89 this.noOfColumns = ndbTable.getNoOfPrimaryKeys();
90 this.columnNames =
new String[noOfColumns];
91 for (
int i = 0;
i < noOfColumns; ++
i) {
92 this.columnNames[
i] = ndbTable.getPrimaryKey(
i);
94 if (logger.isDetailEnabled()) logger.detail(toString());
97 public boolean isUnique() {
105 public String getInternalName() {
109 public String[] getColumnNames() {
114 public String toString() {
115 return "IndexImpl name: " +
name +
" internal name: " + internalName +
" table: " + tableName +
" unique: " + unique +
" columns: " + Arrays.toString(columnNames);